Permalink
Browse files

Add color functions

grey and alpha
  • Loading branch information...
koenbok committed Apr 30, 2016
1 parent d59ba69 commit b85d82cd6c8735bce22fe540e92734c580e3dc4c
Showing with 14 additions and 2 deletions.
  1. +14 −2 framer/Color.coffee
@@ -153,16 +153,22 @@ class exports.Color extends BaseClass
toString: ->
return @toRgbString()
transparent: ->
alpha: (alpha = 1) ->
result = new Color
r: @r
g: @g
b: @b
a: 0
a: alpha
transparent: ->
@alpha(0)
mix: (colorB, fraction, limit = false, model) ->
return Color.mix(@, colorB, fraction, limit, model)
copy: ->
return new Color(@)
isEqual: (colorB) ->
return Color.equal(@, colorB)
@@ -254,6 +260,12 @@ class exports.Color extends BaseClass
c = -> parseInt(Math.random() * 255)
return new Color "rgba(#{c()}, #{c()}, #{c()}, #{alpha})"
@grey: (g = 0.5, alpha = 1) ->
g = parseInt(g * 255)
return new Color "rgba(#{g}, #{g}, #{g}, #{alpha})"
@gray: (args...) -> @grey(args...)
@toColor: (color) -> return new Color(color)
@validColorValue: (color) -> return color instanceof Color or color == null

0 comments on commit b85d82c

Please sign in to comment.