計算機概論
首頁
作業一
說明
作業觀摩
成績
作業二
說明
成績
工具-1
Processing
編輯器
JS001 畫布, 函數, 註解
JS002 變數 動畫
JS003 顏色、迴圈
JS003-1 Hering illusion
JS003-2 Grid Illusion
JS004 判斷式、邏輯符號
JS004-1 Café wall illusion
JS005 滑鼠位置
程式賞析
thanks
love
課程網頁
教科書
程式碼
// 全域變數 float radius = 50.0; int X, Y; int nX, nY; int delay = 16; // 初始設定函式 void setup(){ size( 400, 400 ); strokeWeight( 10 ); frameRate( 15 ); X = width / 2; Y = height / 2; nX = X; nY = Y; } // 主要繪圖函式 void draw(){ radius = radius + sin( frameCount / 4 ); // Track circle to new destination X+=(nX-X)/delay; Y+=(nY-Y)/delay; // Fill canvas grey background( 100 ); // Set fill-color to blue fill( 0, 121, 184 ); // Set stroke-color white stroke(255); // Draw circle ellipse( X, Y, radius, radius ); } // 滑鼠移動事件 void mouseMoved(){ nX = mouseX; nY = mouseY; }
畫布
輸出
None.