mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Implement Path::contains_point()
This commit is contained in:
parent
b5e1b7dc48
commit
2a0be451ae
1 changed files with 23 additions and 2 deletions
|
@ -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;
|
||||
|
@ -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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue