A random curve drawing using HTML5 Canvas Bezier and quadratic curves. RequestAnimationFrame loops the process.
Created
January 27, 2015 00:59
-
-
Save tagr/d5415b121d2872f908a3 to your computer and use it in GitHub Desktop.
Sulley's Fur
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
canvas(id='c', width='800', height='600') |
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 doc = document, | |
canvas = doc.querySelector('#c'), | |
cheight = canvas.height, | |
cwidth = canvas.width, | |
context = canvas.getContext('2d'), | |
r = function(seed, step) { | |
return Math.floor(Math.random()*seed)+step; | |
}, | |
draw = function(t) { | |
context.lineWidth = 1; | |
context.beginPath(); | |
context.moveTo(0,0); | |
context.strokeStyle = "rgba("+r(52,0)+","+r(160,0)+","+r(140,21)+",0.1)"; | |
context.bezierCurveTo(r(cwidth,0), Math.random()*cwidth, r(cwidth,0), r(cwidth,0), r(cwidth,0), r(cheight,0)); | |
context.quadraticCurveTo(r(cwidth,0),r(cheight,0),r(cwidth,0),r(cheight,0)); | |
context.stroke(); | |
}; | |
(function animation(){ | |
window.requestAnimationFrame(animation); | |
draw(); | |
})(); | |
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
body { | |
background: #000; | |
} | |
canvas { | |
display: block; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment