xxxxxxxxxx
58
function setup() {
createCanvas(400, 400);
rectMode(RADIUS)
half = width/2
}
function squareCircle(radius) {
sqWidth = sqrt(sq(radius)/2);
return sqWidth;
}
function draw() {
background(0);
//red circle
fill(255,0,0)
redCirc = width;
circle(half,half,redCirc)
//green square
fill(0,255,0)
greenSqu = squareCircle(redCirc/2);
rect(half,half,greenSqu,greenSqu)
//blue circle
fill(0,0,255)
blueCirc = squareCircle(redCirc)
circle(half,half,blueCirc)
//yellow square
fill(255,255,0)
yellowSqu = squareCircle(blueCirc/2)
rect(half,half,yellowSqu)
//cyan circle
fill(0,255,255)
cyanCirc = squareCircle(blueCirc)
circle(half,half,cyanCirc)
//magenta square
fill(255,0,255)
magentaSqu = squareCircle(cyanCirc/2)
rect(half,half,magentaSqu)
//white circle
fill(255,255,255)
whiteCirc = squareCircle(cyanCirc)
circle(half,half,whiteCirc)
//grey square
fill(128,128,128)
greySqu = squareCircle(whiteCirc/2)
rect(half,half,greySqu)
//black circle
fill(0,0,0)
blackSqu = squareCircle(whiteCirc)
circle(half,half,blackSqu)
}