FMC2nd_p43_Lines13

p43_Lines13

p43_Lines13


イメージからアプレットを起動

Lines12を元に、線の描画を1本ずつ。
Lines12で変更したLines.pde(クラス)はそのままに、インスタンス化しているメインだけの変更。


[java]
int leftBounds = 20;
int topBounds = 20;
float x = leftBounds;
float y = topBounds;
int rightBounds = 380;
int bottomBounds = 380;
int baseMax = 20;
int randomMax = 10;
int maxLines = 1000;
int counter = 0;

int steps = 20;
boolean nextLine = false;
//int alpha = 0;

Line[] Lines;
//Ellipse[] Ellipses;

void setup(){
size(400, 400);
// frameRate(10);
colorMode(HSB, 360, 100, 100);
background(0, 0, 100);

Lines = new Line[maxLines];
// Ellipses = new Ellipse[maxLines];

strokeWeight(1);
smooth();
}

void draw(){
background(0,0,100);

if(steps > 20 && !nextLine) nextLine = true;

if(counter < maxLines && nextLine){
float maxDistance = baseMax * random(0, 1) * randomMax;
float minDistance = 2;
int direction = random(0, 1) < 0.5 ? -1 : 1;
float xEnd = x + (direction * (minDistance + ( random(0, 1) * maxDistance)) );
direction = random(0, 1) < 0.5 ? -1 : 1;
float yEnd = y + (direction * (minDistance + ( random(0, 1) * maxDistance)) );

if(xEnd < leftBounds) xEnd = leftBounds;
if(xEnd > rightBounds) xEnd = rightBounds;
if(yEnd < topBounds) yEnd = topBounds;
if(yEnd > bottomBounds) yEnd = bottomBounds;

Lines[counter] = new Line(x, y, xEnd, yEnd);

// Lines[counter].setAlpha(alpha);
// Ellipses[counter] = new Ellipse(x, y, maxDistance * .2, maxDistance * .2);

x = xEnd;
y = yEnd;

steps = 0;
nextLine = false;

counter++;
}
steps++;
// alpha++;
// if(alpha > 255) alpha = 0;

// if(counter >= 10 && counter // else if(counter > maxLines && counter < maxLines+10) {
// Lines[counter-10].disappear();
// }
// else if(counter > maxLines+10) noLoop();

if(counter < maxLines){
for(int i=0; i Lines[i].bdraw();
// Ellipses[i].bdraw();
}
}
else{
for(int i=0; i< maxLines; i++){
Lines[i].bdraw();
// Ellipses[i].bdraw();
}
}
}

void keyPressed(){
if(key == ‘r’){
background(255);
counter = 0;
Lines = new Line[maxLines];
// Ellipses = new Ellipse[maxLines];
}
if(key ==’q'){
saveFrame(“p43_Lines13.jpg”);
exit();
}
}
[/java]

タグ:

コメントをどうぞ