How do I clear Shadowbrush

I find that shadowbrush does a nice job of adding a shadow to text, but I have run into a problem. I cannot find a command that clears further shadowbrushing. When I am working on a global buffer, it will not due to create a new buffer in the middle of the work process, nor do I want to write the buffer to the canvas and create a new one.

I have found a workaround as shown below:

buffer.graphics.shadowbrush = new shadowbrush
buffer.graphics.shadowbrush.BlurAmount = shadblur
buffer.graphics.shadowbrush.ShadowColor = shadcolor
buffer.graphics.shadowbrush.offset.x = xoffset
buffer.graphics.shadowbrush.offset.y = yoffset
buffer.graphics.drawstring s0,xc,yc
buffer.graphics.shadowbrush.offset.x = 0
buffer.graphics.shadowbrush.offset.y = 0
buffer.graphics.shadowbrush.BlurAmount=0

But that is not optimal because the shadowbrushing continues for all future drawing even though it cannot be seen. It slows things down.

So my question is, how do I clear the shadowbrush? What I seek is something like buffer.graphics.shadowbrush = off.

i think you need assign Nil
the meaning of Null = no object

buffer.graphics.shadowbrush = Nil
at the end of the sequence turns it off.

Thanks Markus!

1 Like

The code above holds 5 errors (shadblur, shadcolor, zoffset and yoffset); I commented these 5 lines, and add:

buffer.graphics.shadowbrush = Nil

after these lines, run, and click in the Button I put the code in.

No error was reported / crash, nothing.

Latest Xojo / macOS (Big Sur) / M1.

Thanks Emile,

buffer.graphics.shadowbrush = Nil

was indeed the solution.

Don‘t forget you can also use Graphics.RestoreState to revert any changes of the graphics object you made since Graphics.SaveState.

1 Like