Last active
December 10, 2015 09:48
-
-
Save NuckChorris/4416278 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Math.TAU = Math.PI * 2 | |
| CanvasRenderingContext2D.prototype.circularGradient = function (x, y, r, fn) { | |
| var circum = Math.TAU * r | |
| var width = 5 | |
| var lines = circum / (width-1) | |
| console.log(lines) | |
| this.lineWidth = width | |
| for (var i = 0; i < lines; i++) { | |
| this.beginPath() | |
| this.moveTo(x, y) | |
| var theta = (i / lines) * Math.TAU | |
| console.log(i, lines, theta / (Math.PI / 180)); | |
| var end = (new Polar(r, theta)).toCartesian() | |
| this.lineTo(x + end.x, y + end.y) | |
| this.strokeStyle = fn(i / lines) | |
| this.stroke() | |
| } | |
| }; |
This file contains hidden or 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(){ | |
| doItFgt($('#cocks')); | |
| }) | |
| var degree = Math.PI / 180; | |
| var doItFgt = function (el) { | |
| var size = el.height() | |
| var mid = size / 2 | |
| var ctx = el[0].getContext('2d') | |
| ctx.circularGradient(mid, mid, size / 2, function (i) { | |
| console.log(i); | |
| return '#' + Array(4).join(Math.round(i * 255).toString(16)) | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment