mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 20:07:34 +00:00
LibWeb: Implement CanvasRenderingContext2D.transform
This commit is contained in:
parent
40f584a2bb
commit
df7a83ac0e
3 changed files with 19 additions and 0 deletions
|
@ -691,6 +691,20 @@ NonnullRefPtr<CanvasGradient> CanvasRenderingContext2D::create_conic_gradient(do
|
||||||
return CanvasGradient::create_conic(start_angle, x, y);
|
return CanvasGradient::create_conic(start_angle, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-transform
|
||||||
|
void CanvasRenderingContext2D::transform(double a, double b, double c, double d, double e, double f)
|
||||||
|
{
|
||||||
|
// 1. If any of the arguments are infinite or NaN, then return.
|
||||||
|
if (!isfinite(a) || !isfinite(b) || !isfinite(c) || !isfinite(d) || !isfinite(e) || !isfinite(f))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 2. Replace the current transformation matrix with the result of multiplying the current transformation matrix with the matrix described by:
|
||||||
|
// a c e
|
||||||
|
// b d f
|
||||||
|
// 0 0 1
|
||||||
|
m_drawing_state.transform.multiply({ static_cast<float>(a), static_cast<float>(b), static_cast<float>(c), static_cast<float>(d), static_cast<float>(e), static_cast<float>(f) });
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument
|
// https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument
|
||||||
DOM::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImageSource const& image)
|
DOM::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImageSource const& image)
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,6 +98,8 @@ public:
|
||||||
NonnullRefPtr<CanvasGradient> create_linear_gradient(double x0, double y0, double x1, double y1);
|
NonnullRefPtr<CanvasGradient> create_linear_gradient(double x0, double y0, double x1, double y1);
|
||||||
NonnullRefPtr<CanvasGradient> create_conic_gradient(double start_angle, double x, double y);
|
NonnullRefPtr<CanvasGradient> create_conic_gradient(double start_angle, double x, double y);
|
||||||
|
|
||||||
|
void transform(double a, double b, double c, double d, double e, double f);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit CanvasRenderingContext2D(HTMLCanvasElement&);
|
explicit CanvasRenderingContext2D(HTMLCanvasElement&);
|
||||||
|
|
||||||
|
|
|
@ -55,4 +55,7 @@ interface CanvasRenderingContext2D {
|
||||||
CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
|
CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
|
||||||
CanvasGradient createConicGradient(double startAngle, double x, double y);
|
CanvasGradient createConicGradient(double startAngle, double x, double y);
|
||||||
|
|
||||||
|
// FIXME: All these `double`s should be `unrestricted double`
|
||||||
|
undefined transform(double a, double b, double c, double d, double e, double f);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue