path_kit/point.rs
1//! 二维点 (x, y)。2D point with x and y coordinates.
2
3use crate::bridge::ffi;
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 ffi::Point {
22 fn from(p: Point) -> Self {
23 ffi::Point {
24 fX: p.x,
25 fY: p.y,
26 }
27 }
28}
29
30impl From<ffi::Point> for Point {
31 fn from(p: ffi::Point) -> Self {
32 Self { x: p.fX, y: p.fY }
33 }
34}