Permalink
Browse files

Merge branch 'master' of github.com:atleastimtrying/danders

Conflicts:
	public/js/application.coffee
	public/js/node.coffee
	public/js/node.js
  • Loading branch information...
2 parents a1d847e + 49f611a commit af8669d04032658ada25537edadec5e83468f993 @danhigham danhigham committed Apr 28, 2012
Showing with 59 additions and 44 deletions.
  1. +5 −4 public/js/application.coffee
  2. +6 −6 public/js/application.js
  3. +22 −8 public/js/node.coffee
  4. +26 −6 public/js/node.js
  5. +0 −9 public/js/nodes.coffee
  6. +0 −11 public/js/nodes.js
@@ -7,10 +7,6 @@ class window.App
@arc x, y, radius, 0, Math.PI * 2, false
@closePath()
@fill()
- @ctx.percentToRadians = (percent)->
- degrees = (percent/100) * 360
- radians = degrees * (Math.pi/180)
- return radians
@nodes = new Nodes(@)
@request = new ApiRequester()
@input = new Input(@)
@@ -59,5 +55,10 @@ class window.App
Ruby:"red"
PHP: "purple"
+ percentToRadians: (percent)->
+ degrees = (percent/100) * 360
+ radians = degrees * (Math.PI/180)
+ return radians
+
$ ->
window.app = new App
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -5,15 +5,29 @@ class window.Node
@followers = data.followers
@languages = data.languages
@colour = "rgba(0,0,0,0.5)"
- @currentPercentage = 0
+ @currentRadians = 0
+ @makeImage(@languages)
draw: =>
- @currentPercentage = 0
- @ctx.translate @x , @y
- # @drawArcByPercentage(language, percent) for language, percent of @langauges
+ @ctx.translate @x, @y
+ #draw image
@ctx.translate -@x, -@y
- drawArcByPercentage: (language, percent)->
- @beginPath()
- @arc 0, 0, @radius, 0, Math.PI * 2, false
- @closePath()
+ makeImage: (languages)->
+ canvas = document.createElement('canvas')
+ ctx = canvas.getContext('2d')
+ canvas.width = @radius *2
+ canvas.height = @radius *2
+ @drawArcByPercentage(ctx,language, percent,canvas.width/2,canvas.height/2) for language, percent of @languages
+ window.open(canvas.toDataURL(), "pieImage", "left=0,top=0,width=#{canvas.width},height=#{canvas.height},toolbar=0,resizable=0")
+
+ drawArcByPercentage: (ctx,language, percent,x,y)->
+ percentInRadians = window.app.percentToRadians percent
+ colour = app.getLanguageColour(language)
+ ctx.beginPath()
+ ctx.moveTo(x,y)
+ ctx.arc x, y, @radius, @currentRadians, @currentRadians + percentInRadians, false
+ ctx.closePath()
+ ctx.fillStyle = colour
+ ctx.fill()
+ @currentRadians += percentInRadians
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -5,16 +5,7 @@ class window.Nodes
draw: =>
node.draw() for node in @collection
- makeNode: (event)=>
- @newNode
- x: event.pageX
- y: event.pageY
- repo_count: 4
- name: 'Dan'
- followers: 1
-
newChildNode: (name, i)=>
- console.log i
node = new ChildNode @app.ctx, name, @app.width/2 - i *30, @app.height/2 + 40, 1
@collection.push node
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit af8669d

Please sign in to comment.