-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1882 from nicksenger/shadows
Quad shadows
- Loading branch information
Showing
49 changed files
with
597 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//! Draw lines around containers. | ||
use crate::Color; | ||
|
||
/// A border. | ||
#[derive(Debug, Clone, Copy, PartialEq, Default)] | ||
pub struct Border { | ||
/// The color of the border. | ||
pub color: Color, | ||
|
||
/// The width of the border. | ||
pub width: f32, | ||
|
||
/// The radius of the border. | ||
pub radius: Radius, | ||
} | ||
|
||
impl Border { | ||
/// Creates a new default [`Border`] with the given [`Radius`]. | ||
pub fn with_radius(radius: impl Into<Radius>) -> Self { | ||
Self { | ||
radius: radius.into(), | ||
..Self::default() | ||
} | ||
} | ||
} | ||
|
||
/// The border radii for the corners of a graphics primitive in the order: | ||
/// top-left, top-right, bottom-right, bottom-left. | ||
#[derive(Debug, Clone, Copy, PartialEq, Default)] | ||
pub struct Radius([f32; 4]); | ||
|
||
impl From<f32> for Radius { | ||
fn from(w: f32) -> Self { | ||
Self([w; 4]) | ||
} | ||
} | ||
|
||
impl From<u8> for Radius { | ||
fn from(w: u8) -> Self { | ||
Self([f32::from(w); 4]) | ||
} | ||
} | ||
|
||
impl From<[f32; 4]> for Radius { | ||
fn from(radi: [f32; 4]) -> Self { | ||
Self(radi) | ||
} | ||
} | ||
|
||
impl From<Radius> for [f32; 4] { | ||
fn from(radi: Radius) -> Self { | ||
radi.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::{Color, Vector}; | ||
|
||
/// A shadow. | ||
#[derive(Debug, Clone, Copy, PartialEq, Default)] | ||
pub struct Shadow { | ||
/// The color of the shadow. | ||
pub color: Color, | ||
|
||
/// The offset of the shadow. | ||
pub offset: Vector, | ||
|
||
/// The blur radius of the shadow. | ||
pub blur_radius: f32, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.