Drawing points on a circle

Hi, a bit of a silly question but I am rusty.

I have a program that is drawing points around a circle but I want them to draw all at once (without removing the background) – what am I forgetting?

let pts = 35;
let a = 0;
let inc, r;

function setup() {
	createCanvas(windowWidth, windowHeight);
	background(100);
	inc = TWO_PI/pts;
	r = 200;
}

function draw() {
	background(100);
	push();
	translate(width/2, height/2);
		for (let x = 0; x < pts; x++) {
			for (let y = 0; y < pts; y++) {
				let x2 = cos(a) * r;
				let y2 = sin(a) * r;
				ellipse(x2, y2, 5 , 5)
			}
		}
	pop();
	a = a + inc;
}

Replace this with a for loop over a, the angle

ah yes, thank you Chrisir (I remember you helped me a few times on Processing 2 forum, nice to see you again!)

Here is the updated solution:

push();
translate(width/2, height/2);
	for (a = 0; a < TWO_PI; a = a + inc) {
		let x = cos(a) * r;
		let y = sin(a) * r;
		ellipse (x, y, 5, 5);
	}
pop();
1 Like