'html5 canvas fillText'에 해당되는 글 2건

  1. 2013.12.10 html5 canvas text font color 글자 색상 fillStyle
  2. 2013.12.10 html5 canvas text font 글자 fillText
프로그램/html52013. 12. 10. 16:35

 

<!DOCTYPE HTML>
<html>
 <head>
  <title>HTML5 Canvas Text Font Color</title>
  <script type="text/javascript">
  var ctx;

  function init()
  {
   ctx = document.getElementById('canvas').getContext('2d');
   ctx.font = "20px Gulim";
   ctx.fillText("Hello World - 보통 20px 굴림", 20, 30);
   ctx.font = "bold 20px Gulim";
   ctx.fillText("Hello World - 굵게 20px 굴림", 30, 60);
   ctx.font = "italic 20px Gulim";
   ctx.fillText("Hello World - italic 20px 굴림", 40, 90);
   ctx.font = "20px Gulim";
   ctx.fillStyle = "red";
   ctx.fillText("Hello World - 보통 20px 굴림", 50, 120);
  }
  </script>
 </head>
<body onLoad="init()">
 <canvas id="canvas" width="400" height="140" style="border:1px solid;">
  이 브라우저는 HTML5의 canvas 요소를 지원하지 않습니다.
 </canvas>
</body>
</html>

 

설명>

ctx.fillStyle = "색상";

ctx.fillStyle = "#ff0000";

ctx.fillStyle = "rgb(255, 0, 0)";

ctx.fillStyle = "red";

Posted by 은둔고수
프로그램/html52013. 12. 10. 15:42

<!DOCTYPE HTML>
<html>
 <head>
  <title>HTML5 Canvas Text Font</title>
  <script type="text/javascript">
  var ctx;

  function init()
  {
   ctx = document.getElementById('canvas').getContext('2d');
   ctx.font = "20px Gulim";
   ctx.fillText("Hello World - 보통 20px 굴림", 20, 30);
   ctx.font = "bold 20px Gulim";
   ctx.fillText("Hello World - 굵게 20px 굴림", 30, 60);
   ctx.font = "italic 20px Gulim";
   ctx.fillText("Hello World - italic 20px 굴림", 40, 90);
   ctx.font = "20px Gulim";
   ctx.fontStyle = "red";
   ctx.fillText("Hello World - 보통 20px 굴림", 50, 120);
  }
  </script>
 </head>
<body onLoad="init()">
 <canvas id="canvas" width="400" height="150" style="border:1px solid;">
  이 브라우저는 HTML5의 canvas 요소를 지원하지 않습니다.
 </canvas>
</body>
</html>

 

설명>

ctx.font = "글자 스타일(normal, italic, bold) 지정, 글자 크기, 글자 종류"; // 기본 normal

ctx.fillText("출력할 내용", x위치, y위치);

Posted by 은둔고수