-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathP5L_p5.glitch-video.json
17 lines (17 loc) · 1.23 KB
/
P5L_p5.glitch-video.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-video",
"mod": 1589928504049,
"type": "sketch",
"parent": "glitch.p5-demos",
"code": "// p5.glitch-video\n// cc teddavis.org 2020\n\nlet libs = [\"includes/libs/p5.glitch.js\"];\n\nlet glitch, vid, rPosition = 1000;\n\nfunction preload() {\n\tvid = createVideo('includes/demos-data/videos/big_buck_bunny.mp4', function() {\n\t\tvid.hide();\n\t\tvid.volume(0);\n\t\tvid.loop();\n\t});\n}\n\nfunction setup() {\n\tcreateCanvas(windowWidth, windowHeight);\n\n\tbackground(255);\n\timageMode(CENTER);\n\n\tglitch = new Glitch();\n\tglitch.pixelate(1);\n}\n\nfunction draw() {\n\tbackground(255);\n\n\t// one per second, set single random byte position\n\tif(frameCount % 60 === 0) {\n\t\trPosition = random(glitch.bytes.length);\n\t}\n\n\tif(frameCount % 3 === 0) {\n\n\t\tif(!mouseIsPressed) {\n\t\t\tglitch.loadImage(vid);\n\t\t}\n\n\t\tglitch.randomByte(rPosition); // single randome byte\n\t\tglitch.limitBytes(.78); // limit bytes to branch\n\t\tglitch.randomBytes(10, 2); // set 10 random bytes\n\t\tglitch.buildImage();\n\t}\n\n\timage(glitch.image, width / 2, height / 2)\n}"
}
]
}