mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:37:35 +00:00
LibGfx: Start a very basic anti-aliased Painter implementation
This can currently draw AA lines (and by proxy, AA paths), and passes all its output through a 2D affine transform to an underlying Gfx::Painter.
This commit is contained in:
parent
f4ea235a33
commit
e2cd558101
5 changed files with 364 additions and 157 deletions
34
Userland/Libraries/LibGfx/AntiAliasingPainter.h
Normal file
34
Userland/Libraries/LibGfx/AntiAliasingPainter.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGfx/Painter.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
class AntiAliasingPainter {
|
||||
public:
|
||||
explicit AntiAliasingPainter(Painter& painter)
|
||||
: m_underlying_painter(painter)
|
||||
{
|
||||
}
|
||||
|
||||
void draw_line(FloatPoint const&, FloatPoint const&, Color, float thickness = 1, Painter::LineStyle style = Painter::LineStyle::Solid, Color alternate_color = Color::Transparent);
|
||||
void fill_path(Path&, Color, Painter::WindingRule rule = Painter::WindingRule::Nonzero);
|
||||
void stroke_path(Path const&, Color, float thickness);
|
||||
void draw_quadratic_bezier_curve(FloatPoint const& control_point, FloatPoint const&, FloatPoint const&, Color, float thickness = 1, Painter::LineStyle style = Painter::LineStyle::Solid);
|
||||
void draw_elliptical_arc(FloatPoint const& p1, FloatPoint const& p2, FloatPoint const& center, FloatPoint const& radii, float x_axis_rotation, float theta_1, float theta_delta, Color, float thickness = 1, Painter::LineStyle style = Painter::LineStyle::Solid);
|
||||
|
||||
void translate(float dx, float dy) { m_transform.translate(dx, dy); }
|
||||
void translate(FloatPoint const& delta) { m_transform.translate(delta); }
|
||||
|
||||
private:
|
||||
Painter& m_underlying_painter;
|
||||
AffineTransform m_transform;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue