平移坐标系到canvas的中心位置,用下列哪个Canvas方法来实现?绘图环境对象为context。
A: context.translate(canvas.width/2,canvas.height/2);
B: context.transform(canvas.width/2,canvas.height/2);
C: context.transfer(canvas.width/2,canvas.height/2);
D: context.translation(canvas.width/2,canvas.height/2);
A: context.translate(canvas.width/2,canvas.height/2);
B: context.transform(canvas.width/2,canvas.height/2);
C: context.transfer(canvas.width/2,canvas.height/2);
D: context.translation(canvas.width/2,canvas.height/2);
举一反三
- 当用CSS修改canvas的width和height后,canvas的大小发生变化,还会影响绘图环境context的大小。
- 清除某一离屏canvas的左半部分的内容,然后绘制于当前canvas,下方需补全的代码是?// 此处为清除某一离屏canvas的左半部分的内容----- 补全代码处 -----context.drawImage(offcanvas, 0,0); A: offcanvas.clearRect(0, 0, canvas.width/2, canvas.height); B: offcanvas.getContext('2d').clearRect(0, 0, canvas.width/2, canvas.height); C: offcanvas.clearRect(0, 0, offcanvas.width/2, offcanvas.height); D: offcanvas.getContext('2d').clearRect(0, 0, offcanvas.width/2, offcanvas.height);
- HTML5画布API中创建一个宽度为200px、高度为50px的画布,以下哪句代码正确?( )。 A: <;canvas id=”myCanvas” w=”200” h=”50”>;<;/canvas>; B: <;canvas id=”myCanvas” w=”200px” h=”50px”>;<;/canvas>; C: <;canvas id=”myCanvas” width=”200” height=”50”>;<;/canvas>; D: <;canvas id=”myCanvas” width=”200px” height=”50px”>;<;/canvas>;
- JS 文件通过哪个命令获取canvas对象? A: getWebGLContext(canvas) B: document.getElementById("example") C: canvas.getContext(2d) D: <canvas id="webgl" width="400" height="400"></canvas>
- 画布(如下代码)创建后,怎样获取? [canvas id="myCanvas" width="200" height="100"] </canvas A: var canvas=document.getElementById('myCanvas'); B: var canvas=document.getElementsByName('myCanvas'); C: var canvas=document.getElementsById('myCanvas'); D: var canvas=document.getElementById('mycanvas');