xxxxxxxxxx
let capture
let off = -1
function setup() {
createCanvas(600, 600)
capture = createCapture(VIDEO)
capture.hide()
background(255)
textAlign(CENTER, CENTER)
textSize(30)
text('Click to start scanning', width/2, height/2)
}
function mouseClicked() {
off = frameCount
background(255)
}
function draw() {
if (off > 0 && frameCount > off) {
push()
const r = (frameCount - off - 2) * 0.5
const r2 = (frameCount - off) * 0.5
clip(() => {
beginShape()
for (let i = 0; i <= 50; i++) {
let a = map(i, 0, 50, 0, TWO_PI)
vertex(width/2 + r * cos(a), height/2 + r * sin(a))
}
for (let i = 0; i <= 50; i++) {
let a = map(i, 0, 50, TWO_PI, 0)
vertex(width/2 + r2 * cos(a), height/2 + r2 * sin(a))
}
endShape()
})
translate(width/2, height/2)
scale(-1, 1)
imageMode(CENTER)
image(capture, 0, 0, width, height, 0, 0, capture.width, capture.height, COVER)
pop()
}
}