Gradient fills in irregular shapes without using Picture Mask


so far I only know the possibility to fill shapes like Ovals or RoundRects with a color gradient using a Pictures (Mask). I wonder if this is not possible without a picture (maybe in combination with ClearRect?)? Only with a pure access to the graphics object of a canvas for example?
I’m asking because when creating x…* gradients, x…* pictures must also be created (depending on the shape) and this can drive up the RAM under certain circumstances. Does anyone have any experience or hints?

Thank you

do a FLOODFILL (rgbsurface) of a known but little used color (I use &c010101)
then create a rectangle picture object the is the max with/height of your irregular area
and do a gradient fill on it.

then scan both and everywhere you hit you special color, replace it with the corresponding pixel from the picture object

its not super fast, but the results work out quite nicely. I did a method like this in a PAINT program I wrote many years ago, it not only allowed me to do gradient fills but also patter fills (diagonal, cross hatch etc).