Last active
July 27, 2017 06:47
-
-
Save GoSubRoutine/ce702dbf832b11732ddae6b7c7d49f9d to your computer and use it in GitHub Desktop.
Instance Mode Multi-Files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
height: 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script defer src=http://CDN.JSDelivr.net/npm/p5></script> | |
<script defer src=mouseHandler.js></script> | |
<script defer src=sketch.js></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var imports; | |
void function (imports) { | |
function mousePressed() { | |
const inc = this.mouseButton === this.LEFT && -1 || 1; | |
this.a = this.constrain(this.a + inc, -1, 100); | |
console.log(this.a); | |
this.redraw(); | |
} | |
imports.mousePressed = mousePressed; | |
}(imports || (imports = {})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Instance Mode Multi-Files (v1.7.1) | |
* GoToLoop (2017-Jul-26) | |
* | |
* Forum.Processing.org/two/discussion/23580/ | |
* instance-mode-over-multiple-files#Item_1 | |
* | |
* Bl.ocks.org/GoSubRoutine/ce702dbf832b11732ddae6b7c7d49f9d | |
*/ | |
"use strict"; | |
void function () { | |
const s = new p5(p => { | |
let a = ~~p.random(100); | |
Object.defineProperty(p, 'a', { | |
get() { return a; }, set(n) { a = n; }, | |
enumerable: true, configurable: false | |
}); | |
p.setup = function () { | |
this.createCanvas(300, 200); | |
this.noLoop(); | |
this.colorMode(this.RGB).blendMode(this.BLEND); | |
this.fill('yellow').stroke('red').strokeWeight(2.5); | |
this.textAlign(this.CENTER, this.CENTER).textSize(0o200); | |
}; | |
function draw() { | |
this.background('#' + this.hex(~~this.random(0x1000), 3)); | |
this.text(a, this.width>>1, this.height>>1); | |
} | |
p.draw = draw.bind(p); | |
}, 'canvas-holder'); | |
s.mousePressed = imports.mousePressed; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment