Processing
01 Hello World & Variable & Setup HELLO世界 & 變數 & 設定
Now We Code it. 終於可以寫程式了^_^
記得結尾要 “;” Remember to end with “;”
END Function
string
print (“Hello World !!!”); open
close
2
1
Type what I tell you in this AREA Then press “play” (compile) to “RUN” the code
在空白處 打上字然後按RUN
3
You will see that what you type, is coming right here! 下面就會 This is your “FIRST CODE!” 出現結果
END Function
string
Print (“Hello Kitty !!!”); open
close
VARIABLE 參數
NAME
EXAMPLE
整數
int(integer
1,2,3,4,5…99,1304
小數
float
0.5, 2.78, 3.1415….
字串
string
HappyBody
布林
boolean
True or False
)
(floating numbers)
宣告參數 Declare the Variables Let computer knows who you are
int x;
this is “x” and it is an integer
float y;
this is “y” and it is a floating number
這是 x 它是一個整數
這是 y 它是一個帶小數的數字
Declare the Variables int x; x=100;
write it in 2 lines. 寫成兩行
float y = 20.845;
write it in 1 lines. 寫成一行
println(x); println(y); println(“x+y=” + x+y);
RESULT
CODE
RESULT
STOP CACULATE PLEASE!!!!!!!!!!! 我不要算拉!!!
SET UP 設定
void setup(){ //basic setup, run once 跑一次 } 基本設定
void draw(){ //draw something, run as loop 捉傷心(畫東西) 跑跑跑一直跑 }
END Function
string
ellipse (locX, loxY, Xr, Yr); open
close
0
500 200 200 50
500
Are you Bored? 無聊否?
Fill color 填色
Background refresh If you put this in draw 背景刷新 如果你 把此放在 draw
2 1 4
3
void setup(){ size(500,500); smooth(); } void draw(){ fill(mouseX-245, mouseY-245, (mouseX+mouseY)/10); ellipse(250,250,mouseX,mouseY); }
Reference