-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable more linear gradient fill cases, including animated linear gradients. #146
Conversation
|
||
var gradientStopKeyFrames = stops.KeyFrames.ToArray(); | ||
|
||
// Create the Composition stops and animated them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
animated [](start = 52, length = 8)
nit typo: animate #Closed
} | ||
|
||
return result; | ||
} | ||
|
||
static IEnumerable<KeyFrame<T>> ExtractKeyFramesFromGradientStopKeyFrames<T>(KeyFrame<Sequence<GradientStop>>[] stops, int stopIndex, Func<GradientStop, T> selector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static IEnumerable<KeyFrame> ExtractKeyFramesFromGradientStopKeyFrames(KeyFrame<Sequence>[] stops, int stopIndex, Func<GradientStop, T> selector) [](start = 7, length = 166)
Probably make this line shorter #Closed
var gradientStop = _c.CreateColorGradientStop(); | ||
colorStops.Add(gradientStop); | ||
|
||
var colorKeyFrames = ExtractKeyFramesFromGradientStopKeyFrames(gradientStopKeyFrames, i, gs => MultiplyColorByOpacityPercent(MultiplyColorByOpacityPercent(gs.Color, gs.OpacityPercent), opacityPercentValue)).ToArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var colorKeyFrames = ExtractKeyFramesFromGradientStopKeyFrames(gradientStopKeyFrames, i, gs => MultiplyColorByOpacityPercent(MultiplyColorByOpacityPercent(gs.Color, gs.OpacityPercent), opacityPercentValue)).ToArray(); [](start = 20, length = 217)
should make this line not as long #Closed
var gradientStop = _c.CreateColorGradientStop(); | ||
colorStops.Add(gradientStop); | ||
|
||
var colorKeyFrames = ExtractKeyFramesFromGradientStopKeyFrames(gradientStopKeyFrames, i, gs => MultiplyColorByOpacityPercent(MultiplyColorByOpacityPercent(gs.Color, gs.OpacityPercent), opacityPercentValue)).ToArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MultiplyColorByOpacityPercent(MultiplyColorByOpacityPercent(gs.Color, gs.OpacityPercent), opacityPercentValue) [](start = 115, length = 110)
Make a function for the MultiplyColorByOpacityPercent passed to MultiplyColorByOpacityPercent perhaps along with a comment since the idea of propagating opacity in addition to the opacity on the gradient stops is something we should call out that we are supporting. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is no longer relevant with the new checks at the top of this function.
In reply to: 320396945 [](ancestors = 320396945,319705117)
var color = MultiplyColorByOpacityPercent(MultiplyColorByOpacityPercent(stop.Color, stop.OpacityPercent), opacityPercentValue); | ||
if (color == null) | ||
{ | ||
// We currently do not support gradients that contain separate opacity stops. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// We currently do not support gradients that contain separate opacity stops. [](start = 24, length = 77)
Suggestion: Maybe this comment can read "We currently do not support gradient stops that are opacity or color only"
From reviewing what MultiplyColorByOpacityPercent does and I assume that Lotties could have stops that are opacity but not color as well? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. We do support color only. It's the opacity-only ones that we can't support (because we don't know what color to use). Eventually we will handle this by creating a ShapeVisual per Shape/Group and putting the opacity on the ShapeVisual
In reply to: 319705548 [](ancestors = 319705548)
* LottieGen reports stats to a TSV file instead of CSV. Added a more general stats reporting mechanism. * LottieGen: eliminate Verbose option and replace with much better stats file outputs. * CR feedback.
…stops. Ignore opacity if it is specified for a gradient, rather than rendering nothing.
…nsistent with ShapeLayer.
…kit/Lottie-Windows into LinearGradientFill2
} | ||
|
||
public readonly Color Color; | ||
public readonly double Offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public readonly double Offset; [](start = 8, length = 30)
I know we don't gain much but would it make sense to have a base class that is GradientStop and knows how to print the offset and then you just re-use that when doing the ToString #ByDesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing that's the same in the ToString is the @{Offset} part. The ColorGradientStop and OpacityGradientStop have no relationship with each other, i.e. we never want to treat them as just of type GradientStop.
In reply to: 321464452 [](ancestors = 321464452)
: base(in args, fillType, opacityPercent) | ||
{ | ||
StartPoint = startPoint; | ||
EndPoint = endPoint; | ||
GradientStops = gradientStops; | ||
ColorStops = colorStops; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ColorStops = colorStops; [](start = 12, length = 24)
It is legal to not have any Color stops? (this should be totally legal in most art programs, but might be weird for our scenarios unless we use the gradient in masks) #ByDesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I could also see that we want to just store the data and do WinComp related support checks in the translator in which case you can ignore this comment.
In reply to: 321465656 [](ancestors = 321465656)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone gives us a silly Lottie file, they'll get silly output. AFAICT there's nothing illegal about opacity only.
In reply to: 321468369 [](ancestors = 321468369,321465656)
{ | ||
// We don't yet support animated opacity with LinearGradientFill. | ||
_issues.GradientFillIsNotSupported(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GradientFillIsNotSupported [](start = 24, length = 26)
should this error message maybe be a bit more specific if the opacityPercent is not something indicated directly on the gradient. #WontFix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are quite a few cases that we can't get quite right at the moment with gradients, so rather than trying to enumerate them all, I figure we can at least point out that something isn't right with gradients.
When it becomes clear what we definitely can or cannot support, then it might be worth making these more specific, but for now, to make progress, I'll keep it general.
In reply to: 321468727 [](ancestors = 321468727)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linear gradient fills should work fine for common cases now.