Skip to content

Instantly share code, notes, and snippets.

@devth
Created February 2, 2012 16:05
Show Gist options
  • Save devth/1724244 to your computer and use it in GitHub Desktop.
Save devth/1724244 to your computer and use it in GitHub Desktop.
class @Stars
constructor: (container, w, h) ->
@renderer = new Highcharts.Renderer(container, w, h)
@group = @renderer.g().add()
render: =>
# :%s/\\d\\+/\\=(submatch(0)-3)/
@scale = .8
# 5 Stars
paths = for i in [0..4]
# Draw a star
path = [
'M', 90,98, # Starting position
'L', 119,0, # Draw lines
148,98,
238,98,
166,152,
192,238,
119,187,
46,238,
72,152,
0,98,
90,98
]
# Scale all numbers & translate the Xs only
t = false # toggling boolean
path = for p in path
if isNaN(p) then p
else
(p * @scale + (if t = !t then (i * 90 * @scale) else 0))
# Translate Xs
# path[1] += (i * 90 * @scale) + (i * 5 * @scale)
path
for path in paths
@renderer.path(path).attr
'stroke-width': 0
fill: '#666666'
.add()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment