linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.24k stars 93 forks source link

Rework dash representation in StrokeStyle #438

Closed cmyr closed 3 years ago

cmyr commented 3 years ago

This is all about ergonomics. I have two goals: to allow StrokeStyle to be created in a const context, and to make StrokeStyle cheaply cloneable.

This was a giant headache. I tried a Cow, but that didn't work, because you can't set it in a const context, because it might call a destructor.

This solution hacks around that. We have separate fields for the const and non-const case; the non-const case overrides the const case, but in practice they are unlikely to be used together.