I threw something together in p5, and it works as intended. Then I tried to translate it to (Java) Processing, and although it runs, the results are weird. I’ve checked everything I can think of, and I’m not sure what the problem is.
Here is the p5 code, followed by a sample screenshot of the expected results:
new p5();
let gap = 16.0; // gap between consecutive circles
let numCircles = 60; // number of circles
let diamInner = 10.0; // diameter of inner circle
let roam = 60.0; // angle to roam from previous rando
let color1 = color(200, 0, 0);
function setup() {
	createCanvas(1000, 600);
	background(30);
	
	noLoop();
}
function draw() {
	let arrRands = new Array(numCircles + 1);
	
	for (let i = 0; i < arrRands.length; i++) {
		arrRands[i] = random(360);
		if (i > 1) {
			arrRands[i] = random(arrRands[i - 2] - roam, arrRands[i - 2] + roam);
		}
	}
	
	stroke(color1);
	strokeWeight(2);
	noFill();
	
	for (let i = 0; i < numCircles; i++) {
		let diamTemp = diamInner + (i * gap * 2.0);
		push();
		
		translate(width / 2.0, height / 2.0);
		
		let x = cos(radians(arrRands[i + 1])) * ((diamTemp / 2.0) + (gap / 2.0));
		let y = sin(radians(arrRands[i + 1])) * ((diamTemp / 2.0) + (gap / 2.0));
		
		if (i % 2 != 0) { // if i is odd
			arc(0, 0, diamTemp, diamTemp, 
					radians(arrRands[i]), radians(arrRands[i + 1]) );
			
			arc(x, y, gap, gap, radians(arrRands[i + 1]), radians(arrRands[i + 1] + 180));
			
		} else { // else if i is even
			arc(0, 0, diamTemp, diamTemp, 
					radians(arrRands[i + 1]), radians(arrRands[i]) );
			
			arc(x, y, gap, gap, radians(arrRands[i + 1] + 180), radians(arrRands[i + 1]));
		}
		
		pop();
	}
}
And here is the Processing translation of the above, followed by sample screenshots of some of the unexpected results. I basically copied my p5 code, pasted it into the Processing IDE, changed the syntax over to Java, and … it outputs nonsense.
float gap = 16.0; // gap between consecutive circles
int numCircles = 60; // number of circles
float diamInner = 10.0; // diameter of inner circle
float roam = 50.0; // angle to roam from previous rando
color color1 = color(200, 0, 0);
void setup() {
    size(1000, 600);
    background(30);
    
    noLoop();
}
void draw() {
    float[] arrRands = new float[numCircles + 1];
    
    for (int i = 0; i < arrRands.length; i++) {
        arrRands[i] = random(360);
        if (i > 1) {
            arrRands[i] = random(arrRands[i - 2] - roam, arrRands[i - 2] + roam);
        }
    }
    
    stroke(color1);
    strokeWeight(2);
    noFill();
    
    for (int i = 0; i < numCircles; i++) {
        float diamTemp = diamInner + (i * gap * 2.0);
        
        push();
        
        translate(width / 2.0, height / 2.0);
        
        float x = cos(radians(arrRands[i + 1])) * ((diamTemp / 2.0) + (gap / 2.0));
        float y = sin(radians(arrRands[i + 1])) * ((diamTemp / 2.0) + (gap / 2.0));
        
        if (i % 2 != 0) { // if i is odd
            arc(0, 0, diamTemp, diamTemp, 
                    radians(arrRands[i]), radians(arrRands[i + 1]) );
            
            arc(x, y, gap, gap, radians(arrRands[i + 1]), radians(arrRands[i + 1] + 180));
            
        } else { // else if i is even
            arc(0, 0, diamTemp, diamTemp, 
                    radians(arrRands[i + 1]), radians(arrRands[i]) );
            
            arc(x, y, gap, gap, radians(arrRands[i + 1] + 180), radians(arrRands[i + 1]));
        }
        pop();
    }
}




