-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from renaudfv/master
Two basic exemple for simple 2d and animated gradients
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
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
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) | ||
} |
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
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) | ||
} |
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
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) | ||
} |