Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float t = 0;
- float radius;
- int count;
- int levels = 7;
- PVector center;
- void setup() {
- size(1080, 1080);
- result = new int[width*height][3];
- PFont font = createFont("Nunito-Regular.ttf", 30);
- textFont(font);
- center = new PVector(width/2+radius/pow(2, levels), height/2);
- }
- void draw() {
- background(#76E9FF);
- count = 0;
- t = map(frameCount, 1, 1440, 0, 1);
- radius = map(cos(TAU*t)/2+0.5, 0, 1, 1000, 10000);
- push();
- translate(width/2, height/2);
- rotate(TAU*t*2);
- guide(radius, levels);
- pop();
- push();
- translate(width-center.x, height-center.y);
- rotate(TAU*t*2);
- yinYang(radius, levels);
- pop();
- noStroke();
- fill(0, 150);
- rect(width-290, height-40, 290, 40, 20);
- fill(240);
- strokeWeight(1);
- text("@URBANOXYGEN_", width-285, height-10);
- }
- void yinYang(float radius, int n) {
- noStroke();
- fill(0);
- arc(0, 0, radius, radius, 0, PI);
- fill(255);
- arc(0, 0, radius, radius, PI, TAU);
- if(n==1) {
- fill(0);
- ellipse(-radius/4, 0, radius/2, radius/2);
- fill(255);
- ellipse(radius/4, 0, radius/2, radius/2);
- ellipse(-radius/4, 0, radius/4, radius/4);
- fill(0);
- ellipse(radius/4, 0, radius/4, radius/4);
- } else {
- push();
- translate(radius/4, 0);
- rotate(TAU*t*2);
- yinYang(radius/2, n-1);
- pop();
- push();
- translate(-radius/4, 0);
- rotate(TAU*t*2);
- yinYang(radius/2, n-1);
- pop();
- }
- }
- void guide(float radius, int n) {
- count++;
- if (n==1) {
- if (count==pow(2, levels-1)) {
- center.set(screenX(0, 0), screenY(0, 0));
- }
- } else {
- push();
- translate(radius/4, 0);
- rotate(TAU*t*2);
- guide(radius/2, n-1);
- pop();
- push();
- translate(-radius/4, 0);
- rotate(TAU*t*2);
- guide(radius/2, n-1);
- pop();
- }
- }
Add Comment
Please, Sign In to add comment