mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Canvas: added lineTo().
This commit is contained in:
parent
fed878710c
commit
774cc4a93a
14 changed files with 60 additions and 45 deletions
|
@ -27,6 +27,7 @@ pub enum CanvasMsg {
|
|||
ClosePath,
|
||||
Fill,
|
||||
MoveTo(Point2D<f32>),
|
||||
LineTo(Point2D<f32>),
|
||||
BezierCurveTo(Point2D<f32>, Point2D<f32>, Point2D<f32>),
|
||||
SetFillStyle(FillOrStrokeStyle),
|
||||
SetStrokeStyle(FillOrStrokeStyle),
|
||||
|
@ -77,6 +78,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
CanvasMsg::ClosePath => painter.close_path(),
|
||||
CanvasMsg::Fill => painter.fill(),
|
||||
CanvasMsg::MoveTo(ref point) => painter.move_to(point),
|
||||
CanvasMsg::LineTo(ref point) => painter.line_to(point),
|
||||
CanvasMsg::BezierCurveTo(ref cp1, ref cp2, ref pt) => {
|
||||
painter.bezier_curve_to(cp1, cp2, pt)
|
||||
}
|
||||
|
@ -140,6 +142,10 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
self.path_builder.move_to(*point)
|
||||
}
|
||||
|
||||
fn line_to(&self, point: &Point2D<AzFloat>) {
|
||||
self.path_builder.line_to(*point)
|
||||
}
|
||||
|
||||
fn bezier_curve_to(&self,
|
||||
cp1: &Point2D<AzFloat>,
|
||||
cp2: &Point2D<AzFloat>,
|
||||
|
|
|
@ -150,6 +150,10 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
|
|||
self.renderer.send(CanvasMsg::MoveTo(Point2D(x as f32, y as f32))).unwrap();
|
||||
}
|
||||
|
||||
fn LineTo(self, x: f64, y: f64) {
|
||||
self.renderer.send(CanvasMsg::LineTo(Point2D(x as f32, y as f32)));
|
||||
}
|
||||
|
||||
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),
|
||||
|
|
|
@ -123,7 +123,7 @@ interface CanvasPathMethods {
|
|||
// shared path API methods
|
||||
void closePath();
|
||||
void moveTo(/*unrestricted*/ double x, /*unrestricted*/ double y);
|
||||
//void lineTo(double x, double y);
|
||||
void lineTo(double x, double y);
|
||||
//void quadraticCurveTo(double cpx, double cpy, double x, double y);
|
||||
|
||||
void bezierCurveTo(/*unrestricted*/ double cp1x,
|
||||
|
|
|
@ -251,5 +251,6 @@ fragment=top != ../html/acid2.html acid2_ref.html
|
|||
== text_align_complex_a.html text_align_complex_ref.html
|
||||
== percentage_height_root.html percentage_height_root_ref.html
|
||||
== canvas_transform_a.html canvas_transform_ref.html
|
||||
== canvas_lineto_a.html canvas_lineto_ref.html
|
||||
!= text_decoration_smoke_a.html text_decoration_smoke_ref.html
|
||||
== hide_after_create.html hide_after_create_ref.html
|
||||
|
|
29
tests/ref/canvas_lineto_a.html
Normal file
29
tests/ref/canvas_lineto_a.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
<canvas id="c" width="150" height="150" >
|
||||
Your browser does not support the HTML5 canvas tag.</canvas>
|
||||
|
||||
<script>
|
||||
var c = document.getElementById("c");
|
||||
var ctx = c.getContext("2d");
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(20, 20);
|
||||
ctx.lineTo(20, 130);
|
||||
ctx.lineTo(130, 130);
|
||||
ctx.lineTo(130, 20);
|
||||
ctx.closePath();
|
||||
|
||||
ctx.fillStyle = '#90EE90';
|
||||
ctx.fill();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
19
tests/ref/canvas_lineto_ref.html
Normal file
19
tests/ref/canvas_lineto_ref.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
div {
|
||||
background: #90EE90;
|
||||
width: 110px;
|
||||
height: 110px;
|
||||
margin: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div></div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +0,0 @@
|
|||
[2d.path.fill.closed.basic.html]
|
||||
type: testharness
|
||||
[Canvas test: 2d.path.fill.closed.basic]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[2d.path.fill.winding.add.html]
|
||||
type: testharness
|
||||
[Canvas test: 2d.path.fill.winding.add]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[2d.path.fill.winding.subtract.1.html]
|
||||
type: testharness
|
||||
[Canvas test: 2d.path.fill.winding.subtract.1]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[2d.path.fill.winding.subtract.2.html]
|
||||
type: testharness
|
||||
[Canvas test: 2d.path.fill.winding.subtract.2]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[2d.path.fill.winding.subtract.3.html]
|
||||
type: testharness
|
||||
[Canvas test: 2d.path.fill.winding.subtract.3]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[2d.transformation.setTransform.skewed.html]
|
||||
type: testharness
|
||||
[Canvas test: 2d.transformation.setTransform.skewed]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[2d.transformation.transform.skewed.html]
|
||||
type: testharness
|
||||
[transform() with skewy matrix transforms correctly]
|
||||
expected: FAIL
|
||||
|
|
@ -7116,9 +7116,6 @@
|
|||
[CanvasRenderingContext2D interface: attribute direction]
|
||||
expected: FAIL
|
||||
|
||||
[CanvasRenderingContext2D interface: operation lineTo(unrestricted double,unrestricted double)]
|
||||
expected: FAIL
|
||||
|
||||
[CanvasRenderingContext2D interface: operation quadraticCurveTo(unrestricted double,unrestricted double,unrestricted double,unrestricted double)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -7377,12 +7374,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 "lineTo" with the proper type (72)]
|
||||
expected: FAIL
|
||||
|
||||
[CanvasRenderingContext2D interface: calling lineTo(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 "quadraticCurveTo" with the proper type (73)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue