Skip to content
Permalink
Browse files

Add a color model parameter for mixing gradients.

Respect the color model of the animation.
  • Loading branch information
eelco authored and Jonas Treub committed Jun 28, 2017
1 parent f32e84e commit 6d4efa68da644bf1b7c04421959d6cffc810e639
Showing with 10 additions and 10 deletions.
  1. +1 −1 framer/Animation.coffee
  2. +9 −9 framer/LinearGradient.coffee
@@ -294,7 +294,7 @@ class exports.Animation extends BaseClass
@_target[key] = Color.mix(@_stateA[key], @_stateB[key], value, false, @options.colorModel)

_updateGradientValue: (key, value) =>
@_target[key] = LinearGradient.mix(@_stateA[key], @_stateB[key], value)
@_target[key] = LinearGradient.mix(@_stateA[key], @_stateB[key], value, @options.colorModel)

_currentState: ->
return _.pick(@layer, _.keys(@properties))
@@ -8,27 +8,27 @@ class exports.LinearGradient extends BaseClass
options.end ?= "white"
options.angle ?= 0
super options

@define "start",
get: -> @_start
set: (value) ->
@_start = new Color(value)

@define "end",
get: -> @_end
set: (value) ->
@_end = new Color(value)

@define "angle",
get: -> @_angle
set: (value) ->
@_angle = value if _.isNumber(value)

toCSS: =>
return "linear-gradient(#{this.angle}deg, #{this.start}, #{this.end})"
mix: (gradientB, fraction) =>
return LinearGradient.mix(@, gradientB, fraction)

mix: (gradientB, fraction, model) =>
return LinearGradient.mix(@, gradientB, fraction, model)

isEqual: (gradientB) ->
return LinearGradient.equal(@, gradientB)
@@ -39,10 +39,10 @@ class exports.LinearGradient extends BaseClass
##############################################################
## Class methods

@mix: (gradientA, gradientB, fraction = 0.5) ->
@mix: (gradientA, gradientB, fraction = 0.5, model) ->
fraction = Utils.clamp(fraction, 0, 1)
start = Color.mix(gradientA.start, gradientB.start, fraction)
end = Color.mix(gradientA.end, gradientB.end, fraction)
start = Color.mix(gradientA.start, gradientB.start, fraction, false, model)
end = Color.mix(gradientA.end, gradientB.end, fraction, false, model)

startAngle = gradientA.angle
endAngle = gradientB.angle

0 comments on commit 6d4efa6

Please sign in to comment.
You can’t perform that action at this time.