期中作業
11_1(錯覺)
//week_11_01_ball_picture
PImage img = loadImage("ball.png");
size(640,569);
background(img);
fill(0);
for(float y=21;y<569;y+=13.748){
for(float x=2;x<640;x+=30){
ellipse(x,y,12,12);
}
}
for(float y=21;y<569;y+=13.748){
for(float x=2+15;x<640;x+=30){
ellipse(x,y,12,12);
}
}
11_2(錯覺)
//week_11_02_color_dot
size(600, 600);
noStroke();
fill(236, 152, 52);//色彩一
rect(0, 0, 300, 300);
fill(122, 202, 249);//色彩二
rect(300, 0, 300, 300);
fill(129, 241, 128);//色彩三
rect(0, 300, 300, 300);
fill(230, 95, 155);
rect(300, 300, 300, 300);//色彩四
fill(122, 202, 249);
for(float y = 0; y< 300;y += 15){
for(float x = 0; x<300; x += 30){
ellipse(x, y, 11, 11);
ellipse(x+15, y+7, 11, 11);
}
}
fill(236, 152, 52);
for(float y = 0; y< 300;y += 15){
for(float x = 0; x<300; x += 30){
ellipse(x, y, 11, 11);
ellipse(300+x+15, y+7, 11, 11);
}
}
11_3(錯覺)
//week11_03_color_ball_dot
size(600, 600);
noStroke();
fill(236, 152, 52);//色彩一
rect(0, 0, 300, 300);
fill(122, 202, 249);//色彩二
rect(300, 0, 300, 300);
fill(129, 241, 128);//色彩三
rect(0, 300, 300, 300);
fill(230, 95, 155);//色彩四
rect(300, 300, 300, 300);
fill(191, 156, 205);
ellipse(150, 150, 150, 150);
ellipse(450, 150, 150, 150);
ellipse(150, 450, 150, 150);
ellipse(450, 450, 150, 150);
for(float y = 0; y< 600;y += 15){
for(float x = 0; x<600; x += 30){
if(6+x<300 && 6+y<300)fill(122, 202, 249);
if(6+x>300 && 6+y<300)fill(236, 152, 52);
if(6+x<300 && 6+y>300)fill(230, 295, 155);
if(6+x>300 && 6+y>300)fill(129, 241, 128);
ellipse(6+x, y, 11, 11);
ellipse(6+x+15, y+7, 11, 11);
}
}
11_4(陣列)
//week11_04_array
ArrayList<Integer> a = new ArrayList<Integer>();
a.add(3);
a.add(5);
a.add(7);
for(Integer i : a){
println(i);
}
for(int i= 0;i<a.size();i++){
println(a.get(i));
}
11_5(Arraylist)
//week_11_05_ArrayList_card
class Card{
int x,y;
void draw(){
rect(x,y,100,150);
}
}
Card card1 = new Card();
void setup(){
size(500,400);
card1.x = 100;
card1.y = 100;
}
void draw(){
card1.draw();
}
11_6(class)
//week_11_06_class_card_draw
class Card {
int x, y;
Card(int _x, int _y) {
x=_x;
y=_y;
}
void draw() {
rect(x, y, 100, 150);
}
}
Card card1 = new Card(100,100);
void setup(){
size(500,400);
}
void draw(){
card1.draw();
}
沒有留言:
張貼留言