polyhorn_ios_sys/coregraphics/geometry.rs
1use super::CGFloat;
2
3/// A structure that contains a point in a two-dimensional coordinate system.
4#[repr(C)]
5#[derive(Copy, Clone, Debug, PartialEq)]
6pub struct CGPoint {
7 /// The x-coordinate of this point.
8 pub x: CGFloat,
9
10 /// The y-coordinate of this point.
11 pub y: CGFloat,
12}
13
14impl CGPoint {
15 /// Creates a point with coordinates specified as `CGFloat` values.
16 pub fn new(x: CGFloat, y: CGFloat) -> CGPoint {
17 CGPoint { x, y }
18 }
19}
20
21/// A structure that contains width and height values.
22#[repr(C)]
23#[derive(Copy, Clone, Debug, PartialEq)]
24pub struct CGSize {
25 /// A width value.
26 pub width: CGFloat,
27
28 /// A height value.
29 pub height: CGFloat,
30}
31
32impl CGSize {
33 /// Creates a size with dimensions specified as `CGFloat` values.
34 pub fn new(width: CGFloat, height: CGFloat) -> CGSize {
35 CGSize { width, height }
36 }
37}
38
39/// A structure that contains the location and dimensions of a rectangle.
40#[repr(C)]
41#[derive(Copy, Clone, Debug, PartialEq)]
42pub struct CGRect {
43 /// A point that specifies the coordinates of the rectangle's origin.
44 pub origin: CGPoint,
45
46 /// A point that specifies the height and width of the rectangle.
47 pub size: CGSize,
48}
49
50impl CGRect {
51 /// Creates a rectangle with coordinates and dimensions specified as
52 /// `CGFloat` values.
53 pub fn new(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat) -> CGRect {
54 CGRect {
55 origin: CGPoint::new(x, y),
56 size: CGSize::new(width, height),
57 }
58 }
59}