class Balloon{
float x;
float y;
float r;
Balloon(int x, int y, int r){
this.x = x;
this.y = y;
this.r = r;
}
void display(){
line(this.x , this.y, this.x, this.y+this.r);
ellipse(this.x, this.y, this.r, this.r);
}
void move_up(){
this.y = this.y-3;
if(this.y < 0){this.y = height;}
}
void move_right(){
this.x = this.x+1.5;
if(this.x > width){this.x = 0;}
}
void fill_c(){
fill(this.x+this.y-445);
}
}
int B_num = 6;
Balloon b[] = new Balloon[B_num];
void setup(){
size(500, 500);
for( int i = 0; i < B_num; i++){
b[i] = new Balloon(63+(i*63), height, 50);
}
}
void draw(){
background(255);
for( int i = 0; i < B_num; i++){
b[i].fill_c();
b[i].display();
b[i].move_up();
b[i].move_right();
}
}
Monday, 20 October 2014
Wednesday, 15 October 2014
Lab 4
int Table = 8;
int Rect_w_h = Table*10;
int size = Table*Rect_w_h;
int[][] T = new int[Table][Table];// row -- col /
void setup(){
size(size, size);
for(int i = 0; i < Table; i++){
for(int j = 0; j < Table; j++){
if(i%2 == 0){ if( j%2 == 0){ T[i][j] = 0; } else{ T[i][j] = 255; } }
else{ if( j%2 == 0){ T[i][j] = 255; } else{ T[i][j] = 0; } }
}
}
for(int i = 0; i < Table; i++){
for(int j = 0; j < Table; j++){
println("T "+i+" "+j+" "+T[i][j]);
}
}
}
void draw(){
for(int x = 0; x < size; x += Rect_w_h){
for(int y = 0; y < size; y += Rect_w_h){
int Fill_index1 = x/Rect_w_h;
int Fill_index2 = y/Rect_w_h;
fill(T[Fill_index1][Fill_index2]);
rect(x, y, size, size);
}
}
}
int Rect_w_h = Table*10;
int size = Table*Rect_w_h;
int[][] T = new int[Table][Table];// row -- col /
void setup(){
size(size, size);
for(int i = 0; i < Table; i++){
for(int j = 0; j < Table; j++){
if(i%2 == 0){ if( j%2 == 0){ T[i][j] = 0; } else{ T[i][j] = 255; } }
else{ if( j%2 == 0){ T[i][j] = 255; } else{ T[i][j] = 0; } }
}
}
for(int i = 0; i < Table; i++){
for(int j = 0; j < Table; j++){
println("T "+i+" "+j+" "+T[i][j]);
}
}
}
void draw(){
for(int x = 0; x < size; x += Rect_w_h){
for(int y = 0; y < size; y += Rect_w_h){
int Fill_index1 = x/Rect_w_h;
int Fill_index2 = y/Rect_w_h;
fill(T[Fill_index1][Fill_index2]);
rect(x, y, size, size);
}
}
}
Thursday, 9 October 2014
Bug Report from Assignment 1
1. ตั้งค่าการวนลูปผิด( < , > )ทำให้โปรเเกรมข้ามการวนลูปหรือทำซํ้าตลอด
- เปลี่ยน เคื่องหมาย (<,>) ให้ถูกต้อง
2. พิมพ์คำสั่งผิดทำให้โปรเเกรมไม่ทำงาน
-เช็คใน reference เพื่อดูคำสั่งที่ถูกต้อง
3. กำหนดชนิดของตัวเเปรไม่ถูกต้องทำให้ค่าที่ออกมาไม่เป็นที่ต้องการ
- เเก้ไขจาก Int เป็น float เพื่อให้
4.ไม่ได้ใส noFill(); ท้ายฟังกชันทำให้สีที่ใส่ต่อไป ผิดพลาด
-ใส่noFill ท้ายฟังกชัน
Subscribe to:
Posts (Atom)