Skip to content

Commit

Permalink
Fixed arrayToRGB when array is a string
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelgrosner committed Feb 7, 2012
1 parent b4b9585 commit 441579a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 2 additions & 5 deletions CanvasContext.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class CanvasContext
constructor: (@canvas_tag) ->
constructor: (@canvas_tag, @background_color = "#ffffff") ->
@elements = []

try
Expand All @@ -15,16 +15,13 @@ class CanvasContext
@resizeToWindow()
@drawAll()

# Background color of the canvas
# TODO: Embedder changable?
@background_color = [255, 255, 255]

# Prevent highlighting on canvas, something which often happens
# while clicking and dragging
$(@canvas).css
"user-select": "none"
"-moz-user-select": "none"
"-webkit-user-select": "none"
"background-color": arrayToRGB @background_color

resizeToWindow: =>
@canvas.width = window.innerWidth
Expand Down
5 changes: 3 additions & 2 deletions main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ hexToRGBArray = (h) ->

arrayToRGB = (a) ->
if typeof a == 'string'
if a.startswith "#" and a.length == 7
if a.startswith "#"
console.log "hex"
return a
else
alert "Improperly formatted string -> color. Must be of the form #XXXXXX"
alert "Improperly formatted string -> color. \
Must be of the form #XXXXXX"

if not a?
a = randomRGB()
Expand Down

0 comments on commit 441579a

Please sign in to comment.