More Related Content Similar to Proga 0608 (20) More from Atsushi Tadokoro (20) Proga 060813. void setup() {
size(400, 400);
background(0);
colorMode(HSB,360,100,100);
stroke(0,0,100);
fill(200,100,100);
}
void draw() {
rectMode(CENTER);
rect(width/2,height/2,200,200);
}
16. RectDrawer r = new RectDrawer();
void setup() {
size(400, 400);
background(0);
colorMode(HSB,360,100,100);
stroke(0,0,100);
fill(200,100,100);
rectMode(CENTER);
}
void draw() {
r.drawRect();
}
class RectDrawer {
void drawRect() {
rect(width/2,height/2,200,200);
}
}
20. RectDrawer r1;
RectDrawer r2;
void setup() {
size(400, 400);
colorMode(HSB,360,100,100);
stroke(0,0,100);
fill(200,100,100);
rectMode(CENTER);
}
void draw() {
background(0);
r1 = new RectDrawer(200,200,200);
r2 = new RectDrawer(110,260,150);
r1.drawRect();
r2.drawRect();
}
21. class RectDrawer {
float x, y, rectSize;
RectDrawer(float x, float y, float rectSize){
this.x = x;
this.y = y;
this.rectSize = rectSize;
}
void drawRect() {
rect(x,y,rectSize,rectSize);
}
}
25. class Car {
color c;
float xpos;
float ypos;
float xvel;
Car(color c, float xpos, float ypos, float xvel) {
this.c = c;
this.xpos = xpos;
this.ypos = ypos;
this.xvel = xvel;
}
void draw () {
fill(c);
rect(xpos,ypos,20,10);
}
26. void drive () {
xpos = xpos + xvel;
if (xpos > width) {
xpos = -20;
}
}
}
28. Car myCar1;
Car myCar2;
void setup() {
size(400,400);
frameRate(30);
colorMode(HSB,360,100,100);
myCar1 = new Car(color(200,100,100),0,150,1);
myCar2 = new Car(color(0,100,100),0,250,2);
}
void draw() {
background(0);
myCar1.draw();
myCar2.draw();
myCar1.drive();
myCar2.drive();
}
29. class Car {
color c;
float xpos;
float ypos;
float xvel;
Car(color c, float xpos, float ypos, float xvel) {
this.c = c;
this.xpos = xpos;
this.ypos = ypos;
this.xvel = xvel;
}
void draw () {
fill(c);
rect(xpos,ypos,20,10);
}
30. void drive () {
xpos = xpos + xvel;
if (xpos > width) {
xpos = -20;
}
}
}
32. int MAX = 100;
Car[] myCars = new Car[MAX];
void setup() {
size(400,400);
frameRate(30);
noStroke();
colorMode(HSB,360,100,100);
for (int i = 0; i < MAX; i++) {
color tempcolor =
color(random(360),random(50,100),random(50,100));
myCars[i]
= new
Car(tempcolor,random(width),random(height),random(1,5));
}
}
33. void draw() {
background(0);
for (int i = 0; i < MAX; i++) {
myCars[i].drive();
myCars[i].draw();
}
}
34. class Car {
color c;
float xpos;
float ypos;
float xvel;
Car(color c, float xpos, float ypos, float xvel) {
this.c = c;
this.xpos = xpos;
this.ypos = ypos;
this.xvel = xvel;
}
void draw () {
fill(c);
rect(xpos,ypos,20,10);
}
35. void drive () {
xpos = xpos + xvel;
if (xpos > width) {
xpos = -20;
}
}
}
37. int num = 3000;
float[] a = new float[4];
float drawScale = 0.2;
float range = 2.5;
boolean drawing = false;
Attr[] attr = new Attr[num];
void setup(){
size(640,640);
background(0);
fill(255,255,255,40);
noStroke();
smooth();
framerate(30);
newDraw();
drawing = true;
}
38. void draw(){
for(int i=0;i<num;i++){
attr[i].update();
}
}
void mouseReleased(){
if(!drawing){
newDraw();
drawing = true;
loop();
}
else {
noLoop();
drawing = false;
}
}
39. void newDraw(){
background(0);
initParam();
for(int i=0;i<num;i++){
attr[i]=new Attr();
}
}
void initParam(){
a[0] =random(0,3.0);
a[1] =random(0,3.0);
a[2] =random(0,3.0);
a[3] =random(0,3.0);
}
40. class Attr {
float nx,ny,ox,oy;
color myc;
Attr(){
ox =random(-2.0,2.0);
oy =random(-2.0,2.0);
}
void update(){
nx = sin(a[0]*oy)-cos(a[1]*ox);
ny = sin(a[2]*ox)-cos(a[3]*oy);
ellipse(nx*width*drawScale+width/2, ny*height*drawScale
+height/2, 0.3, 0.3);
ox=nx;
oy=ny;
}
}