geometry: Add some convenience constructors for geometry types.

This commit is contained in:
Patrick Walton
2016-06-03 16:04:40 -07:00
parent 9b16b0e214
commit 508a240632
+31
View File
@@ -21,6 +21,16 @@ pub struct CGSize {
pub height: CGFloat,
}
impl CGSize {
#[inline]
pub fn new(width: CGFloat, height: CGFloat) -> CGSize {
CGSize {
width: width,
height: height,
}
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct CGPoint {
@@ -28,9 +38,30 @@ pub struct CGPoint {
pub y: CGFloat,
}
impl CGPoint {
#[inline]
pub fn new(x: CGFloat, y: CGFloat) -> CGPoint {
CGPoint {
x: x,
y: y,
}
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct CGRect {
pub origin: CGPoint,
pub size: CGSize
}
impl CGRect {
#[inline]
pub fn new(origin: &CGPoint, size: &CGSize) -> CGRect {
CGRect {
origin: *origin,
size: *size,
}
}
}