Created
May 19, 2013 13:43
-
-
Save mfields/5607666 to your computer and use it in GitHub Desktop.
Off-screen canvas rendering of a gradient
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
( function () { | |
var canvas = document.getElementById( 'stage' ), | |
context = stage.getContext( '2d' ), | |
gradient = document.createElement( 'canvas' );; | |
( function ( size, renderFunction ) { | |
var gc = gradient.getContext( '2d' ), | |
size = 100, | |
half = size / 2, | |
glow; | |
gradient.width = size; | |
gradient.height = size; | |
glow = gc.createRadialGradient( half, half, 1, half, half, half ); | |
glow.addColorStop( 0, 'rgba( 255, 255, 255, 0.5 )' ); | |
glow.addColorStop( 1, 'rgba( 255, 255 ,255, 0 )' ); | |
gc.fillStyle = glow; | |
gc.fillRect( 0, 0, size, size ); | |
} )(); | |
context.drawImage( gradient, 0, 0 ); | |
} )(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment