Merge pull request #628 from hecrj/improvement/float-border-radius

Use `f32` for `border_width` and `border_radius`
This commit is contained in:
Héctor Ramón 2020-11-24 00:17:30 +01:00 committed by GitHub
commit 5615643c52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 144 additions and 134 deletions

View File

@ -16,11 +16,11 @@ mod circle {
};
pub struct Circle {
radius: u16,
radius: f32,
}
impl Circle {
pub fn new(radius: u16) -> Self {
pub fn new(radius: f32) -> Self {
Self { radius }
}
}
@ -42,16 +42,13 @@ mod circle {
_renderer: &Renderer<B>,
_limits: &layout::Limits,
) -> layout::Node {
layout::Node::new(Size::new(
f32::from(self.radius) * 2.0,
f32::from(self.radius) * 2.0,
))
layout::Node::new(Size::new(self.radius * 2.0, self.radius * 2.0))
}
fn hash_layout(&self, state: &mut Hasher) {
use std::hash::Hash;
self.radius.hash(state);
self.radius.to_bits().hash(state);
}
fn draw(
@ -67,7 +64,7 @@ mod circle {
bounds: layout.bounds(),
background: Background::Color(Color::BLACK),
border_radius: self.radius,
border_width: 0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
mouse::Interaction::default(),
@ -96,7 +93,7 @@ pub fn main() -> iced::Result {
}
struct Example {
radius: u16,
radius: f32,
slider: slider::State,
}
@ -110,7 +107,7 @@ impl Sandbox for Example {
fn new() -> Self {
Example {
radius: 50,
radius: 50.0,
slider: slider::State::new(),
}
}
@ -122,7 +119,7 @@ impl Sandbox for Example {
fn update(&mut self, message: Message) {
match message {
Message::RadiusChanged(radius) => {
self.radius = radius.round() as u16;
self.radius = radius;
}
}
}
@ -134,13 +131,16 @@ impl Sandbox for Example {
.max_width(500)
.align_items(Align::Center)
.push(Circle::new(self.radius))
.push(Text::new(format!("Radius: {}", self.radius.to_string())))
.push(Slider::new(
&mut self.slider,
1.0..=100.0,
f32::from(self.radius),
Message::RadiusChanged,
));
.push(Text::new(format!("Radius: {:.2}", self.radius)))
.push(
Slider::new(
&mut self.slider,
1.0..=100.0,
self.radius,
Message::RadiusChanged,
)
.step(0.01),
);
Container::new(content)
.width(Length::Fill)

View File

@ -44,7 +44,7 @@ impl button::StyleSheet for Button {
fn active(&self) -> button::Style {
button::Style {
background: Some(Background::Color(ACTIVE)),
border_radius: 3,
border_radius: 3.0,
text_color: Color::WHITE,
..button::Style::default()
}
@ -60,7 +60,7 @@ impl button::StyleSheet for Button {
fn pressed(&self) -> button::Style {
button::Style {
border_width: 1,
border_width: 1.0,
border_color: Color::WHITE,
..self.hovered()
}
@ -73,7 +73,7 @@ impl button::StyleSheet for Clear {
fn active(&self) -> button::Style {
button::Style {
background: Some(Background::Color(DESTRUCTIVE)),
border_radius: 3,
border_radius: 3.0,
text_color: Color::WHITE,
..button::Style::default()
}
@ -92,7 +92,7 @@ impl button::StyleSheet for Clear {
fn pressed(&self) -> button::Style {
button::Style {
border_width: 1,
border_width: 1.0,
border_color: Color::WHITE,
..self.hovered()
}
@ -106,9 +106,9 @@ impl slider::StyleSheet for Slider {
slider::Style {
rail_colors: (ACTIVE, Color { a: 0.1, ..ACTIVE }),
handle: slider::Handle {
shape: slider::HandleShape::Circle { radius: 9 },
shape: slider::HandleShape::Circle { radius: 9.0 },
color: ACTIVE,
border_width: 0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
}
@ -146,7 +146,7 @@ impl pick_list::StyleSheet for PickList {
pick_list::Menu {
text_color: Color::WHITE,
background: BACKGROUND.into(),
border_width: 1,
border_width: 1.0,
border_color: Color {
a: 0.7,
..Color::BLACK
@ -164,12 +164,12 @@ impl pick_list::StyleSheet for PickList {
pick_list::Style {
text_color: Color::WHITE,
background: BACKGROUND.into(),
border_width: 1,
border_width: 1.0,
border_color: Color {
a: 0.6,
..Color::BLACK
},
border_radius: 2,
border_radius: 2.0,
icon_size: 0.5,
}
}

View File

@ -318,7 +318,7 @@ mod style {
fn style(&self) -> container::Style {
container::Style {
background: Some(Background::Color(SURFACE)),
border_width: 2,
border_width: 2.0,
border_color: if self.is_focused {
Color::BLACK
} else {
@ -346,7 +346,7 @@ mod style {
button::Style {
text_color,
background: background.map(Background::Color),
border_radius: 5,
border_radius: 5.0,
shadow_offset: Vector::new(0.0, 0.0),
..button::Style::default()
}

View File

@ -251,7 +251,7 @@ mod style {
background: Some(Background::Color(match self {
Button::Primary => Color::from_rgb(0.11, 0.42, 0.87),
})),
border_radius: 12,
border_radius: 12.0,
shadow_offset: Vector::new(1.0, 1.0),
text_color: Color::WHITE,
..button::Style::default()

View File

@ -114,7 +114,7 @@ mod dark {
radio::Style {
background: SURFACE.into(),
dot_color: ACTIVE,
border_width: 1,
border_width: 1.0,
border_color: ACTIVE,
}
}
@ -137,13 +137,13 @@ mod dark {
..SCROLLBAR
}
.into(),
border_radius: 2,
border_width: 0,
border_radius: 2.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
scroller: scrollable::Scroller {
color: Color { a: 0.7, ..SCROLLER },
border_radius: 2,
border_width: 0,
border_radius: 2.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
}
@ -182,7 +182,7 @@ mod dark {
rule::Style {
color: SURFACE,
width: 2,
radius: 1,
radius: 1.0,
fill_mode: rule::FillMode::Percent(30.0),
}
}

View File

@ -161,7 +161,7 @@ mod style {
Button::Secondary => Color::from_rgb(0.5, 0.5, 0.5),
Button::Destructive => Color::from_rgb(0.8, 0.2, 0.2),
})),
border_radius: 12,
border_radius: 12.0,
shadow_offset: Vector::new(1.0, 1.0),
text_color: Color::WHITE,
..button::Style::default()

View File

@ -249,7 +249,7 @@ mod style {
fn active(&self) -> button::Style {
button::Style {
background: Color::from_rgb(0.11, 0.42, 0.87).into(),
border_radius: 12,
border_radius: 12.0,
shadow_offset: Vector::new(1.0, 1.0),
text_color: Color::from_rgb8(0xEE, 0xEE, 0xEE),
..button::Style::default()
@ -315,7 +315,7 @@ mod style {
radio::Style {
background: SURFACE.into(),
dot_color: ACTIVE,
border_width: 1,
border_width: 1.0,
border_color: ACTIVE,
}
}
@ -334,15 +334,15 @@ mod style {
fn active(&self) -> text_input::Style {
text_input::Style {
background: SURFACE.into(),
border_radius: 2,
border_width: 0,
border_radius: 2.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
}
}
fn focused(&self) -> text_input::Style {
text_input::Style {
border_width: 1,
border_width: 1.0,
border_color: ACCENT,
..self.active()
}
@ -350,7 +350,7 @@ mod style {
fn hovered(&self) -> text_input::Style {
text_input::Style {
border_width: 1,
border_width: 1.0,
border_color: Color { a: 0.3, ..ACCENT },
..self.focused()
}
@ -375,7 +375,7 @@ mod style {
fn active(&self) -> button::Style {
button::Style {
background: ACTIVE.into(),
border_radius: 3,
border_radius: 3.0,
text_color: Color::WHITE,
..button::Style::default()
}
@ -391,7 +391,7 @@ mod style {
fn pressed(&self) -> button::Style {
button::Style {
border_width: 1,
border_width: 1.0,
border_color: Color::WHITE,
..self.hovered()
}
@ -404,13 +404,13 @@ mod style {
fn active(&self) -> scrollable::Scrollbar {
scrollable::Scrollbar {
background: SURFACE.into(),
border_radius: 2,
border_width: 0,
border_radius: 2.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
scroller: scrollable::Scroller {
color: ACTIVE,
border_radius: 2,
border_width: 0,
border_radius: 2.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
}
@ -449,9 +449,9 @@ mod style {
slider::Style {
rail_colors: (ACTIVE, Color { a: 0.1, ..ACTIVE }),
handle: slider::Handle {
shape: slider::HandleShape::Circle { radius: 9 },
shape: slider::HandleShape::Circle { radius: 9.0 },
color: ACTIVE,
border_width: 0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
}
@ -489,7 +489,7 @@ mod style {
progress_bar::Style {
background: SURFACE.into(),
bar: ACTIVE.into(),
border_radius: 10,
border_radius: 10.0,
}
}
}
@ -502,8 +502,8 @@ mod style {
background: if is_checked { ACTIVE } else { SURFACE }
.into(),
checkmark_color: Color::WHITE,
border_radius: 2,
border_width: 1,
border_radius: 2.0,
border_width: 1.0,
border_color: ACTIVE,
}
}
@ -527,7 +527,7 @@ mod style {
rule::Style {
color: SURFACE,
width: 2,
radius: 1,
radius: 1.0,
fill_mode: rule::FillMode::Padded(15),
}
}

View File

@ -611,7 +611,7 @@ mod style {
background: Some(Background::Color(
Color::from_rgb(0.2, 0.2, 0.7),
)),
border_radius: 10,
border_radius: 10.0,
text_color: Color::WHITE,
..button::Style::default()
}
@ -627,7 +627,7 @@ mod style {
background: Some(Background::Color(Color::from_rgb(
0.8, 0.2, 0.2,
))),
border_radius: 5,
border_radius: 5.0,
text_color: Color::WHITE,
shadow_offset: Vector::new(1.0, 1.0),
..button::Style::default()

View File

@ -769,7 +769,7 @@ mod style {
Button::Primary => Color::from_rgb(0.11, 0.42, 0.87),
Button::Secondary => Color::from_rgb(0.5, 0.5, 0.5),
})),
border_radius: 12,
border_radius: 12.0,
shadow_offset: Vector::new(1.0, 1.0),
text_color: Color::from_rgb8(0xEE, 0xEE, 0xEE),
..button::Style::default()

View File

@ -29,6 +29,11 @@ void main() {
vec2 p_Pos = i_Pos * u_Scale;
vec2 p_Scale = i_Scale * u_Scale;
float i_BorderRadius = min(
i_BorderRadius,
min(i_Scale.x, i_Scale.y) / 2.0
);
mat4 i_Transform = mat4(
vec4(p_Scale.x + 1.0, 0.0, 0.0, 0.0),
vec4(0.0, p_Scale.y + 1.0, 0.0, 0.0),

View File

@ -156,8 +156,8 @@ impl<'a> Layer<'a> {
color: match background {
Background::Color(color) => color.into_linear(),
},
border_radius: *border_radius as f32,
border_width: *border_width as f32,
border_radius: *border_radius,
border_width: *border_width,
border_color: border_color.into_linear(),
});
}

View File

@ -29,7 +29,7 @@ where
background: style.background,
border_color: style.border_color,
border_width: style.border_width,
border_radius: 0,
border_radius: 0.0,
},
primitives,
],
@ -80,8 +80,8 @@ where
bounds,
background: style.selected_background,
border_color: Color::TRANSPARENT,
border_width: 0,
border_radius: 0,
border_width: 0.0,
border_radius: 0.0,
});
}

View File

@ -40,9 +40,9 @@ pub enum Primitive {
/// The background of the quad
background: Background,
/// The border radius of the quad
border_radius: u16,
border_radius: f32,
/// The border width of the quad
border_width: u16,
border_width: f32,
/// The border color of the quad
border_color: Color,
},

View File

@ -119,8 +119,8 @@ fn explain_layout(
primitives.push(Primitive::Quad {
bounds: layout.bounds(),
background: Background::Color(Color::TRANSPARENT),
border_radius: 0,
border_width: 1,
border_radius: 0.0,
border_width: 1.0,
border_color: [0.6, 0.6, 0.6, 0.5].into(),
});

View File

@ -66,7 +66,7 @@ where
);
(
if styling.background.is_some() || styling.border_width > 0 {
if styling.background.is_some() || styling.border_width > 0.0 {
let background = Primitive::Quad {
bounds,
background: styling
@ -93,7 +93,7 @@ where
[0.0, 0.0, 0.0, 0.5].into(),
),
border_radius: styling.border_radius,
border_width: 0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
};

View File

@ -62,7 +62,7 @@ pub(crate) fn background(
bounds: Rectangle,
style: &container::Style,
) -> Option<Primitive> {
if style.background.is_some() || style.border_width > 0 {
if style.background.is_some() || style.border_width > 0.0 {
Some(Primitive::Quad {
bounds,
background: style

View File

@ -43,7 +43,7 @@ where
bounds: Rectangle { ..bounds },
background: style.background,
border_radius: style.border_radius,
border_width: 0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
}],
};
@ -57,7 +57,7 @@ where
},
background: style.bar,
border_radius: style.border_radius,
border_width: 0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
};

View File

@ -42,7 +42,7 @@ where
let radio = Primitive::Quad {
bounds,
background: style.background,
border_radius: (size / 2.0) as u16,
border_radius: size / 2.0,
border_width: style.border_width,
border_color: style.border_color,
};
@ -58,8 +58,8 @@ where
height: bounds.height - dot_size,
},
background: Background::Color(style.dot_color),
border_radius: (dot_size / 2.0) as u16,
border_width: 0,
border_radius: dot_size / 2.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
};

View File

@ -43,7 +43,7 @@ where
},
background: Background::Color(style.color),
border_radius: style.radius,
border_width: 0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
}
} else {
@ -63,7 +63,7 @@ where
},
background: Background::Color(style.color),
border_radius: style.radius,
border_width: 0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
}
};

View File

@ -103,7 +103,7 @@ where
};
let is_scrollbar_visible =
style.background.is_some() || style.border_width > 0;
style.background.is_some() || style.border_width > 0.0;
let scroller = if is_mouse_over
|| state.is_scroller_grabbed()

View File

@ -57,8 +57,8 @@ where
height: 2.0,
},
background: Background::Color(style.rail_colors.0),
border_radius: 0,
border_width: 0,
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
Primitive::Quad {
@ -69,8 +69,8 @@ where
height: 2.0,
},
background: Background::Color(style.rail_colors.1),
border_radius: 0,
border_width: 0,
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
);
@ -82,7 +82,7 @@ where
.shape
{
HandleShape::Circle { radius } => {
(f32::from(radius * 2), f32::from(radius * 2), radius)
(radius * 2.0, radius * 2.0, radius)
}
HandleShape::Rectangle {
width,

View File

@ -149,8 +149,8 @@ where
background: Background::Color(
style_sheet.value_color(),
),
border_radius: 0,
border_width: 0,
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
offset,
@ -193,8 +193,8 @@ where
background: Background::Color(
style_sheet.selection_color(),
),
border_radius: 0,
border_width: 0,
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
if end == right {

View File

@ -6,8 +6,8 @@ use iced_core::{Background, Color, Vector};
pub struct Style {
pub shadow_offset: Vector,
pub background: Option<Background>,
pub border_radius: u16,
pub border_width: u16,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
pub text_color: Color,
}
@ -17,8 +17,8 @@ impl std::default::Default for Style {
Self {
shadow_offset: Vector::default(),
background: None,
border_radius: 0,
border_width: 0,
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
text_color: Color::BLACK,
}
@ -72,8 +72,8 @@ impl StyleSheet for Default {
Style {
shadow_offset: Vector::new(0.0, 0.0),
background: Some(Background::Color([0.87, 0.87, 0.87].into())),
border_radius: 2,
border_width: 1,
border_radius: 2.0,
border_width: 1.0,
border_color: [0.7, 0.7, 0.7].into(),
text_color: Color::BLACK,
}

View File

@ -6,8 +6,8 @@ use iced_core::{Background, Color};
pub struct Style {
pub background: Background,
pub checkmark_color: Color,
pub border_radius: u16,
pub border_width: u16,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
}
@ -25,8 +25,8 @@ impl StyleSheet for Default {
Style {
background: Background::Color(Color::from_rgb(0.95, 0.95, 0.95)),
checkmark_color: Color::from_rgb(0.3, 0.3, 0.3),
border_radius: 5,
border_width: 1,
border_radius: 5.0,
border_width: 1.0,
border_color: Color::from_rgb(0.6, 0.6, 0.6),
}
}

View File

@ -6,8 +6,8 @@ use iced_core::{Background, Color};
pub struct Style {
pub text_color: Option<Color>,
pub background: Option<Background>,
pub border_radius: u16,
pub border_width: u16,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
}
@ -16,8 +16,8 @@ impl std::default::Default for Style {
Self {
text_color: None,
background: None,
border_radius: 0,
border_width: 0,
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
}
}
@ -36,8 +36,8 @@ impl StyleSheet for Default {
Style {
text_color: None,
background: None,
border_radius: 0,
border_width: 0,
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
}
}

View File

@ -5,7 +5,7 @@ use iced_core::{Background, Color};
pub struct Style {
pub text_color: Color,
pub background: Background,
pub border_width: u16,
pub border_width: f32,
pub border_color: Color,
pub selected_text_color: Color,
pub selected_background: Background,
@ -16,7 +16,7 @@ impl std::default::Default for Style {
Self {
text_color: Color::BLACK,
background: Background::Color([0.87, 0.87, 0.87].into()),
border_width: 1,
border_width: 1.0,
border_color: [0.7, 0.7, 0.7].into(),
selected_text_color: Color::WHITE,
selected_background: Background::Color([0.4, 0.4, 1.0].into()),

View File

@ -6,8 +6,8 @@ use iced_core::{Background, Color};
pub struct Style {
pub text_color: Color,
pub background: Background,
pub border_radius: u16,
pub border_width: u16,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
pub icon_size: f32,
}
@ -17,8 +17,8 @@ impl std::default::Default for Style {
Self {
text_color: Color::BLACK,
background: Background::Color([0.87, 0.87, 0.87].into()),
border_radius: 0,
border_width: 1,
border_radius: 0.0,
border_width: 1.0,
border_color: [0.7, 0.7, 0.7].into(),
icon_size: 0.7,
}

View File

@ -6,7 +6,7 @@ use iced_core::{Background, Color};
pub struct Style {
pub background: Background,
pub bar: Background,
pub border_radius: u16,
pub border_radius: f32,
}
/// A set of rules that dictate the style of a progress bar.
@ -21,7 +21,7 @@ impl StyleSheet for Default {
Style {
background: Background::Color(Color::from_rgb(0.6, 0.6, 0.6)),
bar: Background::Color(Color::from_rgb(0.3, 0.9, 0.3)),
border_radius: 5,
border_radius: 5.0,
}
}
}

View File

@ -6,7 +6,7 @@ use iced_core::{Background, Color};
pub struct Style {
pub background: Background,
pub dot_color: Color,
pub border_width: u16,
pub border_width: f32,
pub border_color: Color,
}
@ -24,7 +24,7 @@ impl StyleSheet for Default {
Style {
background: Background::Color(Color::from_rgb(0.95, 0.95, 0.95)),
dot_color: Color::from_rgb(0.3, 0.3, 0.3),
border_width: 1,
border_width: 1.0,
border_color: Color::from_rgb(0.6, 0.6, 0.6),
}
}

View File

@ -74,7 +74,7 @@ pub struct Style {
/// The width (thickness) of the rule line.
pub width: u16,
/// The radius of the line corners.
pub radius: u16,
pub radius: f32,
/// The [`FillMode`] of the rule.
///
/// [`FillMode`]: enum.FillMode.html
@ -94,7 +94,7 @@ impl StyleSheet for Default {
Style {
color: [0.6, 0.6, 0.6, 0.51].into(),
width: 1,
radius: 0,
radius: 0.0,
fill_mode: FillMode::Percent(90.0),
}
}

View File

@ -5,8 +5,8 @@ use iced_core::{Background, Color};
#[derive(Debug, Clone, Copy)]
pub struct Scrollbar {
pub background: Option<Background>,
pub border_radius: u16,
pub border_width: u16,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
pub scroller: Scroller,
}
@ -15,8 +15,8 @@ pub struct Scrollbar {
#[derive(Debug, Clone, Copy)]
pub struct Scroller {
pub color: Color,
pub border_radius: u16,
pub border_width: u16,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
}
@ -40,13 +40,13 @@ impl StyleSheet for Default {
fn active(&self) -> Scrollbar {
Scrollbar {
background: None,
border_radius: 5,
border_width: 0,
border_radius: 5.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
scroller: Scroller {
color: [0.0, 0.0, 0.0, 0.7].into(),
border_radius: 5,
border_width: 0,
border_radius: 5.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
}

View File

@ -13,15 +13,15 @@ pub struct Style {
pub struct Handle {
pub shape: HandleShape,
pub color: Color,
pub border_width: u16,
pub border_width: f32,
pub border_color: Color,
}
/// The shape of the handle of a slider.
#[derive(Debug, Clone, Copy)]
pub enum HandleShape {
Circle { radius: u16 },
Rectangle { width: u16, border_radius: u16 },
Circle { radius: f32 },
Rectangle { width: u16, border_radius: f32 },
}
/// A set of rules that dictate the style of a slider.
@ -45,11 +45,11 @@ impl StyleSheet for Default {
handle: Handle {
shape: HandleShape::Rectangle {
width: 8,
border_radius: 4,
border_radius: 4.0,
},
color: Color::from_rgb(0.95, 0.95, 0.95),
border_color: Color::from_rgb(0.6, 0.6, 0.6),
border_width: 1,
border_width: 1.0,
},
}
}

View File

@ -5,8 +5,8 @@ use iced_core::{Background, Color};
#[derive(Debug, Clone, Copy)]
pub struct Style {
pub background: Background,
pub border_radius: u16,
pub border_width: u16,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
}
@ -14,8 +14,8 @@ impl std::default::Default for Style {
fn default() -> Self {
Self {
background: Background::Color(Color::WHITE),
border_radius: 0,
border_width: 0,
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
}
}
@ -47,8 +47,8 @@ impl StyleSheet for Default {
fn active(&self) -> Style {
Style {
background: Background::Color(Color::WHITE),
border_radius: 5,
border_width: 1,
border_radius: 5.0,
border_width: 1.0,
border_color: Color::from_rgb(0.7, 0.7, 0.7),
}
}

View File

@ -24,6 +24,11 @@ void main() {
vec2 p_Pos = i_Pos * u_Scale;
vec2 p_Scale = i_Scale * u_Scale;
float i_BorderRadius = min(
i_BorderRadius,
min(i_Scale.x, i_Scale.y) / 2.0
);
mat4 i_Transform = mat4(
vec4(p_Scale.x + 1.0, 0.0, 0.0, 0.0),
vec4(0.0, p_Scale.y + 1.0, 0.0, 0.0),

Binary file not shown.