summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--core/src/color.rs9
-rw-r--r--core/src/lib.rs2
-rw-r--r--core/src/point.rs7
-rw-r--r--core/src/size.rs (renamed from native/src/size.rs)0
4 files changed, 16 insertions, 2 deletions
diff --git a/core/src/color.rs b/core/src/color.rs
index d6bdd365..db509b88 100644
--- a/core/src/color.rs
+++ b/core/src/color.rs
@@ -44,11 +44,18 @@ impl Color {
///
/// [`Color`]: struct.Color.html
pub fn from_rgb8(r: u8, g: u8, b: u8) -> Color {
+ Color::from_rgba8(r, g, b, 1.0)
+ }
+
+ /// Creates a [`Color`] from its RGB8 components and an alpha value.
+ ///
+ /// [`Color`]: struct.Color.html
+ pub fn from_rgba8(r: u8, g: u8, b: u8, a: f32) -> Color {
Color {
r: f32::from(r) / 255.0,
g: f32::from(g) / 255.0,
b: f32::from(b) / 255.0,
- a: 1.0,
+ a,
}
}
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 3cbce743..ea5e8b43 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -22,6 +22,7 @@ mod font;
mod length;
mod point;
mod rectangle;
+mod size;
mod vector;
pub use align::{Align, HorizontalAlignment, VerticalAlignment};
@@ -31,4 +32,5 @@ pub use font::Font;
pub use length::Length;
pub use point::Point;
pub use rectangle::Rectangle;
+pub use size::Size;
pub use vector::Vector;
diff --git a/core/src/point.rs b/core/src/point.rs
index 47c8b142..b9a8149c 100644
--- a/core/src/point.rs
+++ b/core/src/point.rs
@@ -11,10 +11,15 @@ pub struct Point {
}
impl Point {
+ /// The origin (i.e. a [`Point`] with both X=0 and Y=0).
+ ///
+ /// [`Point`]: struct.Point.html
+ pub const ORIGIN: Point = Point::new(0.0, 0.0);
+
/// Creates a new [`Point`] with the given coordinates.
///
/// [`Point`]: struct.Point.html
- pub fn new(x: f32, y: f32) -> Self {
+ pub const fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
}
diff --git a/native/src/size.rs b/core/src/size.rs
index 389b3247..389b3247 100644
--- a/native/src/size.rs
+++ b/core/src/size.rs