mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
LibWeb: Implement CanvasRenderingContext2D.setTransform
This commit is contained in:
parent
df7a83ac0e
commit
329e740c85
3 changed files with 16 additions and 0 deletions
|
@ -705,6 +705,20 @@ void CanvasRenderingContext2D::transform(double a, double b, double c, double d,
|
||||||
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) });
|
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#dom-context-2d-settransform
|
||||||
|
void CanvasRenderingContext2D::set_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. Reset the current transformation matrix to the identity matrix.
|
||||||
|
m_drawing_state.transform = {};
|
||||||
|
|
||||||
|
// 3. Invoke the transform(a, b, c, d, e, f) method with the same arguments.
|
||||||
|
transform(a, b, c, d, e, 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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -99,6 +99,7 @@ public:
|
||||||
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);
|
void transform(double a, double b, double c, double d, double e, double f);
|
||||||
|
void set_transform(double a, double b, double c, double d, double e, double f);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit CanvasRenderingContext2D(HTMLCanvasElement&);
|
explicit CanvasRenderingContext2D(HTMLCanvasElement&);
|
||||||
|
|
|
@ -57,5 +57,6 @@ interface CanvasRenderingContext2D {
|
||||||
|
|
||||||
// FIXME: All these `double`s should be `unrestricted double`
|
// FIXME: All these `double`s should be `unrestricted double`
|
||||||
undefined transform(double a, double b, double c, double d, double e, double f);
|
undefined transform(double a, double b, double c, double d, double e, double f);
|
||||||
|
undefined setTransform(double a, double b, double c, double d, double e, double f);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue