moononournation / Arduino_GFX

Arduino GFX developing for various color displays and various data bus interfaces
Other
807 stars 158 forks source link

General Question: Clipping #448

Closed flyandi closed 6 months ago

flyandi commented 7 months ago

This is a general question but is there a way to "clip" a rectangular area. Like when I have text and want to be cut off in a specific area.

Like this example:

image

I can always paint over but wanted to see if this is generally possible with just the standard methods.

I don't think the Canvas classes were designed for that.

flyandi commented 6 months ago

Well I figured it out.

ezgif-2-f32079ef85

The key was to invoke the canvas without starting the output aka:


 Arduino_GFX* ctx = new Arduino_Canvas_Indexed(bf.w, bf.h, gfx, bf.x, bf.y);

  ctx->begin(GFX_SKIP_OUTPUT_BEGIN);```