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
color red = 0xffff0000; | |
println(red); | |
println(hex(red)); |
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
size(512, 256); | |
loadPixels(); | |
int len = pixels.length; | |
float h = float(height); | |
float w = float(width); | |
float diamonds = TWO_PI * 8; | |
float red; | |
float green; |
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
PImage bkg; | |
color px; | |
float centerX; | |
float centerY; | |
float run; | |
float rise; | |
float distSq; | |
float invDist; |
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
size(512, 256, P2D); | |
color start = 0xff00ffff; | |
color stop = 0xffff00ff; | |
color clear = 0x00ffff00; | |
float count = 64; | |
float centerX = width * 0.5; | |
float centerY = height * 0.5; | |
float stopRad = max(centerX, centerY) - 2.5; |
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
class ColorStop implements Comparable<ColorStop> { | |
float percent; | |
color clr; | |
ColorStop(float prc, float v1, float v2, float v3) { | |
this(prc, color(v1, v2, v3)); | |
} | |
ColorStop(float prc, float v1, float v2, float v3, float al) { | |
this(prc, color(v1, v2, v3, al)); |
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
class Gradient { | |
ArrayList<ColorStop> colors = new ArrayList<ColorStop>(); | |
Gradient() { | |
} | |
Gradient(ColorStop... cs) { | |
for (int i = 0, sz = cs.length; i < sz; ++i) { | |
colors.add(cs[i]); | |
} |
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
boolean approximates(ColorStop c, float tolerance) { | |
return abs(percent - c.percent) < tolerance; | |
} |
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
void addColorStop(ColorStop cs) { | |
ColorStop other; | |
for (int i = 0, sz = colors.size(); i < sz; ++i) { | |
other = colors.get(i); | |
if (cs.approximates(other, Gradient.TOLERANCE)) { | |
println(cs, "percentage is too close to", other); | |
return; | |
} | |
} | |
colors.add(cs); |
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
Gradient(ColorStop... cs) { | |
int sz = cs.length; | |
for (int i = 0; i < sz; ++i) { | |
colors.add(cs[i]); | |
} | |
if (sz > 1) { | |
java.util.Collections.sort(colors); | |
removeDuplicates(); | |
} | |
} |
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
color evaluate(float percent) { | |
int sz = colors.size(); | |
if (sz == 0) { | |
return 0x00000000; | |
} | |
float diff; | |
float fraction; | |
ColorStop current; | |
ColorStop prev; |
OlderNewer