Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c217f27

Browse files
Add new test that includes alpha blending of linear gradient.
1 parent d936d50 commit c217f27

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/web_ui/test/html/shaders/linear_gradient_golden_test.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,27 @@ Future<void> testMain() async {
4545
maxDiffRatePercent: 0.01);
4646
});
4747

48+
test('Should blend linear gradient with alpha channel correctly.', () async {
49+
const Rect canvasRect = Rect.fromLTRB(0, 0, 500, 500);
50+
final RecordingCanvas rc =
51+
RecordingCanvas(canvasRect);
52+
final SurfacePaint backgroundPaint = SurfacePaint()
53+
..style = PaintingStyle.fill
54+
..color = const Color(0xFFFF0000);
55+
rc.drawRect(canvasRect, backgroundPaint);
56+
57+
const Rect shaderRect = Rect.fromLTRB(50, 50, 300, 300);
58+
final SurfacePaint paint = SurfacePaint()..shader = Gradient.linear(
59+
Offset(shaderRect.left, shaderRect.top),
60+
Offset(shaderRect.right, shaderRect.bottom),
61+
const <Color>[Color(0x00000000), Color(0xFF0000FF)]);
62+
rc.drawRect(shaderRect, paint);
63+
expect(rc.renderStrategy.hasArbitraryPaint, isTrue);
64+
await canvasScreenshot(rc, 'linear_gradient_rect_alpha',
65+
region: screenRect,
66+
maxDiffRatePercent: 0.01);
67+
});
68+
4869
test('Should draw linear gradient with transform.', () async {
4970
final RecordingCanvas rc =
5071
RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500));

0 commit comments

Comments
 (0)