Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. float size = 900;
  2.  
  3. float[] chance1 = new float[100];
  4. float[] chance2 = new float[100];
  5.  
  6. float threeshold = 0.75;
  7.  
  8. void setup() {
  9.   size(900, 900, P2D);
  10.  
  11.   fillChance();
  12.  
  13.   noStroke();
  14. }
  15.  
  16. void draw() {
  17.  
  18.   threeshold = (float)mouseY/(float)size;
  19.  
  20.   fill(0);
  21.   square(0, 0, size, 1);
  22.   square(0+size/2, 0+size/2, size, 2);
  23.   fill(255);
  24.   square(0, 0+size/2, size, 3);
  25.   square(0+size/2, 0, size, 4);
  26. }
  27.  
  28. void square(float x, float y, float s, int g) {
  29.   rect(x, y, s/2, s/2);
  30.   if (s > 10) {
  31.     int gen = g + 1;
  32.     fill(0);
  33.     if (chance(g) < threeshold) {
  34.       square(x, y, s/2, gen);
  35.     }
  36.     if (chance(10+g) < threeshold) {
  37.       square(x+s/4, y+s/4, s/2, gen);
  38.     }
  39.     fill(255);
  40.     if (chance(20+g) < threeshold) {
  41.       square(x+s/4, y, s/2, gen);
  42.     }            
  43.     if (chance(30+g) < threeshold) {
  44.       square(x, y+s/4, s/2, gen);
  45.     }
  46.   }
  47. }
  48.  
  49. void mouseReleased() {
  50.   draw();
  51.  
  52.   fillChance();
  53. }
  54.  
  55. void keyReleased() {
  56.  saveFrame(hour() + ":" + minute() + ":" + second() + "*" + "ss.png");
  57. }
  58.  
  59. void fillChance(){
  60.   for (int i = 0; i < 100; i++) {
  61.     chance1[i] = random(1);
  62.     chance2[i] = random(1);
  63.   }
  64. }
  65.  
  66. float chance(int i) {
  67.   float norm = (float)mouseX/(float)size;
  68.   float anorm = 1 - norm;
  69.  
  70.   return (chance1[i]*norm)+chance2[i]*anorm;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement