Pac-Man Waka Waka Arcs

Waka Waka

/*
 Project:   Waka Waka
 Author:    GLV
 Date:      2024-11-24
 Version:   1.0.0
*/

void setup()
  {
  size(350, 350);
  noStroke();
  fill(0, 255, 0);
  }
  
float a1;    

void draw()
  {
  background(0);  
  translate(width/2, height/2);
  
  float div = 45;
  float a0 = (frameCount%div)*(TAU/div);
  
  float col = 127.5 + 127.5*sin(a0); // color
  a1 = map(mouseX, -width/2, width/2, -TAU/2, TAU/2); 
  println((int) col, nfs(degrees(a1), 3, 2));
  
 push();
  rotate(a1);
  fill(col);
  textSize(24);
  textAlign(CENTER, CENTER);
  text("WAKA", 100, 0);  
 pop();

  float a3 = TAU/16;
  float mod = a3*sin(a0);
  
  float start = a1 + a3     + mod;
  float stop  = a1 + TAU-a3 - mod;  //TAU = 2*PI radians or 360 degrees
  
  fill(0, 255, 0);
  arc(0, 0, 200, 200, start, stop);
  }

Inspired by a topic:
https://discourse.processing.org/t/rotate-arc-in-pacman-animation/45367/23

:)

1 Like