2015FALL 40423117 CADPA 作業

2015 計算機程式 12/18

html導入brython利用其繪圖技巧:

12/18 html導入brython 投影片

簡易繪圖程式碼分享

<!-- 導入 brython.js -->

<script type="text/javascript" src="http://brython.info/src/brython_dist.js"></script>


<!-- 啟動 brython() -->

<script>
window.onload=function(){
brython(1);
}
</script>

<!-- 以下利用 Brython 程式執行繪圖 -->

<canvas id="plotarea1" width="200" height="200"></canvas>

<script type="text/python3">
# 導入 doc
from browser import document as doc
from browser import console
import math

# 準備繪圖畫布
canvas1 = doc["plotarea1"]
ctx1 = canvas1.getContext("2d")

# 開始畫直線
for i in range(11):
    ctx1.beginPath()
    ctx1.lineWidth = 5
    ctx1.moveTo(0,0+i*20 )
    ctx1.lineTo(200,0+i*20 )
    ctx1.strokeStyle = "#0000ff"
    ctx1.stroke()
for i in range(11):
    ctx1.beginPath()
    ctx1.lineWidth = 5
    ctx1.moveTo(0+i*20, 0)
    ctx1.lineTo(0+i*20, 200)
    ctx1.strokeStyle = "#FF0000"
    ctx1.stroke()


</script>


<script>
window.onload=function(){
brython(1);
}
</script>

期中到期末的複習影片

Review_fix.bat_Python from 40423117 on Vimeo.

Comments