@@ -17,17 +17,13 @@ Future<void> testMain() async {
17
17
const Rect region = Rect .fromLTWH (0 , 0 , 300 , 300 );
18
18
19
19
late BitmapCanvas canvas;
20
- late BitmapCanvas domCanvas;
21
20
22
21
setUp (() {
23
22
canvas = BitmapCanvas (region, RenderStrategy ());
24
- // setting isInsideSvgFilterTree true forces use of DOM canvas
25
- domCanvas = BitmapCanvas (region, RenderStrategy ()..isInsideSvgFilterTree = true );
26
23
});
27
24
28
25
tearDown (() {
29
26
canvas.rootElement.remove ();
30
- domCanvas.rootElement.remove ();
31
27
});
32
28
33
29
test ('draws lines with varying strokeWidth' , () async {
@@ -37,75 +33,6 @@ Future<void> testMain() async {
37
33
domDocument.body! .append (canvas.rootElement);
38
34
await matchGoldenFile ('canvas_lines_thickness.png' , region: region);
39
35
});
40
- test ('draws lines with varying strokeWidth with dom canvas' , () async {
41
-
42
- paintLines (domCanvas);
43
-
44
- domDocument.body! .append (domCanvas.rootElement);
45
- await matchGoldenFile ('canvas_lines_thickness_dom_canvas.png' , region: region);
46
- });
47
- test ('draws lines with negative Offset values with dom canvas' , () async {
48
- // test rendering lines correctly with negative offset when using DOM
49
- final SurfacePaintData paintWithStyle = SurfacePaintData ()
50
- ..color = 0xFFE91E63 // Colors.pink
51
- ..style = PaintingStyle .stroke
52
- ..strokeWidth = 16
53
- ..strokeCap = StrokeCap .round;
54
-
55
- // canvas.drawLine ignores paint.style (defaults to fill) according to api docs.
56
- // expect lines are rendered the same regardless of the set paint.style
57
- final SurfacePaintData paintWithoutStyle = SurfacePaintData ()
58
- ..color = 0xFF4CAF50 // Colors.green
59
- ..strokeWidth = 16
60
- ..strokeCap = StrokeCap .round;
61
-
62
- // test vertical, horizontal, and diagonal lines
63
- final List <Offset > points = < Offset > [
64
- const Offset (- 25 , 50 ), const Offset (45 , 50 ),
65
- const Offset (100 , - 25 ), const Offset (100 , 200 ),
66
- const Offset (- 150 , - 145 ), const Offset (100 , 200 ),
67
- ];
68
- final List <Offset > shiftedPoints = points.map ((Offset point) => point.translate (20 , 20 )).toList ();
69
-
70
- paintLinesFromPoints (domCanvas, paintWithStyle, points);
71
- paintLinesFromPoints (domCanvas, paintWithoutStyle, shiftedPoints);
72
-
73
- domDocument.body! .append (domCanvas.rootElement);
74
- await matchGoldenFile ('canvas_lines_with_negative_offset.png' , region: region);
75
- });
76
-
77
- test ('drawLines method respects strokeCap with dom canvas' , () async {
78
- final SurfacePaintData paintStrokeCapRound = SurfacePaintData ()
79
- ..color = 0xFFE91E63 // Colors.pink
80
- ..strokeWidth = 16
81
- ..strokeCap = StrokeCap .round;
82
-
83
- final SurfacePaintData paintStrokeCapSquare = SurfacePaintData ()
84
- ..color = 0xFF4CAF50 // Colors.green
85
- ..strokeWidth = 16
86
- ..strokeCap = StrokeCap .square;
87
-
88
- final SurfacePaintData paintStrokeCapButt = SurfacePaintData ()
89
- ..color = 0xFFFF9800 // Colors.orange
90
- ..strokeWidth = 16
91
- ..strokeCap = StrokeCap .butt;
92
-
93
- // test vertical, horizontal, and diagonal lines
94
- final List <Offset > points = < Offset > [
95
- const Offset (5 , 50 ), const Offset (45 , 50 ),
96
- const Offset (100 , 5 ), const Offset (100 , 200 ),
97
- const Offset (5 , 10 ), const Offset (100 , 200 ),
98
- ];
99
- final List <Offset > shiftedPoints = points.map ((Offset point) => point.translate (50 , 50 )).toList ();
100
- final List <Offset > twiceShiftedPoints = shiftedPoints.map ((Offset point) => point.translate (50 , 50 )).toList ();
101
-
102
- paintLinesFromPoints (domCanvas, paintStrokeCapRound, points);
103
- paintLinesFromPoints (domCanvas, paintStrokeCapSquare, shiftedPoints);
104
- paintLinesFromPoints (domCanvas, paintStrokeCapButt, twiceShiftedPoints);
105
-
106
- domDocument.body! .append (domCanvas.rootElement);
107
- await matchGoldenFile ('canvas_lines_with_strokeCap.png' , region: region);
108
- });
109
36
}
110
37
111
38
void paintLines (BitmapCanvas canvas) {
@@ -143,10 +70,3 @@ void paintLines(BitmapCanvas canvas) {
143
70
paint3.color = 0xFFFF9800 ; // Colors.orange;
144
71
canvas.drawLine (const Offset (50 , 70 ), const Offset (150 , 70 ), paint3);
145
72
}
146
-
147
- void paintLinesFromPoints (BitmapCanvas canvas, SurfacePaintData paint, List <Offset > points) {
148
- // points list contains pairs of Offset points, so for loop step is 2
149
- for (int i = 0 ; i < points.length - 1 ; i += 2 ) {
150
- canvas.drawLine (points[i], points[i + 1 ], paint);
151
- }
152
- }
0 commit comments