gg icon indicating copy to clipboard operation
gg copied to clipboard

More Optimized Stroke Text

Open alaninnovates opened this issue 1 year ago • 0 comments

In the example given in the meme.go demonstration for text with stroke width, the code inefficiently loops in an O(n^2) loop.

https://github.com/fogleman/gg/blob/8febc0f526adecda6f8ae80f3869b7cd77e52984/examples/meme.go#L15-L26

In this case, when n=6, the maximum iterations that this could use is (6*2)^2 = 144 calls to DrawStringAnchored! This is wildly inefficient and requires a lot of CPU power.

I am wondering if there is an alternative and less intensive way to create a similar text stroke effect, or if such a function could be added. Thanks!

alaninnovates avatar Feb 03 '25 07:02 alaninnovates