Skip to content

Instantly share code, notes, and snippets.

@behreajj
behreajj / clrGrad_2_12.pde
Created June 25, 2017 17:45
Color Gradients 2-12
/* If mode is HSB, this will take the shortest path around the
* color wheel to find the new color. For instance, red to blue
* will go red violet blue (backwards in hue space) rather than
* cycling through ROYGBIV.
*/
// Disabling rollover (wasn't working anyway) for 0126.
// Otherwise it makes full spectrum scale impossible for
// those who might want it…in spite of how despicable
// a full spectrum scale might be.
@behreajj
behreajj / clrGrad_2_13.pde
Created June 25, 2017 17:45
Color Gradients 2-13
float smootherStep(float origin, float dest, float step) {
return map(step * step * step * (step * (step * 6 - 15) + 10),
0, 1, origin, dest);
}
@behreajj
behreajj / clrGrad_2_14.pde
Created June 25, 2017 17:59
Color Gradients 2-14
color smootherStepColor(color c1, color c2, float step) {
// Constrain step.
step = step < 0 ? 0 : step > 1 ? 1 : step;
// Define a default color.
color result = 0x00000000;
if (g.colorMode == RGB) {
@behreajj
behreajj / clrGrad_2_15.pde
Created June 25, 2017 18:01
Color Gradients 2-15
if (eval == EvalMethod.SmootherStep) {
return smootherStepColor(current.clr, prev.clr, fraction);
} else {
return lerpColor(current.clr, prev.clr, fraction);
}
@behreajj
behreajj / clrGrad_2_16.pde
Last active June 25, 2017 18:10
Color Gradients 2-16
int count = 6;
float swatchW;
float fWidth;
float h1;
float h2;
float step;
String clrMdLabel;
@behreajj
behreajj / clrGrad_3_1.pde
Created June 25, 2017 18:52
Color Gradients 3-1
int paletteCount = 6;
int rows = 6;
int cols = 6;
float tileH;
float tileW;
float swatchW = 64;
float consistency = 0.75;
float step;
@behreajj
behreajj / clrGrad_3_2.pde
Last active June 25, 2017 19:01
Color Gradients 3-2
void blendRadGrad(PImage pg, Gradient gradient, float blend,
int cx, int cy, float sclr) {
color clr;
int run;
int rise;
int dist;
int w = pg.width;
int h = pg.height;
@behreajj
behreajj / clrGrad_3_3.pde
Created June 25, 2017 18:58
Color Gradients 3-3
float project(float originx, float originy,
float destx, float desty,
int pointx, int pointy) {
// Rise and run of line.
float lnRise = desty - originy;
float lnRun = destx - originx;
// Distance-squared of line.
float lnDistSq = lnRun * lnRun + lnRise * lnRise;
@behreajj
behreajj / clrGrad_3_4.pde
Created June 25, 2017 19:03
Color Gradients 3-4
void blendLinGrad(PImage pg, Gradient gradient, float blend,
int orx, int ory, int dex, int dey) {
color clr;
int w = pg.width;
int h = pg.height;
pg.loadPixels();
for (int y = 0, x, i = 0; y < h; ++y) {
@behreajj
behreajj / clrGrad_3_5.xml
Last active June 25, 2017 19:36
Color Gradients 3-5
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Fan" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve" transform="translate(-256, -256)">
<path id="st0" class="st0" fill="#ff8080" d="M420.8,283.4c-14.2,8.3-29.2,15.8-44.9,22.3c-46.8,19.4-100.5-2.8-119.9-49.7
c0,50.7,41.1,91.8,91.8,91.8c58.6,0,113.9-13.7,163.1-38.1C479.6,308.8,448.5,300.1,420.8,283.4z"/>
</svg>