geometry: Add some convenience constructors for geometry types.
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user