Skip to content
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

Merged
merged 8 commits into from
Sep 5, 2019

Conversation

simeoncran
Copy link
Contributor

Linear gradient fills should work fine for common cases now.


var gradientStopKeyFrames = stops.KeyFrames.ToArray();

// Create the Composition stops and animated them.
Copy link
Contributor

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)
Copy link
Contributor

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();
Copy link
Contributor

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();
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you are asking for with the comment.


In reply to: 319705117 [](ancestors = 319705117)

Copy link
Contributor

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.
Copy link
Contributor

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

Copy link
Contributor Author

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)

Simeon Cran added 7 commits September 3, 2019 10:44
* 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.
}

public readonly Color Color;
public readonly double Offset;
Copy link
Contributor

@eliezerpMS eliezerpMS Sep 5, 2019

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

Copy link
Contributor Author

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;
Copy link
Contributor

@eliezerpMS eliezerpMS Sep 5, 2019

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

Copy link
Contributor

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)

Copy link
Contributor Author

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();
Copy link
Contributor

@eliezerpMS eliezerpMS Sep 5, 2019

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

Copy link
Contributor Author

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)

Copy link
Contributor

@eliezerpMS eliezerpMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@simeoncran simeoncran merged commit b305a19 into master Sep 5, 2019
@delete-merged-branch delete-merged-branch bot deleted the LinearGradientFill2 branch September 5, 2019 20:45
@michael-hawker michael-hawker added this to the 6.0 milestone Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants