Created
November 19, 2012 19:29
-
-
Save mikechambers/4113108 to your computer and use it in GitHub Desktop.
Paper.js Drawing Example
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 thickness; | |
var strokeColor; | |
var text = new PointText(new Point(300, 200)); | |
text.content = "Click and Drag to Draw"; | |
text.characterStyle = { | |
fontSize:36, | |
fillColor:"#777777",//new RgbColor(119,119,119); | |
font:"Arial" | |
}; | |
var myPath; | |
function onMouseDown(e) { | |
if(text) { | |
text.remove(); | |
text = null; | |
} | |
myPath = new Path(); | |
thickness = Math.random() * 30 + 10 | 0; | |
var r = (Math.random()*255 | 0) / 255; | |
var g = (Math.random()*255 | 0) / 255; | |
var b = (Math.random()*255 | 0) / 255; | |
myPath.style = { | |
strokeColor: new RgbColor(r,g,b), | |
strokeWidth:thickness, | |
strokeCap:"round", | |
strokeJoin:"round" | |
} | |
} | |
function onMouseDrag(e) { | |
myPath.add(e.point); | |
myPath.smooth(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment