-
Notifications
You must be signed in to change notification settings - Fork 7
/
P5L_p5.glitch-webcam.json
17 lines (17 loc) · 1.04 KB
/
P5L_p5.glitch-webcam.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"version": "1.3.2",
"revision": 36,
"count": {
"sketches": 1,
"folders": 0
},
"structure": [
{
"name": "p5.glitch-webcam",
"mod": "1589926491138",
"type": "sketch",
"parent": "glitch.p5-demos",
"code": "// p5.glitch-webcam\n// cc teddavis.org 2020\n\nlet libs = [\"includes/libs/p5.glitch.js\"];\n\nlet glitch, capture, w = 320, h = 240;\n\nfunction setup() {\n\tcapture = createCapture(VIDEO);\n\tcapture.size(w, h);\n\tcapture.hide();\n\n\tcreateCanvas(windowWidth, windowHeight);\n\n\tbackground(0);\n\timageMode(CENTER);\n\n\tglitch = new Glitch();\n\tglitch.pixelate(1);\n}\n\nfunction draw() {\n\tif(frameCount % 3 === 0) {\n\t\t\n\t\tif(!mouseIsPressed){\n\t\t\tglitch.loadImage(capture);\n\t\t}\n\t\t\n\t\t// map mouseX to # of randomBytes() + mouseY to limitBytes()\n\t\tglitch.limitBytes(map(mouseY, 0, height, 0, 1));\n\t\tglitch.randomBytes(map(mouseX, 0, width, 0, 100));\n\t\tglitch.buildImage();\n\t}\n\t\n\timage(glitch.image, width / 2, height / 2, glitch.width, glitch.height)\n}"
}
]
}