-
Notifications
You must be signed in to change notification settings - Fork 28.8k
Include transform in static Gradient lerp methods #149624
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -191,6 +191,32 @@ void main() { | |||||||||||||
)); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
test('LinearGradient lerp test with transforms', () { | ||||||||||||||
const LinearGradient testGradient1 = LinearGradient( | ||||||||||||||
transform: GradientRotation(math.pi/4), | ||||||||||||||
colors: <Color>[ | ||||||||||||||
Color(0x33333333), | ||||||||||||||
Color(0x66666666), | ||||||||||||||
], | ||||||||||||||
stops: <double>[0, 1], | ||||||||||||||
); | ||||||||||||||
const LinearGradient testGradient2 = LinearGradient( | ||||||||||||||
transform: GradientRotation(math.pi/2), | ||||||||||||||
colors: <Color>[ | ||||||||||||||
Color(0x33333333), | ||||||||||||||
Color(0x66666666), | ||||||||||||||
], | ||||||||||||||
stops: <double>[0, 1], | ||||||||||||||
); | ||||||||||||||
|
||||||||||||||
final LinearGradient? actual0 = LinearGradient.lerp(testGradient1, testGradient2, 0.0); | ||||||||||||||
final LinearGradient? actual1 = LinearGradient.lerp(testGradient1, testGradient2, 1.0); | ||||||||||||||
final LinearGradient? actual2 = LinearGradient.lerp(testGradient1, testGradient2, 0.5); | ||||||||||||||
expect(testGradient1, equals(actual0)); | ||||||||||||||
expect(testGradient2, equals(actual1)); | ||||||||||||||
expect(testGradient2, equals(actual2)); | ||||||||||||||
Comment on lines
+215
to
+217
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Tiny nit: "actual" should be passed as the first argument for |
||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
test('LinearGradient toString', () { | ||||||||||||||
expect( | ||||||||||||||
const LinearGradient( | ||||||||||||||
|
@@ -481,6 +507,32 @@ void main() { | |||||||||||||
)); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
test('RadialGradient lerp test with transforms', () { | ||||||||||||||
const RadialGradient testGradient1 = RadialGradient( | ||||||||||||||
transform: GradientRotation(math.pi/4), | ||||||||||||||
colors: <Color>[ | ||||||||||||||
Color(0x33333333), | ||||||||||||||
Color(0x66666666), | ||||||||||||||
], | ||||||||||||||
stops: <double>[0, 1], | ||||||||||||||
); | ||||||||||||||
const RadialGradient testGradient2 = RadialGradient( | ||||||||||||||
transform: GradientRotation(math.pi/2), | ||||||||||||||
colors: <Color>[ | ||||||||||||||
Color(0x33333333), | ||||||||||||||
Color(0x66666666), | ||||||||||||||
], | ||||||||||||||
stops: <double>[0, 1], | ||||||||||||||
); | ||||||||||||||
|
||||||||||||||
final RadialGradient? actual0 = RadialGradient.lerp(testGradient1, testGradient2, 0.0); | ||||||||||||||
final RadialGradient? actual1 = RadialGradient.lerp(testGradient1, testGradient2, 1.0); | ||||||||||||||
final RadialGradient? actual2 = RadialGradient.lerp(testGradient1, testGradient2, 0.5); | ||||||||||||||
expect(testGradient1, equals(actual0)); | ||||||||||||||
expect(testGradient2, equals(actual1)); | ||||||||||||||
expect(testGradient2, equals(actual2)); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
test('RadialGradient lerp test with focal', () { | ||||||||||||||
const RadialGradient testGradient1 = RadialGradient( | ||||||||||||||
center: Alignment.topLeft, | ||||||||||||||
|
@@ -706,6 +758,32 @@ void main() { | |||||||||||||
)); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
test('SweepGradient lerp test with transforms', () { | ||||||||||||||
const SweepGradient testGradient1 = SweepGradient( | ||||||||||||||
transform: GradientRotation(math.pi/4), | ||||||||||||||
colors: <Color>[ | ||||||||||||||
Color(0x33333333), | ||||||||||||||
Color(0x66666666), | ||||||||||||||
], | ||||||||||||||
stops: <double>[0, 1], | ||||||||||||||
); | ||||||||||||||
const SweepGradient testGradient2 = SweepGradient( | ||||||||||||||
transform: GradientRotation(math.pi/2), | ||||||||||||||
colors: <Color>[ | ||||||||||||||
Color(0x33333333), | ||||||||||||||
Color(0x66666666), | ||||||||||||||
], | ||||||||||||||
stops: <double>[0, 1], | ||||||||||||||
); | ||||||||||||||
|
||||||||||||||
final SweepGradient? actual0 = SweepGradient.lerp(testGradient1, testGradient2, 0.0); | ||||||||||||||
final SweepGradient? actual1 = SweepGradient.lerp(testGradient1, testGradient2, 1.0); | ||||||||||||||
final SweepGradient? actual2 = SweepGradient.lerp(testGradient1, testGradient2, 0.5); | ||||||||||||||
expect(testGradient1, equals(actual0)); | ||||||||||||||
expect(testGradient2, equals(actual1)); | ||||||||||||||
expect(testGradient2, equals(actual2)); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
test('SweepGradient scale test)', () { | ||||||||||||||
const SweepGradient testGradient = SweepGradient( | ||||||||||||||
center: Alignment.topLeft, | ||||||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
not a big deal, but if you feel like it, you could remove the TODO on the line above (or alternatively, add one on the new line, with a link to #443)
(same for all three gradients)