Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PImage img1;
int number=1;
int count = 9;
float inc = 1;
int rotation_counter = 0;
float circle_increment = 0;
Tentacle[] tentacles;
//MAIN METHODS------------------------------------------------------
void setup() {
size(1000, 1000, P2D);
imageMode(CENTER);
smooth();
noFill();
img1 = loadImage("foxy2.png");
img1.resize(width, height);
// fill(random(255),random(50, 100),random(255));
begin();
}
void draw() {
// background(186, 143, 149);
// background(130, 112, 129);
//background(211, 171, 158);
background(184,196,187);
inc -= 0.06; // SPEED
for (int i=0; i<count; i++) {
tentacles[i].drawTentacle();
}
image(img1, width/2, height/2);
// saveFrame("Fox " + number + ".png");
number++;
}
/*
void keyPressed() {
while (key == 's') {
println("Saving...");
save("Fox " + number + ".png");
number++;
}
println("Done saving.");
}
*/
//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); */
a[i] = 0.014;
b[i] = random(HALF_PI, PI+PI/2);
c[i] = 25;
}
tRotate = random(PI+(PI/5), (TWO_PI)-(PI/5));
float scale = cos(random(radians(50))+HALF_PI)+6; // last number here can change general length
tLength = height*0.1*scale; //and this one somehow too
stepSize = 1;
}
void drawTentacle() {
float x, y;
x = 0;
// rotation_counter = 1;
pushMatrix();
translate(width/2, height/2+250);
circle_increment = (((TWO_PI)-(PI/5))-(PI+(PI/5)))/9;
rotate((PI+(PI/5))-(circle_increment/2)+(circle_increment*rotation_counter)); // get rid of this if you want them pointing in one general direction
// rotate(tRotate);
rotation_counter++;
if (rotation_counter == 10){
rotation_counter = 1;
}
noStroke();
while (x<tLength) {
float r = map(x, 0, tLength, 200, 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, 1); //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;
if (r < 45){
fill(232, 215, 183);
} else {
fill(243, 236, 221);
}
ellipse(x, y, r, r);
stepSize = r/9; //circleness
x += stepSize;
}
popMatrix();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.