計算機概論
首頁
作業一
說明
作業觀摩
成績
作業二
說明
成績
工具-1
Processing
編輯器
JS001 畫布, 函數, 註解
JS002 變數 動畫
JS003 顏色、迴圈
JS003-1 Hering illusion
JS003-2 Grid Illusion
JS004 判斷式、邏輯符號
JS004-1 Café wall illusion
JS005 滑鼠位置
程式賞析
thanks
love
課程網頁
教科書
程式碼
var i=0, j =0; var len=30, gap =10; // len 表示長方形寬度、 gap 灰色間隔寬度 // 初始設定函式 void setup(){ size(400, 400); // 設定畫布大小 frameRate(24); // 設定每秒24個frames smooth(); // 設定為平滑顯示 background(255, 255, 255); // 設定背影色 noLoop(); // 設定只畫一次 } // 主要繪圖函式 void draw(){ // 灰色長條狀 for (i = 0; i < 11; i++){ fill(175, 175, 175); stroke(175, 175, 175); rect((i+1)*(len+gap)-gap,0,gap,400); rect(0,(i+1)*(len+gap)-gap,400,gap); } for (i = 0; i <400/(gap+len); i++){ for (j = 0; j <400/(gap+len); j++){ // 黑色長方形 stroke(0, 0, 0); fill(0, 0, 0); rect(i*(len+gap),j*(len+gap),len,len); // 白色圓形 fill(255,255, 255); stroke(255, 255, 255); ellipse((i+1)*(len+gap)-gap/2,(j+1)*(len+gap)-gap/2,gap,gap); } } }
畫布
輸出
None.