mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Canvas: implement quadraticCurveTo().
This commit is contained in:
parent
7bd6cb0091
commit
2817f2e066
7 changed files with 19 additions and 13 deletions
|
@ -28,6 +28,7 @@ pub enum CanvasMsg {
|
|||
Fill,
|
||||
MoveTo(Point2D<f32>),
|
||||
LineTo(Point2D<f32>),
|
||||
QuadraticCurveTo(Point2D<f32>, Point2D<f32>),
|
||||
BezierCurveTo(Point2D<f32>, Point2D<f32>, Point2D<f32>),
|
||||
Arc(Point2D<f32>, f32, f32, f32, bool),
|
||||
SetFillStyle(FillOrStrokeStyle),
|
||||
|
@ -80,6 +81,9 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
CanvasMsg::Fill => painter.fill(),
|
||||
CanvasMsg::MoveTo(ref point) => painter.move_to(point),
|
||||
CanvasMsg::LineTo(ref point) => painter.line_to(point),
|
||||
CanvasMsg::QuadraticCurveTo(ref cp, ref pt) => {
|
||||
painter.quadratic_curve_to(cp, pt)
|
||||
}
|
||||
CanvasMsg::BezierCurveTo(ref cp1, ref cp2, ref pt) => {
|
||||
painter.bezier_curve_to(cp1, cp2, pt)
|
||||
}
|
||||
|
@ -150,6 +154,12 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
self.path_builder.line_to(*point)
|
||||
}
|
||||
|
||||
fn quadratic_curve_to(&self,
|
||||
cp: &Point2D<AzFloat>,
|
||||
endpoint: &Point2D<AzFloat>) {
|
||||
self.path_builder.quadratic_curve_to(cp, endpoint)
|
||||
}
|
||||
|
||||
fn bezier_curve_to(&self,
|
||||
cp1: &Point2D<AzFloat>,
|
||||
cp2: &Point2D<AzFloat>,
|
||||
|
|
|
@ -154,6 +154,11 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
|
|||
self.renderer.send(CanvasMsg::LineTo(Point2D(x as f32, y as f32))).unwrap();
|
||||
}
|
||||
|
||||
fn QuadraticCurveTo(self, cpx: f64, cpy: f64, x: f64, y: f64) {
|
||||
self.renderer.send(CanvasMsg::QuadraticCurveTo(Point2D(cpx as f32, cpy as f32),
|
||||
Point2D(x as f32, y as f32))).unwrap();
|
||||
}
|
||||
|
||||
fn BezierCurveTo(self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, x: f64, y: f64) {
|
||||
self.renderer.send(CanvasMsg::BezierCurveTo(Point2D(cp1x as f32, cp1y as f32),
|
||||
Point2D(cp2x as f32, cp2y as f32),
|
||||
|
|
|
@ -124,7 +124,7 @@ interface CanvasPathMethods {
|
|||
void closePath();
|
||||
void moveTo(/*unrestricted*/ double x, /*unrestricted*/ double y);
|
||||
void lineTo(double x, double y);
|
||||
//void quadraticCurveTo(double cpx, double cpy, double x, double y);
|
||||
void quadraticCurveTo(double cpx, double cpy, double x, double y);
|
||||
|
||||
void bezierCurveTo(/*unrestricted*/ double cp1x,
|
||||
/*unrestricted*/ double cp1y,
|
||||
|
|
2
components/servo/Cargo.lock
generated
2
components/servo/Cargo.lock
generated
|
@ -36,7 +36,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "azure"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-azure#3fa95e4ce2c12234e75b7a68b1a2542e3804b67c"
|
||||
source = "git+https://github.com/servo/rust-azure#110b98c7d39a275513c654644311f26b7eb75580"
|
||||
dependencies = [
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
|
||||
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
|
||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -39,7 +39,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "azure"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-azure#3fa95e4ce2c12234e75b7a68b1a2542e3804b67c"
|
||||
source = "git+https://github.com/servo/rust-azure#110b98c7d39a275513c654644311f26b7eb75580"
|
||||
dependencies = [
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
|
||||
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
|
||||
|
|
2
ports/gonk/Cargo.lock
generated
2
ports/gonk/Cargo.lock
generated
|
@ -23,7 +23,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "azure"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-azure#3fa95e4ce2c12234e75b7a68b1a2542e3804b67c"
|
||||
source = "git+https://github.com/servo/rust-azure#110b98c7d39a275513c654644311f26b7eb75580"
|
||||
dependencies = [
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
|
||||
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
|
||||
|
|
|
@ -7116,9 +7116,6 @@
|
|||
[CanvasRenderingContext2D interface: attribute direction]
|
||||
expected: FAIL
|
||||
|
||||
[CanvasRenderingContext2D interface: operation quadraticCurveTo(unrestricted double,unrestricted double,unrestricted double,unrestricted double)]
|
||||
expected: FAIL
|
||||
|
||||
[CanvasRenderingContext2D interface: operation arcTo(unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -7374,12 +7371,6 @@
|
|||
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "direction" with the proper type (69)]
|
||||
expected: FAIL
|
||||
|
||||
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "quadraticCurveTo" with the proper type (73)]
|
||||
expected: FAIL
|
||||
|
||||
[CanvasRenderingContext2D interface: calling quadraticCurveTo(unrestricted double,unrestricted double,unrestricted double,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 "arcTo" with the proper type (75)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue