Scale SKPicture without scaling stroke width

113 views
Skip to first unread message

Muzib

unread,
Jan 15, 2023, 7:38:39 PM1/15/23
to skia-discuss
Hi,
In my app, I was testing how large load Skia can handle without dropping performance. 
My case only involves drawing vectors (lines, paths, curves etc), no pictures. I am using SKPicture to save all the drawing commands and reusing it over and over. 

I have also found out that I can handle user zoom in/out and panning - by applying required transformation on the CanvasView instead of applying it on the SKPicture. 

Now, my problem is that the scale transformation also applies to the stroke width of the SKPicture. Specifying an SKPaint in the DrawPicture method doesn't effect the stroke width. As a result, I have to regenerate the SKPicture on every scale change to avoid stroke width getting too thick ot too thin.

Is there any way around this?

Thanks.

Brian Osman

unread,
Jan 15, 2023, 7:41:08 PM1/15/23
to skia-d...@googlegroups.com
No, there isn't a way to do that directly - typically when vector graphics are zoomed, the stroke width changes along with everything else. The only exception (in Skia) is if you set the stroke width to zero, it's treated as "hairline". Those strokes are always drawn as single-pixel, regardless of zoom level.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/2648fc6b-949f-4fb5-b84d-c5c00a9c166fn%40googlegroups.com.

Muzib

unread,
Jan 16, 2023, 7:13:30 AM1/16/23
to skia-discuss
Well, that is what I was looking for.
Thanks a ton.
Reply all
Reply to author
Forward
0 new messages