Skip to content

Commit

Permalink
Implement Path::contains_point()
Browse files Browse the repository at this point in the history
  • Loading branch information
pylbrecht committed Aug 25, 2019
1 parent b5e1b7d commit 2a0be45
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions components/canvas/raqote_backend.rs
Expand Up @@ -11,6 +11,7 @@ use crate::canvas_paint_thread::AntialiasMode;
use canvas_traits::canvas::*;
use cssparser::RGBA;
use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D};
use raqote::PathOp;
use std::marker::PhantomData;

pub struct RaqoteBackend;
Expand Down Expand Up @@ -183,8 +184,28 @@ impl Path {
unimplemented!()
}

pub fn contains_point(&self, _x: f64, _y: f64, _path_transform: &Transform2D<f32>) -> bool {
unimplemented!()
pub fn contains_point(&self, x: f64, y: f64, _path_transform: &Transform2D<f32>) -> bool {
for op in self.as_raqote().ops.iter() {
match op {
PathOp::MoveTo(point) | PathOp::LineTo(point) => {
if point.x as f64 == x && point.y as f64 == y {
return true;
}
},
PathOp::QuadTo(_, point) => {
if point.x as f64 == x && point.y as f64 == y {
return true;
}
},
PathOp::CubicTo(_, _, point) => {
if point.x as f64 == x && point.y as f64 == y {
return true;
}
},
_ => {},
}
}
false
}

pub fn copy_to_builder(&self) -> Box<dyn GenericPathBuilder> {
Expand Down

0 comments on commit 2a0be45

Please sign in to comment.