mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Canvas: implement transformation matrix rotation.
This commit is contained in:
parent
7b87085c18
commit
e3e2119c4c
10 changed files with 15 additions and 45 deletions
|
@ -355,6 +355,20 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
|
||||||
self.update_transform()
|
self.update_transform()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-rotate
|
||||||
|
fn Rotate(self, angle: f64) {
|
||||||
|
if angle == 0.0 || !angle.is_finite() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let (sin, cos) = (angle.sin(), angle.cos());
|
||||||
|
let transform = self.state.borrow().transform;
|
||||||
|
self.state.borrow_mut().transform = transform.mul(&Matrix2D::new(cos as f32, sin as f32,
|
||||||
|
-sin as f32, cos as f32,
|
||||||
|
0.0, 0.0));
|
||||||
|
self.update_transform()
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-translate
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-translate
|
||||||
fn Translate(self, x: f64, y: f64) {
|
fn Translate(self, x: f64, y: f64) {
|
||||||
if !(x.is_finite() && y.is_finite()) {
|
if !(x.is_finite() && y.is_finite()) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ interface CanvasRenderingContext2D {
|
||||||
// transformations (default transform is the identity matrix)
|
// transformations (default transform is the identity matrix)
|
||||||
// attribute SVGMatrix currentTransform;
|
// attribute SVGMatrix currentTransform;
|
||||||
void scale(unrestricted double x, unrestricted double y);
|
void scale(unrestricted double x, unrestricted double y);
|
||||||
//void rotate(unrestricted double angle);
|
void rotate(unrestricted double angle);
|
||||||
void translate(unrestricted double x, unrestricted double y);
|
void translate(unrestricted double x, unrestricted double y);
|
||||||
void transform(unrestricted double a,
|
void transform(unrestricted double a,
|
||||||
unrestricted double b,
|
unrestricted double b,
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.transformation.order.html]
|
|
||||||
type: testharness
|
|
||||||
[Transformations are applied in the right order]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.transformation.rotate.direction.html]
|
|
||||||
type: testharness
|
|
||||||
[rotate() is clockwise]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.transformation.rotate.nonfinite.html]
|
|
||||||
type: testharness
|
|
||||||
[rotate() with Infinity/NaN is ignored]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.transformation.rotate.radians.html]
|
|
||||||
type: testharness
|
|
||||||
[rotate() uses radians]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.transformation.rotate.wrap.html]
|
|
||||||
type: testharness
|
|
||||||
[rotate() wraps large positive values correctly]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.transformation.rotate.wrapnegative.html]
|
|
||||||
type: testharness
|
|
||||||
[rotate() wraps large negative values correctly]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.transformation.rotate.zero.html]
|
|
||||||
type: testharness
|
|
||||||
[rotate() by 0 does nothing]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -6828,9 +6828,6 @@
|
||||||
[CanvasRenderingContext2D interface: attribute currentTransform]
|
[CanvasRenderingContext2D interface: attribute currentTransform]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[CanvasRenderingContext2D interface: operation rotate(unrestricted double)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[CanvasRenderingContext2D interface: operation resetTransform()]
|
[CanvasRenderingContext2D interface: operation resetTransform()]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -6960,12 +6957,6 @@
|
||||||
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "currentTransform" with the proper type (6)]
|
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "currentTransform" with the proper type (6)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "rotate" with the proper type (8)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[CanvasRenderingContext2D interface: calling rotate(unrestricted double) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "resetTransform" with the proper type (12)]
|
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "resetTransform" with the proper type (12)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue