Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup(){
- size(600, 600, P3D);
- noLoop();
- smooth(8);
- ortho();
- colorMode(HSB, 100);
- }
- float N = 12;
- void draw(){
- background(0, 5, 97);
- translate(width/2, height/2);
- // rotateY(2*PI*mouseX/width);
- ring(220, 81);
- scale(1, -1);
- ring(110, 41);
- scale(1, -1);
- ring(53, 21);
- }
- void ring(float R, float r){
- for(float alfa = 0; alfa < TWO_PI; alfa += TWO_PI/N){
- float x = R * cos(alfa);
- float y = R * sin(alfa);
- pushMatrix();
- rotate(alfa);
- translate(R, 0);
- rotateX(radians(-10));
- rotateZ(-PI/2);
- float hue = map(alfa, 0, TWO_PI, 100, 0);
- shape(r, hue, alfa);
- popMatrix();
- }
- }
- void shape(float r, float hue, float alfa){
- // coloured sides
- noStroke();
- for(float al = 0; al < TWO_PI; al += TWO_PI/3){
- fill((hue+90)%100, 68, map(al, 0, TWO_PI, 45, 100));
- beginShape();
- vertex(r * cos(al), r * sin(al));
- vertex(r * cos(al + TWO_PI/6), r * sin(al + TWO_PI/6));
- vertex(r * cos(al + 2*TWO_PI/6), r * sin(al + 2*TWO_PI/6));
- vertex(0, 0);
- endShape();
- // noisy fill
- noStroke();
- for(int k = 0; k < r/81*17000; k++){
- float u = random(1);
- float v = random(1);
- float px = r * cos(al) + u * (r * cos(al + TWO_PI/6) - r * cos(al)) + v * (0 - r * cos(al));
- float py = r * sin(al) + u * (r * sin(al + TWO_PI/6) - r * sin(al)) + v * (0 - r * sin(al));
- 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));
- ellipse(px, py, 1.2, 1.2);
- }
- }
- // strokes
- stroke(11);
- for(float al = 0; al < TWO_PI; al += TWO_PI/6)
- line(r * cos(al), r * sin(al), r * cos(al + TWO_PI/6), r * sin(al + TWO_PI/6));
- for(float al = 0; al < TWO_PI; al += TWO_PI/3)
- line(0, 0, r * cos(al), r * sin(al));
- }
- float power(float p, float g) {
- if (p < 0.5)
- return 0.5 * pow(2*p, g);
- else
- return 1 - 0.5 * pow(2*(1 - p), g);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement