Skip to content

Commit

Permalink
Merge pull request #15 from renaudfv/master
Browse files Browse the repository at this point in the history
Two basic exemple for simple 2d and animated gradients
  • Loading branch information
micycle1 authored Jun 28, 2024
2 parents b666176 + 8f8cd55 commit e6dabc0
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/Animation/Animation.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/************************************************************
* PeasyGradients example
*
* Basic white to black gradient rendered to the main PApplet
*************************************************************/

// Necessary imports
import micycle.peasygradients.*;
import micycle.peasygradients.utilities.*;
import micycle.peasygradients.gradient.*;

// Gradient context to be bound to a renderer
PeasyGradients peasyGradients;
// Basic black to white Gradient
Gradient blackToWhite = new Gradient(color(0), color(255));


void setup() {
size(400, 400);

// Binding the gradient context to the current PApplet
peasyGradients = new PeasyGradients(this);

// Remove seam from start and end of gradient
blackToWhite.primeAnimation();
}

void draw() {
// Animate/ move the gradient
blackToWhite.animate(0.01f);
// Render gradient to context
peasyGradients.linearGradient(blackToWhite, 0); // angle = 0 (horizontal)
}
25 changes: 25 additions & 0 deletions examples/BasicBlackWhite/BasicBlackWhite.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/************************************************************
* PeasyGradients example
*
* Basic white to black gradient rendered to the main PApplet
*************************************************************/

// Necessary imports
import micycle.peasygradients.*;
import micycle.peasygradients.gradient.*;

// Gradient context to be bound to a renderer
PeasyGradients peasyGradients;
// Basic black to white Gradient
Gradient blackToWhite = new Gradient(color(0), color(255));

void setup() {
size(400, 400);

// Binding the gradient context to the current PApplet
peasyGradients = new PeasyGradients(this);
}

void draw() {
peasyGradients.linearGradient(blackToWhite, 0); // angle = 0 (horizontal)
}
33 changes: 33 additions & 0 deletions examples/Radial/Radial.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/************************************************************
* PeasyGradients example
*
* Basic white to black gradient rendered to the main PApplet
*************************************************************/

// Necessary imports
import micycle.peasygradients.*;
import micycle.peasygradients.utilities.*;
import micycle.peasygradients.gradient.*;

// Gradient context to be bound to a renderer
PeasyGradients peasyGradients;
// Basic black to white Gradient
Gradient blackToWhite = new Gradient(color(0), color(255));


void setup() {
size(400, 400);

// Binding the gradient context to the current PApplet
peasyGradients = new PeasyGradients(this);

// Remove seam from start and end of gradient
blackToWhite.primeAnimation();
}

void draw() {
// Animate/ move the gradient
blackToWhite.animate(-0.01f);
// Render gradient to context
peasyGradients.radialGradient(blackToWhite, new PVector(mouseX, mouseY), 1); // angle = 0 (horizontal)
}

0 comments on commit e6dabc0

Please sign in to comment.