正在加载图片...
实例:在canvas中绘制矩形 <body> <canvas id="myCanvas"> your browser does not support the canvas tag </canvas> 得到画布 <script type="text/javascript"> var canvas=document.getElementByld('myCanvas); var ctx=canvas.getContext('2d) ctx.fillStyle='#FF0000'; 创建context对象; ctx.fillRect(0,0_80,100): getContext("2d")对象是内建 的HTML5对象,拥有多种绘 </script> fillStyle方法将context对象染 制路径、矩形、圆形、字符以 <body≥ 成红色, 及添加图像的方法 fillRect方法规定了形状、位 置和尺寸。 fillRect方法拥有参数(0,0,80,100). 意思是:在画布上绘制80x100的矩形,从左上角开始(0,0) 理解坐标 实例: 在canvas中绘制矩形 <body> <canvas id="myCanvas"> your browser does not support the canvas tag </canvas> <script type="text/javascript"> var canvas=document.getElementById('myCanvas'); var ctx=canvas.getContext('2d'); ctx.fillStyle='#FF0000'; ctx.fillRect(0,0,80,100); </script> </body> 得到画布 创建 context 对象; getContext("2d") 对象是内建 的 HTML5 对象,拥有多种绘 制路径、矩形、圆形、字符以 及添加图像的方法 fillStyle 方法将context对象染 成红色, fillRect 方法规定了形状、位 置和尺寸。 fillRect 方法拥有参数 (0,0,80,100)。 意思是:在画布上绘制 80x100 的矩形,从左上角开始 (0,0)。 理解坐标
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有