Skip to content

Instantly share code, notes, and snippets.

@vijaydev
Created May 23, 2011 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaydev/986436 to your computer and use it in GitHub Desktop.
Save vijaydev/986436 to your computer and use it in GitHub Desktop.
def pie_to(val, r)
rads = (val*3.60) * Math::PI / 180 # 360 deg of val % in radians
sr = (r * Math.sin(rads)).to_i
cr = (r * Math.cos(rads)).to_i
arc = val <= 50 ? 0 : 1
[sr, r-cr, arc]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment