티스토리 뷰
Syntax
ctx.measureText(text);
Parameters
- text
- The text to measure.
Return value
A TextMetrics
object.
Source
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | function draw() { var ctx = document.getElementById( 'canvas' ).getContext( '2d' ); ctx.font = "48px serif" ; ctx.fillText( "Hello world" , 10, 50); ctx.font = "48px serif" ; ctx.strokeText( "Hello world" , 10, 100); ctx.font = "48px serif" ; ctx.fillText(ctx.measureText( "Hello world" ).width, 10, 150); ctx.font = "48px serif" ; ctx.fillText( "Hello world" , 10, 200, 100); } |
Demo
'Develop > canvas' 카테고리의 다른 글
33 .clip() - 잘라내기 (0) | 2015.08.10 |
---|---|
32. globalCompositeOperation - 색상 블렌딩모드 (합성) (0) | 2015.08.10 |
31. measureText() - 글자의 넓이 반환 (0) | 2015.08.10 |
30. strokeText() - 라인으로 글쓰기 (0) | 2015.08.10 |
29. fillText() - 글자그리기 (0) | 2015.08.10 |
28. transform() - 회전 (0) | 2015.08.10 |
- TAG
- Canvas, fillText, HTML5, JavaScript, measureText, strokeText, 글, 글쓰기, 글자, 자바스크립트, 캔버스, 텍스트
댓글
공지사항
최근에 달린 댓글
- Total
- 56,252
- Today
- 12
- Yesterday
- 49
링크
TAG
- 글
- Round
- Fill
- 라즈베리파이
- 캔버스
- stroke()
- fillText
- translate
- arc()
- 글자
- 튜토리얼
- Canvas
- Bezier
- 글쓰기
- rect
- measureText
- 곡선
- 도형그리기
- 배경색
- virtualhost
- 텍스트
- 베지어
- Symfony
- 자바스크립트
- JavaScript
- GitLab
- HTML5
- save
- 심포니
- strokeText