It seems the SVG canvas does not apply any patheffects for canvas.drawRect(...)
from IPython.core.display import SVG
import io
stream = skia.DynamicMemoryWStream()
canvas = skia.SVGCanvas.Make((100, 100), stream)
rect = skia.Rect(10, 10, 50, 50)
paint = skia.Paint(
AntiAlias=True,
PathEffect=skia.DashPathEffect.Make([10.0, 5.0], 0.0),
Style=skia.Paint.kStroke_Style,
StrokeWidth=1,
)
canvas.drawRect(rect, paint)
del canvas
stream.flush()
SVG(stream.detachAsData())

The patheffects e.g. dashedpatheffect is being applied for PNG images without issues.
surface = skia.Surface(100, 100)
canvas = surface.getCanvas()
rect = skia.Rect(10, 10, 50, 50)
paint = skia.Paint(
AntiAlias=True,
PathEffect=skia.DashPathEffect.Make([10.0, 5.0], 0.0),
Style=skia.Paint.kStroke_Style,
StrokeWidth=1,
)
canvas.drawRect(rect, paint)
image = surface.makeImageSnapshot()
display(image)

I know we can use path.addRect(...), but the output xml is very large.
Does anyone know if it possible to add a stroke-dasharray attribute directly to a rect in the output .svg instead?
Cheers,
It seems the SVG canvas does not apply any patheffects for canvas.drawRect(...)
The patheffects e.g. dashedpatheffect is being applied for PNG images without issues.
I know we can use path.addRect(...), but the output xml is very large.
Does anyone know if it possible to add a stroke-dasharray attribute directly to a rect in the output .svg instead?
Cheers,