pub use blinc_core::{CornerRadius, Point, Rect, Shadow, Size};
use crate::Color;
#[derive(Clone, Copy, Debug, Default)]
#[repr(C)]
pub struct Circle {
pub center: Point,
pub radius: f32,
}
impl Circle {
pub const fn new(center: Point, radius: f32) -> Self {
Self { center, radius }
}
pub fn contains(&self, point: Point) -> bool {
let dx = point.x - self.center.x;
let dy = point.y - self.center.y;
(dx * dx + dy * dy) <= (self.radius * self.radius)
}
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C)]
pub struct Ellipse {
pub center: Point,
pub radius_x: f32,
pub radius_y: f32,
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C)]
pub struct RoundedRect {
pub rect: Rect,
pub corner_radius: CornerRadius,
}
impl RoundedRect {
pub fn new(rect: Rect, corner_radius: CornerRadius) -> Self {
Self {
rect,
corner_radius,
}
}
pub fn uniform(rect: Rect, radius: f32) -> Self {
Self {
rect,
corner_radius: radius.into(),
}
}
}
pub mod shadow_presets {
use super::*;
pub fn sm() -> Shadow {
Shadow::new(0.0, 1.0, 2.0, Color::BLACK.with_alpha(0.1))
}
pub fn md() -> Shadow {
Shadow {
offset_x: 0.0,
offset_y: 4.0,
blur: 6.0,
spread: -1.0,
color: Color::BLACK.with_alpha(0.1),
}
}
pub fn lg() -> Shadow {
Shadow {
offset_x: 0.0,
offset_y: 10.0,
blur: 15.0,
spread: -3.0,
color: Color::BLACK.with_alpha(0.1),
}
}
}