Created
June 3, 2014 19:32
-
-
Save lmccart/36adc76c6c012ce95a49 to your computer and use it in GitHub Desktop.
remove with two sketches
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
var s0 = function( sketch ) { | |
var gray = 0; | |
var h = 10; | |
sketch.setup = function() { | |
var cnv = sketch.createCanvas(400, 400); | |
cnv.mousePressed(increaseH); | |
sketch.rectMode(sketch.CENTER); | |
sketch.print("both gray values should change, rect in sketch0 should change only when clicking on canvas0"); | |
}; | |
sketch.draw = function() { | |
sketch.background(gray); | |
sketch.rect(sketch.width/2, sketch.height/2, h, h); | |
}; | |
sketch.mousePressed = function() { | |
gray += 10; | |
}; | |
sketch.mouseMoved = function() { | |
sketch.print("sketch0 x:"+sketch.mouseX+" y:"+sketch.mouseY); | |
}; | |
function increaseH() { | |
h += 5; | |
} | |
sketch.keyPressed = function() { | |
sketch.remove(); | |
}; | |
}; | |
var myp5_0 = new p5(s0, 'div0'); | |
var s1 = function( sketch ) { | |
var gray = 0; | |
sketch.setup = function() { | |
sketch.createCanvas(400, 400); | |
}; | |
sketch.draw = function() { | |
sketch.background(255, 0, 100); | |
sketch.fill(gray); | |
sketch.rect(sketch.width/2, sketch.height/2, 50, 50); | |
}; | |
sketch.mousePressed = function() { | |
gray += 10; | |
}; | |
sketch.mouseMoved = function() { | |
console.log("sketch1 x:"+sketch.mouseX+" y:"+sketch.mouseY); | |
}; | |
sketch.mouseReleased = function() { | |
console.log("mouseReleased"); | |
}; | |
sketch.keyPressed = function() { | |
sketch.remove(); | |
}; | |
sketch.mouseDragged = function() { | |
console.log("mouseDragged"); | |
}; | |
}; | |
var myp5_1 = new p5(s1, 'div1'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment