-
-
Save gabrielflorit/5a081b9009dcca2ea47f93f0c7e05596 to your computer and use it in GitHub Desktop.
SCRIPT-8
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
{} |
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
init = state => {} | |
update = (state, input, elapsed) => {} | |
// Circle parametric equation. | |
// Given an angle and radius, find xy. | |
const xy = ({ angle, radius, origin }) => { | |
const x = origin.x + radius * Math.cos(angle) | |
const y = origin.y + radius * Math.sin(angle) | |
return { x, y } | |
} | |
// Draw a polygon, given sides, radius, and origin. | |
const drawPolygon = ({ sides, radius, origin }) => { | |
const points = range(sides).map(i => { | |
const angle = i * ((2 * Math.PI) / sides) | |
const { x, y } = xy({ angle, radius, origin }) | |
return [x, y] | |
}) | |
polyStroke(points, 0) | |
} | |
draw = state => { | |
const radius = 28 | |
const origin = { x: 64, y: 64 } | |
clear() | |
rectStroke(0, 0, 128, 128, 5) | |
drawPolygon({ sides: 3, radius, origin: { x: radius * 1.0, y: radius * 1.0 } }) | |
drawPolygon({ sides: 4, radius, origin: { x: radius * 3.5, y: radius * 1.0} }) | |
drawPolygon({ sides: 5, radius, origin: { x: radius * 1.0, y: radius * 3.5 } }) | |
drawPolygon({ sides: 6, radius, origin: { x: radius * 3.5, y: radius * 3.5 } }) | |
} |
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
[] |
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
{ | |
"iframeVersion": "0.1.280", | |
"lines": [ | |
36, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0 | |
] | |
} |
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
{} |
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
{} |
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
{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment