Upload
gary-chang
View
213
Download
1
Embed Size (px)
DESCRIPTION
A_Little_Bit_Processing_Tutorial
Citation preview
Processing
ArrayList Simple Practice
0701
陣列小練習
ArrayListPractice陣列小練習
{ }ArrayList
If you got this…如果你懂這個的話…
Think of How?想想看怎麼做這個 ?
First, you might
think in this way(Directly)
Probably I (Gary) am stupid
你可能會先這樣做又或許只有我這麼笨
import peasy.test.*;import peasy.org.apache.commons.math.*;import peasy.*;import peasy.org.apache.commons.math.geometry.*;PeasyCam cam;
void setup(){size(1000,1000,P3D);cam = new PeasyCam(this,0,0,0,1000);}
void draw(){background(0); for(int i =0; i<500; i+=50){ for(int j=0; j<500; j+=50){ fill(map(i,0,500,0,255),map(j,0,500,0,255),random(100,255)); pushMatrix(); translate(i,j,0); box(30,30,random(500)); popMatrix(); } }}
NOTHINGHAPPENS???!!!
If you like it this way, it’s also fine
如果你喜歡這樣也可以
Problem 01:Keep updating, not static.
Problem 02:The height extend in both sides
一直抖一直抖
高度往兩邊長
Now we need
ArrayList所以我們需要ArrayList
import peasy.test.*;import peasy.org.apache.commons.math.*;import peasy.*;import peasy.org.apache.commons.math.geometry.*;PeasyCam cam;
ArrayList randomH;
void setup(){size(1000,1000,P3D);cam = new PeasyCam(this,0,0,0,1000);randomH = new ArrayList();
for(int i =0; i<500; i+=50){ for(int j=0; j<500; j=j+50){ PVector h = new PVector(i,j,random(0,300)); randomH.add(h); } }}
void draw(){background(0);for(int i =0; i<randomH.size();i++){ PVector nH = (PVector)randomH.get(i); pushMatrix(); fill(map(nH.x,0,500,0,255),map(nH.y,0,500,0,255),map(nH.z,0,500,0,255)); translate(nH.x,nH.y,nH.z/2); box(30,30,nH.z); popMatrix(); }}
Create an ArrayList
Declare the ArrayList
Put stuffs inside
Call them out
Draw boxesFix the double sides problem
創造一個 ArrayList
宣告一個 ArrayList
在 ArrayList裡面放入東西
把他們取出來呈現
畫方盒解決往兩邊延長的問題
DONE!
完成