xxxxxxxxxx
float xpos1=500;
float ypos1=0;
float xpos2=500;
float ypos2=500;
float xpos3=0;
float ypos3=500;
float apos1=500;
float bpos1=0;
float apos2=0;
float bpos2=0;
float apos3=0;
float bpos3=500;
tri[] myTri = new tri[10];
tri2[] myTri2 = new tri2[50];
int num=500;
DotX[] myDotX = new DotX[num];
int num1=500;
DotY[] myDotY = new DotY[num1];
void setup() {
background(255);
size(500, 500); //sets the size of the frame
for (int i = 0; i<10; i++) {
myTri[i] = new tri(255, xpos1, ypos1, xpos2, ypos2, xpos3, ypos3);
xpos1 = xpos1-50;
ypos1 = ypos1+50;
xpos2 = xpos2-50; //this is the change in between each triangle
ypos2 = ypos2;
xpos3 = xpos3;
ypos3 = ypos3;
println(xpos1); //vertical triangles that oer lap each other
}
for (int j = 0; j<50; j++) {
myTri2[j] = new tri2(255, apos1, bpos1, apos2, bpos2, apos3, bpos3);
apos1 = apos1-10;
bpos1 = bpos1+10;
apos2 = apos2;
bpos2 = bpos2+10;
apos3 = apos3;
bpos3 = bpos3;
println(apos1);
}
for (int l = 0; l<num; l++) {
myDotX[l] = new DotX(255-l*10, 0, 0+l*3, random (1, 7)); //this is the dots floating horizontally
}
for (int k = 0; k<num1; k++){
myDotY[k] = new DotY(255-k*10, 0+k*3, height, random (1,5)); //dots floating vertically
}
}
void draw() {
for (int i = 0; i<myTri.length; i++) {
myTri[i].display();
}
for (int j = 0; j<myTri2.length; j++) {
myTri2[j].display();
}
for (int l=0; l<myDotX.length; l++){
myDotX[l].display();
myDotX[l].move();
}
for (int k=0; k<myDotY.length; k++){
myDotY[k].display();
myDotY[k].move();
}
}
class DotX{
color c;
float x;
int y;
float speed;
DotX(color tempC, float tempX, int tempY, float tempSpeed){
c = tempC;
x = tempX;
y = tempY;
speed = tempSpeed;
}
void display(){
fill(0);
ellipse(x,y,2,2);
}
void move(){
x=x+speed;
if(x>width){
x=-20;
}
}
}
class DotY{
color c;
int x;
float y;
float speed;
DotY(color tempC, int tempX, float tempY, float tempSpeed) {
c = tempC;
x = tempX;
y = tempY;
speed = tempSpeed;
}
void display() {
fill(0);
ellipse(x, y, 3, 3);
}
void move() {
y=y-speed;
if (y<0) {
y=height+20;
}
}
} //instruction for building vertical dots
class tri{
color c;
float x1;
float x2;
float x3;
float y1;
float y2;
float y3;
tri(color tempColor, float tempX1, float tempY1, float tempX2, float tempY2, float tempX3, float tempY3){
c = tempColor;
x1 = tempX1;
y1 = tempY1;
x2 = tempX2;
y2 = tempY2;
x3 = tempX3;
y3 = tempY3;
}
void display(){
fill(255);
stroke(0);
triangle(x1,y1,x2,y2,x3,y3);
}
}
class tri2{
color c;
float a1;
float a2;
float a3;
float b1;
float b2;
float b3;
tri2(color tempColor, float tempA1, float tempB1, float tempA2, float tempB2, float tempA3, float tempB3){
c = tempColor;
a1 = tempA1;
b1 = tempB1;
a2 = tempA2;
b2 = tempB2;
a3 = tempA3;
b3 = tempB3;
}
void display(){
fill(255);
stroke(0);
triangle(a1,b1,a2,b2,a3,b3);
}
}