mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibWeb: Add CanvasPath arcTo support
Adds initial CanvasPath arcTo support for 2D rendering contexts https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-arcto
This commit is contained in:
parent
7cb80c67d8
commit
9a61041941
5 changed files with 94 additions and 7 deletions
|
@ -72,11 +72,7 @@ void Path::elliptical_arc_to(FloatPoint point, FloatSize radii, float x_axis_rot
|
|||
double x_axis_rotation_s;
|
||||
double x_axis_rotation_c;
|
||||
AK::sincos(static_cast<double>(x_axis_rotation), x_axis_rotation_s, x_axis_rotation_c);
|
||||
|
||||
// Find the last point
|
||||
FloatPoint last_point { 0, 0 };
|
||||
if (!m_segments.is_empty())
|
||||
last_point = m_segments.last()->point();
|
||||
FloatPoint last_point = this->last_point();
|
||||
|
||||
// Step 1 of out-of-range radii correction
|
||||
if (rx == 0.0 || ry == 0.0) {
|
||||
|
@ -160,6 +156,13 @@ void Path::elliptical_arc_to(FloatPoint point, FloatSize radii, float x_axis_rot
|
|||
theta_1,
|
||||
theta_delta);
|
||||
}
|
||||
FloatPoint Path::last_point()
|
||||
{
|
||||
FloatPoint last_point { 0, 0 };
|
||||
if (!m_segments.is_empty())
|
||||
last_point = m_segments.last()->point();
|
||||
return last_point;
|
||||
}
|
||||
|
||||
void Path::close()
|
||||
{
|
||||
|
@ -383,6 +386,14 @@ void Path::add_path(Path const& other)
|
|||
invalidate_split_lines();
|
||||
}
|
||||
|
||||
void Path::ensure_subpath(FloatPoint point)
|
||||
{
|
||||
if (m_need_new_subpath && m_segments.is_empty()) {
|
||||
move_to(point);
|
||||
m_need_new_subpath = false;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct RoundTrip {
|
||||
RoundTrip(ReadonlySpan<T> span)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue