Translate Processing sketch into P5 issue

I gave an example to try:
https://discourse.processing.org/t/get-the-vertical-axis-of-objects-array/23319/3

Here is another one (move the mouse to center it):

Code
float theta = 0;

void setup() 
  {
  size(300, 300);
  }

void draw() 
  {
  background(0);
  translate(width/2, height/2);
  
  noFill();
  circle(0, 0, 100);

  theta += TAU/360;
  
  int num = int(map(mouseX, 0, width, -200, 100)); //This comes in very handy!
  textSize(24);
  text(num, 70, 0);

  rotate(theta);
  translate(num, 0);  //This will translate it to center
  
  stroke(255, 255, 0);
  strokeWeight(2);
  line(0, 0, 100, 0);  
  }

Take a look at the tutorials:
2D Transformations / Processing.org After that 3D.

And the other resources at the Processing site.

:)

image

2 Likes