Created
December 24, 2016 20:04
-
-
Save bgrayburn/6874fb9ef150313ef9546b1e01588e70 to your computer and use it in GitHub Desktop.
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
int max_rand_step = 5; | |
int frame_num = 0; | |
int shape_opacity = 20; | |
int num_of_rects = 40; | |
void setup(){ | |
size(displayWidth, displayHeight); | |
frameRate(40); | |
} | |
color cur_background = color(int(random(255)), int(random(255)), int(random(255))); | |
int getRandIncrNumber(int num, int max_rand_step){ | |
return int(num + (random(max_rand_step) - (max_rand_step / 2))); | |
}; | |
color getRandIncrColor(color base_color, int max_rand_step){ | |
return color( | |
getRandIncrNumber(int(red(base_color)), max_rand_step), | |
getRandIncrNumber(int(green(base_color)), max_rand_step), | |
getRandIncrNumber(int(blue(base_color)), max_rand_step) | |
); | |
}; | |
void draw(){ | |
pushMatrix(); | |
translate(width/2, height/2); | |
rectMode(CENTER); | |
ellipseMode(CENTER); | |
cur_background = getRandIncrColor(cur_background, max_rand_step); | |
background(cur_background); | |
stroke(random(255), random(255), random(255)); | |
int neg_red = 255-int(red(cur_background)); | |
int neg_green = 255-int(green(cur_background)); | |
int neg_blue = 255-int(blue(cur_background)); | |
fill(neg_red, neg_green, neg_blue, shape_opacity); | |
for (int i=0; i<num_of_rects; i++){ | |
rect(0, 0, random(width), random(height)); | |
} | |
println(frameRate); | |
popMatrix(); | |
} | |
void mouseDragged(){ | |
max_rand_step = int(map(mouseY, 0, height, 0, 255)); | |
shape_opacity = int(map(mouseX, 0, width, 0, 255)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment