mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-12-22 12:28:19 -06:00
document corner radius
This commit is contained in:
parent
9acdacaa32
commit
899774a7e1
|
@ -3,6 +3,7 @@ use crate::rect::Corners;
|
|||
|
||||
//TODO uneven corners (separate width/height for each corner)
|
||||
|
||||
/// Calculate the number of points based on the maximum corner radius
|
||||
fn point_count(corners: Corners<f32>) -> NonZeroU16 {
|
||||
//Increase for higher quality
|
||||
const VTX_PER_CORER_RADIUS_PIXEL: f32 = 0.5;
|
||||
|
@ -11,19 +12,31 @@ fn point_count(corners: Corners<f32>) -> NonZeroU16 {
|
|||
).unwrap()
|
||||
}
|
||||
|
||||
/// Low-level options for rendering rounded corners
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct RoundedCorners {
|
||||
/// Corner radius of each corner
|
||||
pub radius: Corners<f32>,
|
||||
|
||||
/// Number of points to use for each corner
|
||||
///
|
||||
/// This value affects all corners, regardless of their individual radius
|
||||
pub point_count: NonZeroU16,
|
||||
}
|
||||
|
||||
impl From<Corners<f32>> for RoundedCorners {
|
||||
/// Create a new `RoundedCorners` from [`Corners<f32>`](crate::rect::Corners)
|
||||
///
|
||||
/// Point count will be calculated automatically based on the maximum radius
|
||||
fn from(radius: Corners<f32>) -> Self {
|
||||
Self::from_radius(radius)
|
||||
}
|
||||
}
|
||||
|
||||
impl RoundedCorners {
|
||||
/// Create a new `RoundedCorners` from [`Corners<f32>`](crate::rect::Corners)
|
||||
///
|
||||
/// Point count will be calculated automatically based on the maximum radius
|
||||
pub fn from_radius(radius: Corners<f32>) -> Self {
|
||||
Self {
|
||||
radius,
|
||||
|
|
Loading…
Reference in a new issue