Closed Forairaaaaa closed 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 :
drawGradient*
functions are considered as "intruders" in the Base Class because they only support RGB-based color depths (try to draw a gradient in a sprite with colorDepth 4, 2 or 1 and you'll see what I mean)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);
// ...
}
I got the idea, thanks again~
Hi! I took @tobozo's advices from previous issue to render by line. I try to add 4 apis and run some tests:
drawFastHLineInDifference
fillRectInDifference
fillSmoothRoundRectInDifference
fillSmoothCircleInDifference
Hope this is useful, thanks~