This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Pass angles for SweepGradient in degrees, not radians #21677
Merged
harryterkelsen
merged 7 commits into
flutter-team-archive:master
from
harryterkelsen:canvaskit-sweep-gradient
Dec 12, 2020
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
26202c1
Pass angles for SweepGradient in degrees, not radians
harryterkelsen 85a5c35
Merge branch 'master' into canvaskit-sweep-gradient
harryterkelsen 1a5aff7
add test
harryterkelsen 8e77199
Remove write flag
harryterkelsen abae9a6
Skip screenshot tests on safari and firefox
harryterkelsen b0f4c56
Remove unused imports
harryterkelsen 91463f9
Update goldens lock
harryterkelsen 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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| // @dart = 2.12 | ||
| import 'dart:html' as html; | ||
| import 'dart:math' as math; | ||
| import 'dart:typed_data'; | ||
|
|
||
| import 'package:test/bootstrap/browser.dart'; | ||
| import 'package:test/test.dart'; | ||
| import 'package:ui/src/engine.dart'; | ||
| import 'package:ui/ui.dart' as ui; | ||
|
|
||
| import 'package:web_engine_tester/golden_tester.dart'; | ||
|
|
||
| import 'common.dart'; | ||
|
|
||
| void main() { | ||
| internalBootstrapBrowserTest(() => testMain); | ||
| } | ||
|
|
||
| const ui.Rect region = const ui.Rect.fromLTRB(0, 0, 500, 250); | ||
|
|
||
| Future<void> matchPictureGolden(String goldenFile, CkPicture picture, | ||
| {bool write = false}) async { | ||
| final EnginePlatformDispatcher dispatcher = | ||
| ui.window.platformDispatcher as EnginePlatformDispatcher; | ||
| final LayerSceneBuilder sb = LayerSceneBuilder(); | ||
| sb.pushOffset(0, 0); | ||
| sb.addPicture(ui.Offset.zero, picture); | ||
| dispatcher.rasterizer!.draw(sb.build().layerTree); | ||
| await matchGoldenFile(goldenFile, region: region, write: write); | ||
| } | ||
|
|
||
| void testMain() { | ||
| group('SweepGradient', () { | ||
| setUpCanvasKitTest(); | ||
|
|
||
| test('is correctly rendered', () async { | ||
| final CkPictureRecorder recorder = CkPictureRecorder(); | ||
| final CkCanvas canvas = recorder.beginRecording(region); | ||
|
|
||
| final CkGradientSweep gradient = CkGradientSweep( | ||
| ui.Offset(250, 125), | ||
| <ui.Color>[ | ||
| ui.Color(0xFF4285F4), | ||
| ui.Color(0xFF34A853), | ||
| ui.Color(0xFFFBBC05), | ||
| ui.Color(0xFFEA4335), | ||
| ui.Color(0xFF4285F4), | ||
| ], | ||
| <double>[ | ||
| 0.0, | ||
| 0.25, | ||
| 0.5, | ||
| 0.75, | ||
| 1.0, | ||
| ], | ||
| ui.TileMode.clamp, | ||
| -(math.pi / 2), | ||
| math.pi * 2 - (math.pi / 2), | ||
| null); | ||
|
|
||
| final CkPaint paint = CkPaint()..shader = gradient; | ||
|
|
||
| canvas.drawRect(region, paint); | ||
|
|
||
| await matchPictureGolden( | ||
| 'canvaskit_sweep_gradient.png', recorder.endRecording(), | ||
| write: true); | ||
| }); | ||
| }); | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.