path_kit/point.rs
1//! 二维点 (x, y)。2D point with x and y coordinates.
2
3use crate::pathkit;
4
5/// 二维点。A 2D point with x and y coordinates.
6#[derive(Debug, Clone, Copy, PartialEq)]
7pub struct Point {
8 /// X 坐标 / X coordinate
9 pub x: f32,
10 /// Y 坐标 / Y coordinate
11 pub y: f32,
12}
13
14impl Point {
15 /// 创建点。Creates a point at (x, y).
16 pub const fn new(x: f32, y: f32) -> Self {
17 Self { x, y }
18 }
19}
20
21impl From<Point> for pathkit::SkPoint {
22 fn from(p: Point) -> Self {
23 pathkit::SkPoint { fX: p.x, fY: p.y }
24 }
25}
26
27impl From<pathkit::SkPoint> for Point {
28 fn from(p: pathkit::SkPoint) -> Self {
29 Self { x: p.fX, y: p.fY }
30 }
31}