Last active
December 11, 2018 11:22
-
-
Save wonderburg7/c02dbabcec250c6e8484dec412ae09b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//changed from https://www.openprocessing.org/sketch/126679 | |
int sizeX = 500; | |
int sizeY = 500; | |
int number=1; | |
int count = 15; | |
float inc = 1; | |
Tentacle[] tentacles; | |
//MAIN METHODS------------------------------------------------------ | |
void setup(){ | |
size(1000,1000,P2D); | |
smooth(); | |
noFill(); | |
// fill(random(255),random(50, 100),random(255)); | |
fill(255); | |
begin(); | |
} | |
void draw(){ | |
background(0, 0); | |
inc -= 0.1; | |
for(int i=0;i<count;i++){ | |
tentacles[i].drawTentacle(); | |
} | |
} | |
void keyPressed(){ | |
if(key == 's'){ | |
println("Saving..."); | |
save("tentacle" + number + ".png"); | |
println("Done saving."); | |
number++; | |
} | |
} | |
//METHODS------------------------------------------------------------ | |
void begin(){ | |
tentacles = new Tentacle[count]; | |
for(int i=0;i<count;i++){ | |
tentacles[i] = new Tentacle(); | |
} | |
} | |
void mousePressed(){ | |
if(mouseButton==RIGHT){ | |
begin(); | |
} | |
} | |
//OBJECTS------------------------------------------------------------ | |
class Tentacle{ | |
float[] a = new float[3]; | |
float[] b = new float[3]; | |
float[] c = new float[3]; | |
float tLength; | |
float stepSize; | |
float tRotate; | |
int alpha; | |
Tentacle(){ | |
for(int i=0;i<3;i++){ | |
a[i] = random(0.005,0.03); | |
b[i] = random(0,TWO_PI); | |
c[i] = random(2,50); | |
} | |
tRotate = random(radians(360)); | |
// tRotate = random(250,400); | |
float scale = cos(random(radians(360))+HALF_PI)+2; // last number here can change general length | |
tLength = height*random(0.1,0.1)*scale; //and this one somehow too | |
stepSize = 5; | |
// alpha = int(random(30,100));// used for stroke weight | |
} | |
void drawTentacle(){ | |
float x,y; | |
x = 0; | |
pushMatrix(); | |
translate(width/2,height/2); | |
rotate(tRotate); // get rid of this if you want them pointing in one general direction | |
// rotate(-PI/2); //this one points it upwards | |
// stroke(100,alpha); | |
noStroke(); | |
while(x<tLength){ | |
float r = map(x,0,tLength,20,1); //second to last number - makes base of tentacles thicker, changing the last number here makes tentacles less pointy | |
float A = map(x,0,tLength,0,2); //changing the last number here makes tentacles much floppier but might become just circles | |
y = (sin(a[0]*x+b[0]+inc)*c[0] + sin(a[1]*x+b[1]+inc)*c[1] + sin(a[2]*x+b[2]+inc)*c[2]); //adding to this makes them longer and straighter and more circley | |
y = y*A; | |
ellipse(x,y,r,r); | |
// if(r>15) | |
stepSize = r/5; //circleness | |
x += stepSize; | |
} | |
// tRotate = tRotate+0.005; | |
popMatrix(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment