Created
December 24, 2011 21:56
-
-
Save alanedwardes/1518434 to your computer and use it in GitHub Desktop.
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
length = Math.max(canvas.width, canvas.height); | |
// Make sure the rays are bigger than the canvas | |
midx = canvas.width / 2, midy = canvas.height / 2; | |
// Get the mid point of our canvas | |
var d = 12; | |
// how many rays (or divisions) | |
for(i = 0;i < d;i++){ | |
angle = (Math.PI * 2 / d) * i; | |
// 360 degrees is Math.PI * 2: | |
// we're getting that divided by | |
// divisions times loop interations | |
context.moveTo(midx, midy); | |
// Move to the middle of the canvas | |
c1 = getXY(midx, midy, length, angle + d / 100); | |
// Calculate the first co-ordinates | |
context.lineTo(c1.x, c1.y); | |
// Line from the middle to the first co-ordinates | |
c2 = getXY(midx, midy, length, angle - d / 100); | |
// Calculate the second co-ordinates | |
context.lineTo(c2.x, c2.y); | |
// Line to the second co-ordinates | |
context.lineTo(midx, midy); | |
// Line back to the middle | |
context.fill(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment