mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibWeb: Add spec comments to canvas context2d rect
This commit is contained in:
parent
573a2619a5
commit
9997d8f178
3 changed files with 17 additions and 8 deletions
|
@ -192,16 +192,25 @@ WebIDL::ExceptionOr<void> CanvasPath::arc_to(double x1, double y1, double x2, do
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasPath::rect(float x, float y, float width, float height)
|
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-rect
|
||||||
|
void CanvasPath::rect(double x, double y, double w, double h)
|
||||||
{
|
{
|
||||||
|
// 1. If any of the arguments are infinite or NaN, then return.
|
||||||
|
if (!isfinite(x) || !isfinite(y) || !isfinite(w) || !isfinite(h))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 2. Create a new subpath containing just the four points (x, y), (x+w, y), (x+w, y+h), (x, y+h), in that order, with those four points connected by straight lines.
|
||||||
auto transform = active_transform();
|
auto transform = active_transform();
|
||||||
m_path.move_to(transform.map(Gfx::FloatPoint { x, y }));
|
m_path.move_to(transform.map(Gfx::FloatPoint { x, y }));
|
||||||
if (width == 0 || height == 0)
|
m_path.line_to(transform.map(Gfx::FloatPoint { x + w, y }));
|
||||||
return;
|
m_path.line_to(transform.map(Gfx::FloatPoint { x + w, y + h }));
|
||||||
m_path.line_to(transform.map(Gfx::FloatPoint { x + width, y }));
|
m_path.line_to(transform.map(Gfx::FloatPoint { x, y + h }));
|
||||||
m_path.line_to(transform.map(Gfx::FloatPoint { x + width, y + height }));
|
|
||||||
m_path.line_to(transform.map(Gfx::FloatPoint { x, y + height }));
|
// 3. Mark the subpath as closed.
|
||||||
m_path.close();
|
m_path.close();
|
||||||
|
|
||||||
|
// 4. Create a new subpath with the point (x, y) as the only point in the subpath.
|
||||||
|
m_path.move_to(transform.map(Gfx::FloatPoint { x, y }));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
void quadratic_curve_to(float cx, float cy, float x, float y);
|
void quadratic_curve_to(float cx, float cy, float x, float y);
|
||||||
void bezier_curve_to(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
|
void bezier_curve_to(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
|
||||||
WebIDL::ExceptionOr<void> arc_to(double x1, double y1, double x2, double y2, double radius);
|
WebIDL::ExceptionOr<void> arc_to(double x1, double y1, double x2, double y2, double radius);
|
||||||
void rect(float x, float y, float width, float height);
|
void rect(double x, double y, double w, double h);
|
||||||
WebIDL::ExceptionOr<void> arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise);
|
WebIDL::ExceptionOr<void> arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise);
|
||||||
WebIDL::ExceptionOr<void> ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise);
|
WebIDL::ExceptionOr<void> ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ interface mixin CanvasPath {
|
||||||
undefined quadraticCurveTo(unrestricted double cpx, unrestricted double cpy, unrestricted double x, unrestricted double y);
|
undefined quadraticCurveTo(unrestricted double cpx, unrestricted double cpy, unrestricted double x, unrestricted double y);
|
||||||
undefined bezierCurveTo(unrestricted double cp1x, unrestricted double cp1y, unrestricted double cp2x, unrestricted double cp2y, unrestricted double x, unrestricted double y);
|
undefined bezierCurveTo(unrestricted double cp1x, unrestricted double cp1y, unrestricted double cp2x, unrestricted double cp2y, unrestricted double x, unrestricted double y);
|
||||||
undefined arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);
|
undefined arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);
|
||||||
undefined rect(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height);
|
undefined rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
|
||||||
// FIXME: undefined roundRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h, optional (unrestricted double or DOMPointInit or sequence<(unrestricted double or DOMPointInit)>) radii = 0);
|
// FIXME: undefined roundRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h, optional (unrestricted double or DOMPointInit or sequence<(unrestricted double or DOMPointInit)>) radii = 0);
|
||||||
undefined arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean counterclockwise = false);
|
undefined arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean counterclockwise = false);
|
||||||
undefined ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, optional boolean counterclockwise = false);
|
undefined ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, optional boolean counterclockwise = false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue