Skip to content

Instantly share code, notes, and snippets.

@behreajj
Created June 25, 2017 17:39
Show Gist options
  • Save behreajj/80b708e9df8b837226a76697a438d1e6 to your computer and use it in GitHub Desktop.
Save behreajj/80b708e9df8b837226a76697a438d1e6 to your computer and use it in GitHub Desktop.
Color Gradients 2-10
size(600, 200);
rectMode(CORNERS);
ellipseMode(RADIUS);
noStroke();
int[] blendModes = { BLEND, ADD, SUBTRACT };
// Red, Green, Blue, Cyan, Magenta, Yellow
color[] palette = { 0x55ff0000, 0x5500ff00,
0x550000ff, 0x5500ffff, 0x55ff00ff,
0x55ffff00 };
float rectWidth = width * 0.334;
float centerX;
float centerY = height * 0.5;
float angle;
float radius = min(width, height) * 0.2675;
float dist = rectWidth * 0.5 - radius;
// Blend background
fill(0xffd6d6d6);
rect(0, 0, rectWidth, height);
// Add background.
fill(0xff000000);
rect(rectWidth, 0, rectWidth * 2, height);
// Subtract background.
fill(0xffffffff);
rect(rectWidth * 2, 0, width, height);
// Three modes, six overlapping circles.
for (int i = 0; i < 3; ++i) {
centerX = rectWidth * 0.5 + width * i * 0.334;
blendMode(blendModes[i]);
for (int j = 0; j < 6; ++j) {
angle = j * 0.1667 * TWO_PI;
fill(palette[j]);
ellipse(centerX + cos(angle) * dist,
centerY + sin(angle) * dist,
radius, radius);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment