Skip to content

Instantly share code, notes, and snippets.

@jemgold
Created May 10, 2015 12:27
Show Gist options
  • Save jemgold/c08afdbf955abfafb923 to your computer and use it in GitHub Desktop.
Save jemgold/c08afdbf955abfafb923 to your computer and use it in GitHub Desktop.
r = 100
generatePolygon = (sides) ->
vertex(v, sides) for v in [0...sides]
vertex = (v, sides) ->
x = r * Math.cos(2 * Math.PI * v / sides)
y = r * Math.sin(2 * Math.PI * v / sides)
new Layer
x: x + 100
y: y + 100
borderRadius: 100
pentagonLayers = generatePolygon 5
pentagonLayers[0].backgroundColor = 'red'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment