mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
auto merge of #5089 : mmatyas/servo/canvas_lineto, r=jdm
This patch enables the use of `lineTo()` on the canvas.
This commit is contained in:
commit
9eaa48b793
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue