xxxxxxxxxx
40
function setup() {
createCanvas(800, 800);
noSmooth()
pixelDensity(1)
buff = createGraphics(100,100)
buff.noSmooth()
pixelDensity(1)
}
function draw() {
background(220);
let C1 = {x: 50,y:50,r:20}
let C2 = {x: 68,y:68,r:10}
buff.loadPixels()
for(let x = 0; x < 100; x++){
for(let y = 0; y < 100; y++){
buff.set(x,y,color(255))
let d1 = dist(x,y,C1.x,C1.y) - C1.r
let d2 = dist(x,y,C2.x,C2.y) - C2.r
let d = min(d1,d2)
if(d < 0){
buff.set(x,y, color(255,0,0))
}
if(abs(d) < .5){
buff.set(x,y, color(0,0,0))
}
}
}
buff.updatePixels()
image(buff,0,0,800,800)
noLoop()
}