mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:37:44 +00:00
PaintBrush: Make spray circular.
This commit is contained in:
parent
9fa4e779ff
commit
7ccb84e58e
1 changed files with 6 additions and 5 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include <LibGUI/GPainter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <SharedGraphics/GraphicsBitmap.h>
|
#include <SharedGraphics/GraphicsBitmap.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <LibM/math.h>
|
||||||
|
|
||||||
SprayTool::SprayTool()
|
SprayTool::SprayTool()
|
||||||
{
|
{
|
||||||
|
@ -29,12 +30,12 @@ void SprayTool::paint_it()
|
||||||
auto& bitmap = m_widget->bitmap();
|
auto& bitmap = m_widget->bitmap();
|
||||||
ASSERT(bitmap.format() == GraphicsBitmap::Format::RGB32);
|
ASSERT(bitmap.format() == GraphicsBitmap::Format::RGB32);
|
||||||
m_widget->update();
|
m_widget->update();
|
||||||
const double radius = 15;
|
const double base_radius = 15;
|
||||||
for (int i = 0; i < 100 + (nrand() * 800); i++) {
|
for (int i = 0; i < 100 + (nrand() * 800); i++) {
|
||||||
const int minX = m_last_pos.x() - radius;
|
double radius = base_radius * nrand();
|
||||||
const int minY = m_last_pos.y() - radius;
|
double angle = 2 * M_PI * nrand();
|
||||||
const int xpos = minX + (radius * 2 * nrand());
|
const int xpos = m_last_pos.x() + radius * cos(angle);
|
||||||
const int ypos = minY + (radius * 2 * nrand());
|
const int ypos = m_last_pos.y() - radius * sin(angle);
|
||||||
if (xpos < 0 || xpos >= bitmap.width())
|
if (xpos < 0 || xpos >= bitmap.width())
|
||||||
continue;
|
continue;
|
||||||
if (ypos < 0 || ypos >= bitmap.height())
|
if (ypos < 0 || ypos >= bitmap.height())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue