Skip to content

Instantly share code, notes, and snippets.

@srdjan-m
Created February 16, 2018 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srdjan-m/48e8aa575589e9916e06c4d0574e0b20 to your computer and use it in GitHub Desktop.
Save srdjan-m/48e8aa575589e9916e06c4d0574e0b20 to your computer and use it in GitHub Desktop.
Bezier line animation in Processing
float x1, y1;
float x2, y2;
float x3, y3;
float x4, y4;
int frame = 0;
PImage title;
float a = 0;
void setup() {
size(500, 500);
smooth();
ellipseMode(CENTER);
title = loadImage("title.png");
x1 = 250;
y1 = 25;
x2 = 380; // CP 1
y2 = 25; //250;
x3 = 25; // CP 2
y3 = 380; //250;
x4 = 250;
y4 = 380;
background(0);
strokeWeight(3);
}
void draw() {
noStroke();
fill(0, 10);
rect(0, 0, width, height);
imageMode(CENTER);
image(title, width * 0.5, 450);
fill(255, 50);
x2 = 250 + (sin(radians(a)) * 355);
x3 = 250 - (cos(radians(a)) * 355);
noFill();
stroke(255, 155 + sin(radians(a * 2)) * 100, 155 + cos(radians(a * 2)) * 100);
bezier(x1, y1, x2, y2, x3, y3, x4, y4);
x2 = 250 - (sin(radians(a)) * 355);
x3 = 250 + (cos(radians(a)) * 355);
stroke(255, 155 + sin(radians(a * 2)) * 100, 155 + cos(radians(a * 2)) * 100);
bezier(x1, y1, x2, y2, x3, y3, x4, y4);
a += 3;
if(frame > 59 && frame < 160){
saveFrame("welcome###.png");
}
frame ++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment