Created
February 19, 2014 04:32
-
-
Save MichaelPaulukonis/9086104 to your computer and use it in GitHub Desktop.
dime-story vasarely (processing sketch)
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
// Inspired by Victor Vasarely*, I created a mechanistic color grid with inset squares or rectangles. | |
// The color palette was primarily built using a Complementary set of reds and greens, | |
// with a hand-picked blue and yellow for added vibrancy. | |
// The algorithm prohibits the horizontal repetition of a background color, | |
// and will not alow an inset-shape to be the same color as the background. | |
// * particularly by http://4.bp.blogspot.com/-JvA1kOVrVoQ/TbtLGxQ7fxI/AAAAAAAAAZU/n8wyXMlmDus/s1600/colour_vasarely5.jpg | |
// found, charmingly enough, at http://mrswagnersartideas.blogspot.com/2011/04/victor-vasarely.html | |
// two early palettes. | |
//color[] palette = {#FFAEAC, #DB91E8, #B6ACFF, #91C4E8, #9FFFE1}; // pastels | |
//color[] palette = {#B2004a, #FF1979, #FF0061, #00B209, #0EFF19}; // red-green pop | |
color[] palette = {#B2004a, #FF1979, #FF0061, #00B209, #0EFF19, #1E25FF, #FFF913 }; // red-green pop + blue + yellow | |
int width = 864; | |
int height = 720; | |
int blockSize = 72; | |
int circleOffset = blockSize / 2; | |
int innerBlockOffset = 10; | |
int innerCircleSize = blockSize - 10; | |
int innerBlockSize = blockSize - 20; | |
void setup() { | |
size(width, height); | |
background(#FFFFFF); | |
noLoop(); | |
noStroke(); | |
} | |
void draw() { | |
int blockColor = -1; | |
int eColor = -1; | |
int eOffset = blockSize/2; | |
for (int y = 0; y < height; y += blockSize) { | |
for (int x = 0; x < width; x += blockSize) { | |
blockColor = getNewIndex(blockColor); | |
fill(palette[blockColor]); | |
rect(x, y, blockSize, blockSize); | |
eColor = getNewIndex(blockColor); // ellipse can't be same color as block | |
// but we _can_ repeat ellipse colors from block to block | |
fill(palette[eColor]); | |
if (random(1) < 0.5) { | |
ellipse(x + circleOffset, y + circleOffset, innerCircleSize, innerCircleSize); | |
} else { | |
rect(x + innerBlockOffset, y + innerBlockOffset, innerBlockSize, innerBlockSize); | |
} | |
} | |
} | |
} | |
// don't repeat a color | |
// this is linear, and doesn't calculate for a grid. hoo-hah! | |
int getNewIndex(int prev) { | |
int r = prev; | |
while (r == prev) { | |
r = int(random(0, palette.length)); | |
} | |
//println("prev: " + prev + " next: " + r); | |
return r; | |
} | |
// kinda dull, not going to use | |
// leaving in code for future reference | |
color inverseColor(color c) { | |
return (color)#000000 - c; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment