PoP5js
by sampottinger
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.js"></script>
JavaScript
var drawing_sample = (function () {
function drawing_sample() {
this.d = new drawing_sample.Drawer(this);
}
drawing_sample.prototype.setP5Inst = function(newP5Inst) {
this.p5 = newP5Inst;
}
drawing_sample.prototype.line = function (x1, x2, x3, x4) {
this.p5.line(x1, x2, x3, x4);
};
drawing_sample.prototype.size = function (width, height) {
this.p5.createCanvas(width, height);
};
drawing_sample.prototype.background = function (color) {
this.p5.background(color);
};
drawing_sample.prototype.noFill = function () {
this.p5.noFill();
};
drawing_sample.prototype.stroke = function (color) {
this.p5.stroke(color);
};
drawing_sample.prototype.mouseX = function () {
return this.p5.mouseX;
};
drawing_sample.prototype.mouseY = function () {
return this.p5.mouseY;
};
drawing_sample.prototype.mousePressed = function () {
return this.mousePressedStatus;
};
drawing_sample.prototype.setMousePressedWaiting = function (newWaitingStatus) {
this.mousePressedWaitingStatus = newWaitingStatus;
};
drawing_sample.prototype.acceptMousePressedWaiting = function () {
this.mousePressedStatus = this.mousePressedWaitingStatus;
};
drawing_sample.prototype.setup = function () {
this.background("#FAFAFA");
};
drawing_sample.prototype.draw = function () {
this.noFill();
this.stroke("#333333");
if (this.mousePressed()) {
this.d.drawLine();
}
};
drawing_sample.prototype.settings = function () {
this.size(300, 300);
};
drawing_sample.main = function (passedArgs) {
var emulatedSketch = new drawing_sample();
new p5((sketch) => {
emulatedSketch.setP5Inst(sketch);
sketch.setup = () => {
emulatedSketch.settings();
emulatedSketch.setup();
};
...