lovyan03 / LovyanGFX

SPI LCD graphics library for ESP32 (ESP-IDF/ArduinoESP32) / ESP8266 (ArduinoESP8266) / SAMD51(Seeed ArduinoSAMD51)
Other
1.03k stars 189 forks source link

Add some fill apis layer in difference mode #473

Closed Forairaaaaa closed 6 months ago

Forairaaaaa commented 6 months ago

Hi! I took @tobozo's advices from previous issue to render by line. I try to add 4 apis and run some tests:

ezgif com-video-to-gif ezgif com-video-to-gif (1) ezgif com-video-to-gif (2)

Hope this is useful, thanks~

tobozo commented 6 months ago

awesome effect! thanks for sharing :+1:

some thoughts:

high level drawing functions are better off the LGFX_Base class, although it's useful, very well written and documented, it's unlikely this PR will be accepted.

the reasons are multiple :

maybe it's time to create some LovyanGFX-affiliate repository to store community contributions such as yours, I can't make that decision as I'm not the repository owner but it could be worth starting a discussion on that topic

until such thing happens, one way to share your FX code without integrating into the main class is to use inheritance in a separate hpp file that can be optionnally loaded as I did in this example.

class LGFX_SpriteFx : public LGFX_Sprite
{
  public:

    LGFX_SpriteFx(LovyanGFX* parent) : LGFX_Sprite(parent) { };
    /// ...
}

the other "uglier" way to stay outside LGFX_Base and even drop inheritance is to add LovyanGFX* object as first argument to the FX functions and eventually use a cpp template for color types:

  template <typename COLOR>
  void myFXFunction( LovyanGFX* gfx, int32_t x, int32_t y, uint32_t w, uint32_t h, COLOR color )
  {
    assert(gfx);
    // ...
  }
Forairaaaaa commented 6 months ago

I got the idea, thanks again~