class Cord { float x; float y; float x2; float y2; boolean on; int angle =0; color d = color(random(50,250),random(2,200),random(2,250)); // constructor Cord() { on = false; } // display cord void display() { stroke(d); line(x,y,x2,y2); } void setLocation(float _x, float _y, float _x2, float _y2) { x=_x; y=_y; x2=_x2; y2=_y2; } // when components connect to each other void doSomethingComp(Component a, Component b, Circle h) { if (a.shape.equals("la") && b.shape.equals("la2") && !mousePressed && frameCount>333333) { angle += 2; float val = cos(radians(angle)) * a.y/1.1; for (int k = 0; k < 360; k+= 15) { float xoff = cos(radians(k)) * val; float yoff = sin(radians(k)) * val; stroke(d); fill(d,10); ellipse(h.x + xoff, h.y + yoff, val/2, val/2); } fill(d,10); ellipse(h.x, h.y,5,5); } } // when components connect to the center void doSomethingCenter(Component b) { if (b.shape.equals("circle")) { noFill(); ellipse(width/2,height/2,80,80); } else if (b.shape.equals("square")) { fill(b.x,0,b.y,20); rect(width/2,height/2,120,120); } else if (b.shape.equals("triangle")) { } else if (b.shape.equals("ellipse")) { noFill(); ellipse(width/2,height/2,400,150); } else if (b.shape.equals("puddle")) { // noFill(); stroke(d); for (int d=150; d>0; d-=10) { ellipse(x,height/2,d,d); } } else if (b.shape.equals("la")) { angle += 10; float val = cos(radians(angle)) * 19.0; for (int a = 0; a < 360; a += 45) { float xoff = cos(radians(a)) * val; float yoff = sin(radians(a)) * val; stroke(d); fill(d); ellipse(b.x + xoff, b.y + yoff, val/2, val/2); } fill(d); ellipse(b.x, b.y,5,5); } else if (b.shape.equals("la2")) { angle += 10; float val = cos(radians(angle)) * 19.0; for (int a = 0; a < 360; a += 45) { float xoff = cos(radians(a)) * val; float yoff = sin(radians(a)) * val; stroke(d); fill(d); ellipse(b.x + xoff, b.y + yoff, val/2, val/2); } fill(d); ellipse(b.x, b.y,5,5); } } void turnOff() { on = false; } void turnOn() { on = true; } }