40723210 網際內容管理

  • Home
    • Site Map
    • reveal
    • blog
  • 簡介
    • vi 與 vim 的指令整理
    • git基本指令
    • python基本語法
    • Dos 基本指令
  • 網路連線設定
  • 配置可攜程式環境
  • 倉儲改版
  • 靜態 CMSimfly
  • Mobile 網站內容
  • Virtual Host
  • Javascript
    • First game
    • canvas
    • Spur Gear1
    • Spur Gears
    • 國旗-改
    • 國旗-改2
    • 國旗-改3
    • 貪食蛇
    • 打磚塊
    • 程式嵌入
  • 問題探討與解決
  • 期中報告
  • 期末報告
First game << Previous Next >> Spur Gear1

canvas

Your browser doesn't support the HTML5 element canvas.

<p><canvas height="300" id="canvas" width="400"> Your browser doesn't support the HTML5 element canvas. </canvas></p>
<script>
canvas = document.getElementById("canvas");
ctx = canvas.getContext('2d');
 
function draw(){
 ctx.beginPath();
 ctx.strokeStyle = "rgb(200,0,0)";
 ctx.arc(200, 200,50,0,2*Math.PI, false);
 ctx.closePath();
 ctx.stroke();
}
 
function clear_canvas(){
// Store the current transformation matrix
// The save() method pushes the current state onto the stack..
ctx.save();
 
// Use the identity matrix while clearing the canvas
// the setTransform() method lets you scale, rotate, move, and skew the current context.
// setTransform(Horizontal scaling, Horizontal skewing,Vertical skewing, Vertical scaling, Horizontal moving, Vertical moving)
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Restore the transform
// The restore() method pops the top state on the stack, restoring the context to that state.
ctx.restore();
}
</script>
<p><button onclick="draw()">繪圖</button> <button onclick="clear_canvas()">清除</button></p>

First game << Previous Next >> Spur Gear1

Copyright © All rights reserved | This template is made with by Colorlib