mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
LibGfx: Replace 'bool dotted' with a LineStyle::{Solid,Dotted} enum
Just a bool is insufficient as we'll have to support dashed lines as well.
This commit is contained in:
parent
da42279171
commit
59d00e5df6
3 changed files with 21 additions and 11 deletions
|
@ -966,7 +966,7 @@ void Painter::draw_pixel(const Point& position, Color color, int thickness)
|
|||
fill_rect(rect.translated(-state().translation), color);
|
||||
}
|
||||
|
||||
void Painter::draw_line(const Point& p1, const Point& p2, Color color, int thickness, bool dotted)
|
||||
void Painter::draw_line(const Point& p1, const Point& p2, Color color, int thickness, LineStyle style)
|
||||
{
|
||||
auto clip_rect = this->clip_rect();
|
||||
|
||||
|
@ -989,7 +989,7 @@ void Painter::draw_line(const Point& p1, const Point& p2, Color color, int thick
|
|||
return;
|
||||
int min_y = max(point1.y(), clip_rect.top());
|
||||
int max_y = min(point2.y(), clip_rect.bottom());
|
||||
if (dotted) {
|
||||
if (style == LineStyle::Dotted) {
|
||||
for (int y = min_y; y <= max_y; y += thickness * 2)
|
||||
draw_pixel({ x, y }, color, thickness);
|
||||
} else {
|
||||
|
@ -1012,7 +1012,7 @@ void Painter::draw_line(const Point& p1, const Point& p2, Color color, int thick
|
|||
return;
|
||||
int min_x = max(point1.x(), clip_rect.left());
|
||||
int max_x = min(point2.x(), clip_rect.right());
|
||||
if (dotted) {
|
||||
if (style == LineStyle::Dotted) {
|
||||
for (int x = min_x; x <= max_x; x += thickness * 2)
|
||||
draw_pixel({ x, y }, color, thickness);
|
||||
} else {
|
||||
|
@ -1023,7 +1023,7 @@ void Painter::draw_line(const Point& p1, const Point& p2, Color color, int thick
|
|||
}
|
||||
|
||||
// FIXME: Implement dotted diagonal lines.
|
||||
ASSERT(!dotted);
|
||||
ASSERT(style == LineStyle::Solid);
|
||||
|
||||
const double adx = abs(point2.x() - point1.x());
|
||||
const double ady = abs(point2.y() - point1.y());
|
||||
|
@ -1116,10 +1116,10 @@ void Painter::for_each_line_segment_on_bezier_curve(const FloatPoint& control_po
|
|||
for_each_line_segment_on_bezier_curve(control_point, p1, p2, callback);
|
||||
}
|
||||
|
||||
void Painter::draw_quadratic_bezier_curve(const Point& control_point, const Point& p1, const Point& p2, Color color, int thickness, bool dotted)
|
||||
void Painter::draw_quadratic_bezier_curve(const Point& control_point, const Point& p1, const Point& p2, Color color, int thickness, LineStyle style)
|
||||
{
|
||||
for_each_line_segment_on_bezier_curve(FloatPoint(control_point.x(), control_point.y()), FloatPoint(p1.x(), p1.y()), FloatPoint(p2.x(), p2.y()), [&](const FloatPoint& p1, const FloatPoint& p2) {
|
||||
draw_line(Point(p1.x(), p1.y()), Point(p2.x(), p2.y()), color, thickness, dotted);
|
||||
draw_line(Point(p1.x(), p1.y()), Point(p2.x(), p2.y()), color, thickness, style);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1263,7 +1263,7 @@ void Painter::fill_path(Path& path, Color color, WindingRule winding_rule)
|
|||
#ifdef FILL_PATH_DEBUG
|
||||
dbg() << "y=" << scanline << ": " << winding_number << " at " << i << ": " << from << " -- " << to;
|
||||
#endif
|
||||
draw_line(from, to, color, 1, false);
|
||||
draw_line(from, to, color, 1);
|
||||
}
|
||||
|
||||
skip_drawing:;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue