From 28b22b8def48a908165f7a9e0e0beb759ffeba0f Mon Sep 17 00:00:00 2001 From: Renaud Vincent <5589331+renaudfv@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:11:03 -0400 Subject: [PATCH 1/2] Two basic exemple for simple 2d and animated gradients --- examples/Animation/Animation.pde | 33 ++++++++++++++++++++ examples/BasicBlackWhite/BasicBlackWhite.pde | 25 +++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 examples/Animation/Animation.pde create mode 100644 examples/BasicBlackWhite/BasicBlackWhite.pde diff --git a/examples/Animation/Animation.pde b/examples/Animation/Animation.pde new file mode 100644 index 0000000..5216b45 --- /dev/null +++ b/examples/Animation/Animation.pde @@ -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) +} diff --git a/examples/BasicBlackWhite/BasicBlackWhite.pde b/examples/BasicBlackWhite/BasicBlackWhite.pde new file mode 100644 index 0000000..4a5ce58 --- /dev/null +++ b/examples/BasicBlackWhite/BasicBlackWhite.pde @@ -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) +} From 8f8cd55464a460a27bb108fbad2866a73ea6cc49 Mon Sep 17 00:00:00 2001 From: Renaud Vincent <5589331+renaudfv@users.noreply.github.com> Date: Thu, 27 Jun 2024 14:57:35 -0400 Subject: [PATCH 2/2] Raidial example --- examples/Radial/Radial.pde | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/Radial/Radial.pde diff --git a/examples/Radial/Radial.pde b/examples/Radial/Radial.pde new file mode 100644 index 0000000..78231ff --- /dev/null +++ b/examples/Radial/Radial.pde @@ -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) +}