Skip to content

Instantly share code, notes, and snippets.

@ryanbrubaker
Created June 7, 2012 02:07
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 ryanbrubaker/2886084 to your computer and use it in GitHub Desktop.
Save ryanbrubaker/2886084 to your computer and use it in GitHub Desktop.
CommunicationLineView for morse code demo
class CommunicationLineView extends Backbone.View
initialize: ->
@model.bind('hasNewData', @render)
render: (tokens) =>
context = document.getElementById(
"communicationLineCanvas").getContext('2d')
context.clearRect(0, 0, context.canvas.width, 29)
tokenNum = 0
for token in tokens
do (token) ->
if kDotToken == token
context.beginPath()
context.moveTo((50 * tokenNum) + 15, 15)
context.arc((50 * tokenNum) + 15, 15, 10,
0, Math.PI*2, false)
context.closePath()
context.fill()
context.stroke()
else if kDashToken == token
context.fillRect((50 * tokenNum) + 15,
15, 25, 10)
else if kWordStopToken == token
context.fillRect((50 * tokenNum) + 30,
5, 10, 20)
tokenNum += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment