[web] Make null paint color consistent with mobile&desktop (flutter/engine#23778)
This commit is contained in:
@@ -950,7 +950,7 @@ class BitmapCanvas extends EngineCanvas {
|
||||
} else {
|
||||
_drawPointsPaint.style = ui.PaintingStyle.fill;
|
||||
}
|
||||
_drawPointsPaint.color = paint.color;
|
||||
_drawPointsPaint.color = paint.color ?? const ui.Color(0xFF000000);
|
||||
_drawPointsPaint.maskFilter = paint.maskFilter;
|
||||
|
||||
final double dpr = ui.window.devicePixelRatio;
|
||||
|
||||
@@ -927,8 +927,8 @@ class ContextStateHandle {
|
||||
fillStyle = colorString;
|
||||
strokeStyle = colorString;
|
||||
} else {
|
||||
fillStyle = '';
|
||||
strokeStyle = '';
|
||||
fillStyle = '#000000';
|
||||
strokeStyle = '#000000';
|
||||
}
|
||||
|
||||
final ui.MaskFilter? maskFilter = paint.maskFilter;
|
||||
|
||||
@@ -252,11 +252,14 @@ html.Element _pathToSvgElement(SurfacePath path, SurfacePaintData paint,
|
||||
sb.write(
|
||||
'<svg viewBox="0 0 $width $height" width="${width}px" height="${height}px">');
|
||||
sb.write('<path ');
|
||||
final ui.Color color = paint.color ?? const ui.Color(0xFF000000);
|
||||
if (paint.style == ui.PaintingStyle.stroke) {
|
||||
sb.write('stroke="${colorToCssString(paint.color)}" ');
|
||||
sb.write('stroke="${colorToCssString(color)}" ');
|
||||
sb.write('stroke-width="${paint.strokeWidth}" ');
|
||||
} else if (paint.color != null) {
|
||||
sb.write('fill="${colorToCssString(paint.color)}" ');
|
||||
sb.write('fill="${colorToCssString(color)}" ');
|
||||
} else {
|
||||
sb.write('fill="#000000" ');
|
||||
}
|
||||
if (path.fillType == ui.PathFillType.evenOdd) {
|
||||
sb.write('fill-rule="evenodd" ');
|
||||
|
||||
@@ -39,33 +39,37 @@ void testMain() async {
|
||||
}
|
||||
|
||||
void paintLines(BitmapCanvas canvas) {
|
||||
final SurfacePaintData paint1 = SurfacePaintData()
|
||||
final SurfacePaintData nullPaint = SurfacePaintData()
|
||||
..strokeWidth = 1.0
|
||||
..style = PaintingStyle.stroke;
|
||||
final SurfacePaintData paint1 = SurfacePaintData()
|
||||
..color = Color(0xFF9E9E9E) // Colors.grey
|
||||
..strokeWidth = 1.0
|
||||
..style = PaintingStyle.stroke;
|
||||
final SurfacePaintData paint2 = SurfacePaintData()
|
||||
final SurfacePaintData paint2 = SurfacePaintData()
|
||||
..color = Color(0x7fff0000)
|
||||
..strokeWidth = 1.0
|
||||
..style = PaintingStyle.stroke;
|
||||
final SurfacePaintData paint3 = SurfacePaintData()
|
||||
final SurfacePaintData paint3 = SurfacePaintData()
|
||||
..color = Color(0xFF4CAF50) //Colors.green
|
||||
..strokeWidth = 1.0
|
||||
..style = PaintingStyle.stroke;
|
||||
// Draw markers around 100x100 box
|
||||
canvas.drawLine(Offset(50, 50), Offset(52, 50), paint1);
|
||||
canvas.drawLine(Offset(150, 50), Offset(148, 50), paint1);
|
||||
canvas.drawLine(Offset(50, 150), Offset(52, 150), paint1);
|
||||
canvas.drawLine(Offset(150, 150), Offset(148, 150), paint1);
|
||||
// Draw diagonal
|
||||
canvas.drawLine(Offset(50, 50), Offset(150, 150), paint2);
|
||||
// Draw horizontal
|
||||
paint3.strokeWidth = 1.0;
|
||||
paint3.color = Color(0xFFFF0000);
|
||||
canvas.drawLine(Offset(50, 55), Offset(150, 55), paint3);
|
||||
paint3.strokeWidth = 2.0;
|
||||
paint3.color = Color(0xFF2196F3); // Colors.blue;
|
||||
canvas.drawLine(Offset(50, 60), Offset(150, 60), paint3);
|
||||
paint3.strokeWidth = 4.0;
|
||||
paint3.color = Color(0xFFFF9800); // Colors.orange;
|
||||
canvas.drawLine(Offset(50, 70), Offset(150, 70), paint3);
|
||||
// Draw markers around 100x100 box
|
||||
canvas.drawLine(Offset(50, 40), Offset(148, 40), nullPaint);
|
||||
canvas.drawLine(Offset(50, 50), Offset(52, 50), paint1);
|
||||
canvas.drawLine(Offset(150, 50), Offset(148, 50), paint1);
|
||||
canvas.drawLine(Offset(50, 150), Offset(52, 150), paint1);
|
||||
canvas.drawLine(Offset(150, 150), Offset(148, 150), paint1);
|
||||
// Draw diagonal
|
||||
canvas.drawLine(Offset(50, 50), Offset(150, 150), paint2);
|
||||
// Draw horizontal
|
||||
paint3.strokeWidth = 1.0;
|
||||
paint3.color = Color(0xFFFF0000);
|
||||
canvas.drawLine(Offset(50, 55), Offset(150, 55), paint3);
|
||||
paint3.strokeWidth = 2.0;
|
||||
paint3.color = Color(0xFF2196F3); // Colors.blue;
|
||||
canvas.drawLine(Offset(50, 60), Offset(150, 60), paint3);
|
||||
paint3.strokeWidth = 4.0;
|
||||
paint3.color = Color(0xFFFF9800); // Colors.orange;
|
||||
canvas.drawLine(Offset(50, 70), Offset(150, 70), paint3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user