Advertisement
Guest User

Untitled

a guest
Oct 14th, 2015
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.54 KB | None | 0 0
  1. void setup(){
  2.         size(600, 600, P3D);
  3.         noLoop();
  4.         smooth(8);
  5.  
  6.         ortho();
  7.         colorMode(HSB, 100);
  8. }
  9.  
  10. float N = 12;
  11.  
  12. void draw(){
  13.         background(0, 5, 97);
  14.  
  15.         translate(width/2, height/2);
  16.         // rotateY(2*PI*mouseX/width);
  17.  
  18.         ring(220, 81);
  19.         scale(1, -1);
  20.         ring(110, 41);
  21.         scale(1, -1);
  22.         ring(53, 21);
  23. }
  24.  
  25. void ring(float R, float r){
  26.         for(float alfa = 0; alfa < TWO_PI; alfa += TWO_PI/N){
  27.  
  28.                 float x = R * cos(alfa);
  29.                 float y = R * sin(alfa);
  30.  
  31.                 pushMatrix();
  32.                 rotate(alfa);
  33.                 translate(R, 0);
  34.  
  35.                 rotateX(radians(-10));
  36.                 rotateZ(-PI/2);
  37.  
  38.                 float hue = map(alfa, 0, TWO_PI, 100, 0);
  39.                 shape(r, hue, alfa);
  40.  
  41.                 popMatrix();
  42.  
  43.         }
  44. }
  45.  
  46. void shape(float r, float hue, float alfa){
  47.  
  48.         // coloured sides
  49.         noStroke();
  50.         for(float al = 0; al < TWO_PI; al += TWO_PI/3){
  51.                 fill((hue+90)%100, 68, map(al, 0, TWO_PI, 45, 100));
  52.                 beginShape();
  53.                 vertex(r * cos(al), r * sin(al));
  54.                 vertex(r * cos(al + TWO_PI/6), r * sin(al + TWO_PI/6));
  55.                 vertex(r * cos(al + 2*TWO_PI/6), r * sin(al + 2*TWO_PI/6));
  56.                 vertex(0, 0);
  57.                 endShape();
  58.  
  59.                 // noisy fill
  60.                 noStroke();
  61.                 for(int k = 0; k < r/81*17000; k++){
  62.                         float u = random(1);
  63.                         float v = random(1);
  64.                         float px = r * cos(al) + u * (r * cos(al + TWO_PI/6) - r * cos(al)) + v * (0 - r * cos(al));
  65.                         float py = r * sin(al) + u * (r * sin(al + TWO_PI/6) - r * sin(al)) + v * (0 - r * sin(al));
  66.                         fill((hue+90)%100, 68, map(al, 0, TWO_PI, 45, 100) + 7*power(noise(px*0.03*220/r, py*0.03*220/r, alfa+al), 5) + random(-6, 6));
  67.                         ellipse(px, py, 1.2, 1.2);
  68.                 }
  69.         }
  70.  
  71.         // strokes
  72.         stroke(11);
  73.         for(float al = 0; al < TWO_PI; al += TWO_PI/6)
  74.                 line(r * cos(al), r * sin(al), r * cos(al + TWO_PI/6), r * sin(al + TWO_PI/6));
  75.  
  76.         for(float al = 0; al < TWO_PI; al += TWO_PI/3)
  77.                 line(0, 0, r * cos(al), r * sin(al));
  78. }
  79.  
  80.  
  81. float power(float p, float g) {
  82.         if (p < 0.5)
  83.                 return 0.5 * pow(2*p, g);
  84.         else
  85.                 return 1 - 0.5 * pow(2*(1 - p), g);
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement