Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float size = 900;
- float[] chance1 = new float[100];
- float[] chance2 = new float[100];
- float threeshold = 0.75;
- void setup() {
- size(900, 900, P2D);
- fillChance();
- noStroke();
- }
- void draw() {
- threeshold = (float)mouseY/(float)size;
- fill(0);
- square(0, 0, size, 1);
- square(0+size/2, 0+size/2, size, 2);
- fill(255);
- square(0, 0+size/2, size, 3);
- square(0+size/2, 0, size, 4);
- }
- void square(float x, float y, float s, int g) {
- rect(x, y, s/2, s/2);
- if (s > 10) {
- int gen = g + 1;
- fill(0);
- if (chance(g) < threeshold) {
- square(x, y, s/2, gen);
- }
- if (chance(10+g) < threeshold) {
- square(x+s/4, y+s/4, s/2, gen);
- }
- fill(255);
- if (chance(20+g) < threeshold) {
- square(x+s/4, y, s/2, gen);
- }
- if (chance(30+g) < threeshold) {
- square(x, y+s/4, s/2, gen);
- }
- }
- }
- void mouseReleased() {
- draw();
- fillChance();
- }
- void keyReleased() {
- saveFrame(hour() + ":" + minute() + ":" + second() + "*" + "ss.png");
- }
- void fillChance(){
- for (int i = 0; i < 100; i++) {
- chance1[i] = random(1);
- chance2[i] = random(1);
- }
- }
- float chance(int i) {
- float norm = (float)mouseX/(float)size;
- float anorm = 1 - norm;
- return (chance1[i]*norm)+chance2[i]*anorm;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement