50733113-陳志嘉個人網頁

  • Home
    • Site Map
    • reveal
    • blog
  • 首頁簡介
    • 頁面資源
      • git http 與 ssh
      • 目錄結構
      • 頁面編輯
      • 插入程式碼
      • Java 程式碼
      • Python 程式碼
      • C或C++程式碼
      • Lua 程式碼
      • Javascript 程式碼
      • Html 原始碼
      • 網際簡報
      • 網誌編輯
      • 已知錯誤
  • 相關資訊
    • Proxy 設定
    • 隨身碟格式化
    • GitHub 倉儲建立
  • 筆記整理
    • git 等相關指令
  • 課程內容
    • 校園免費授權
      • windows 10
    • TWAREN SSL-VPN
    • Ubuntu 18.04
    • FileZilla
    • VirtualBox
    • 虛擬主機開啟動態網站
  • ROC flag(w14)
    • ROC Flag 成果
  • 程式
    • 亂數產生系統
    • 骰子
    • 繪圖
  • 期中操作影片
  • 期末報告
骰子 << Previous Next >> 期中操作影片

繪圖

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>// <![CDATA[
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>

骰子 << Previous Next >> 期中操作影片

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