summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Applications/PixelPaint')
-rw-r--r--Userland/Applications/PixelPaint/BrushTool.cpp2
-rw-r--r--Userland/Applications/PixelPaint/FilterParams.h4
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.cpp7
-rw-r--r--Userland/Applications/PixelPaint/LineTool.cpp10
-rw-r--r--Userland/Applications/PixelPaint/SprayTool.cpp2
5 files changed, 13 insertions, 12 deletions
diff --git a/Userland/Applications/PixelPaint/BrushTool.cpp b/Userland/Applications/PixelPaint/BrushTool.cpp
index df0eec7acc..66638da0f3 100644
--- a/Userland/Applications/PixelPaint/BrushTool.cpp
+++ b/Userland/Applications/PixelPaint/BrushTool.cpp
@@ -82,7 +82,7 @@ void BrushTool::draw_point(Gfx::Bitmap& bitmap, const Gfx::Color& color, const G
if (distance >= m_size)
continue;
- auto falloff = (1.0 - (distance / (float)m_size)) * (1.0f / (100 - m_hardness));
+ auto falloff = (1.0 - double { distance / m_size }) * (1.0 / (100 - m_hardness));
auto pixel_color = color;
pixel_color.set_alpha(falloff * 255);
bitmap.set_pixel(x, y, bitmap.get_pixel(x, y).blend(pixel_color));
diff --git a/Userland/Applications/PixelPaint/FilterParams.h b/Userland/Applications/PixelPaint/FilterParams.h
index 398caecf9f..8440d27e5c 100644
--- a/Userland/Applications/PixelPaint/FilterParams.h
+++ b/Userland/Applications/PixelPaint/FilterParams.h
@@ -127,8 +127,8 @@ struct FilterParameters<Gfx::SpatialGaussianBlurFilter<N>> {
for (auto x = -offset; x <= offset; x++) {
for (auto y = -offset; y <= offset; y++) {
- auto r = sqrt(x * x + y * y);
- kernel.elements()[x + offset][y + offset] = (exp(-(r * r) / s)) / (M_PI * s);
+ auto r = sqrtf(x * x + y * y);
+ kernel.elements()[x + offset][y + offset] = (expf(-(r * r) / s)) / (float { M_PI } * s);
}
}
diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp
index 0198b49eca..e91cbcf275 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.cpp
+++ b/Userland/Applications/PixelPaint/ImageEditor.cpp
@@ -380,9 +380,10 @@ void ImageEditor::scale_centered_on_position(const Gfx::IntPoint& position, floa
if (m_scale > 100.0f)
m_scale = 100.0f;
- auto focus_point = Gfx::FloatPoint(
- m_pan_origin.x() - ((float)position.x() - (float)width() / 2.0) / old_scale,
- m_pan_origin.y() - ((float)position.y() - (float)height() / 2.0) / old_scale);
+ Gfx::FloatPoint focus_point {
+ m_pan_origin.x() - (position.x() - width() / 2.0f) / old_scale,
+ m_pan_origin.y() - (position.y() - height() / 2.0f) / old_scale
+ };
m_pan_origin = Gfx::FloatPoint(
focus_point.x() - m_scale / old_scale * (focus_point.x() - m_pan_origin.x()),
diff --git a/Userland/Applications/PixelPaint/LineTool.cpp b/Userland/Applications/PixelPaint/LineTool.cpp
index 7c3e37e836..2f5738872a 100644
--- a/Userland/Applications/PixelPaint/LineTool.cpp
+++ b/Userland/Applications/PixelPaint/LineTool.cpp
@@ -36,15 +36,15 @@ namespace PixelPaint {
static Gfx::IntPoint constrain_line_angle(const Gfx::IntPoint& start_pos, const Gfx::IntPoint& end_pos, float angle_increment)
{
- float current_angle = atan2(end_pos.y() - start_pos.y(), end_pos.x() - start_pos.x()) + M_PI * 2.;
+ float current_angle = atan2f(end_pos.y() - start_pos.y(), end_pos.x() - start_pos.x()) + float { M_PI * 2 };
- float constrained_angle = ((int)((current_angle + angle_increment / 2.) / angle_increment)) * angle_increment;
+ float constrained_angle = ((int)((current_angle + angle_increment / 2) / angle_increment)) * angle_increment;
auto diff = end_pos - start_pos;
float line_length = sqrt(diff.x() * diff.x() + diff.y() * diff.y());
- return { start_pos.x() + (int)(cos(constrained_angle) * line_length),
- start_pos.y() + (int)(sin(constrained_angle) * line_length) };
+ return { start_pos.x() + (int)(cosf(constrained_angle) * line_length),
+ start_pos.y() + (int)(sinf(constrained_angle) * line_length) };
}
LineTool::LineTool()
@@ -90,7 +90,7 @@ void LineTool::on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEven
if (!m_constrain_angle) {
m_line_end_position = layer_event.position();
} else {
- const float ANGLE_STEP = M_PI / 8.0f;
+ constexpr auto ANGLE_STEP = M_PI / 8;
m_line_end_position = constrain_line_angle(m_line_start_position, layer_event.position(), ANGLE_STEP);
}
m_editor->update();
diff --git a/Userland/Applications/PixelPaint/SprayTool.cpp b/Userland/Applications/PixelPaint/SprayTool.cpp
index 51d5a7e83b..523a7a0850 100644
--- a/Userland/Applications/PixelPaint/SprayTool.cpp
+++ b/Userland/Applications/PixelPaint/SprayTool.cpp
@@ -70,7 +70,7 @@ void SprayTool::paint_it()
m_editor->update();
const double minimal_radius = 2;
const double base_radius = minimal_radius * m_thickness;
- for (int i = 0; i < M_PI * base_radius * base_radius * (m_density / 100.0f); i++) {
+ for (int i = 0; i < M_PI * base_radius * base_radius * (m_density / 100.0); i++) {
double radius = base_radius * nrand();
double angle = 2 * M_PI * nrand();
const int xpos = m_last_pos.x() + radius * cos(angle);