How to erase a section of Graphics

How to erase a section of Graphics
0.0 0


Is there anyway to erase a part of a drawing made on a graphics component?


I need that too, but I afraid that “clear and redraw” is the only solution.


You might be able to achieve this by setting a different blend mode – you want to replace existing colours with a section of graphics having alpha 0.

Using a blend mode of {GL_ONE, GL_ZERO} (also called DISABLE) means ignore the colour already set at the destination and set the colour you want. After this, you can simply draw the area you want to erase with alpha 0.

Untested, but I suspect you can do something like (this is with the C++ API):

auto prevBlendFunc = drawNode->getBlendFunc();
drawNode->setBlendFunc( {GL_ONE, GL_ZERO} );
drawNode->drawPoint( {0, 0}, 100, {0, 0, 0, 0} ); // Replace whichever shape you need
drawNode->setBlendFunc( prevBlendFunc );