1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:57:46 +00:00

PixelPaint: Refactor falloff computation and extend hardness range

This commit is contained in:
r00ster91 2021-12-18 20:33:38 +01:00 committed by Brian Gianforcaro
parent 7fae46361b
commit b6d921f682
4 changed files with 14 additions and 7 deletions

View file

@ -28,6 +28,12 @@ public:
void set_hardness(int hardness) { m_hardness = hardness; }
int hardness() const { return m_hardness; }
double get_falloff(double distance)
{
double multiplicand = hardness() == 100 ? 1.0 : 1.0 / (100 - hardness());
return (1.0 - double { distance / size() }) * multiplicand;
}
protected:
virtual Color color_for(GUI::MouseEvent const& event);
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point);