I was wondering if it would be possible to cache the CGShadingRef used in drawGradient when calling setFillType (eventually lazy evaluation if you don’t want to compute it there)
Currently if call multiple DrawLine with a gradient, it ends up being recomputed way to much times.
I did have a quick look, but it’s far more complicated that it seems, because there are callback functions and a stack of saved context states to worry about, so I chickened out. Have a go yourself if you want to, but I realised I was probably going to end up spending several hours getting it to work, and didn’t have time to do that.