Rename Shape::polygon to Shape::convex_polygon
epaint only supports filling convex polygons (for now)
This commit is contained in:
parent
085233f907
commit
196ddff499
2 changed files with 13 additions and 2 deletions
|
@ -129,7 +129,7 @@ fn color_slider_1d(ui: &mut Ui, value: &mut f32, color_at: impl Fn(f32) -> Color
|
||||||
let x = lerp(rect.left()..=rect.right(), *value);
|
let x = lerp(rect.left()..=rect.right(), *value);
|
||||||
let r = rect.height() / 4.0;
|
let r = rect.height() / 4.0;
|
||||||
let picked_color = color_at(*value);
|
let picked_color = color_at(*value);
|
||||||
ui.painter().add(Shape::polygon(
|
ui.painter().add(Shape::convex_polygon(
|
||||||
vec![
|
vec![
|
||||||
pos2(x - r, rect.bottom()),
|
pos2(x - r, rect.bottom()),
|
||||||
pos2(x + r, rect.bottom()),
|
pos2(x + r, rect.bottom()),
|
||||||
|
|
|
@ -29,6 +29,7 @@ pub enum Shape {
|
||||||
/// If true, connect the first and last of the points together.
|
/// If true, connect the first and last of the points together.
|
||||||
/// This is required if `fill != TRANSPARENT`.
|
/// This is required if `fill != TRANSPARENT`.
|
||||||
closed: bool,
|
closed: bool,
|
||||||
|
/// Fill is only supported for convex polygons.
|
||||||
fill: Color32,
|
fill: Color32,
|
||||||
stroke: Stroke,
|
stroke: Stroke,
|
||||||
},
|
},
|
||||||
|
@ -85,7 +86,12 @@ impl Shape {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn polygon(points: Vec<Pos2>, fill: impl Into<Color32>, stroke: impl Into<Stroke>) -> Self {
|
/// A convex polygon with a fill and optional stroke.
|
||||||
|
pub fn convex_polygon(
|
||||||
|
points: Vec<Pos2>,
|
||||||
|
fill: impl Into<Color32>,
|
||||||
|
stroke: impl Into<Stroke>,
|
||||||
|
) -> Self {
|
||||||
Self::Path {
|
Self::Path {
|
||||||
points,
|
points,
|
||||||
closed: true,
|
closed: true,
|
||||||
|
@ -94,6 +100,11 @@ impl Shape {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated = "Renamed convex_polygon"]
|
||||||
|
pub fn polygon(points: Vec<Pos2>, fill: impl Into<Color32>, stroke: impl Into<Stroke>) -> Self {
|
||||||
|
Self::convex_polygon(points, fill, stroke)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn circle_filled(center: Pos2, radius: f32, fill_color: impl Into<Color32>) -> Self {
|
pub fn circle_filled(center: Pos2, radius: f32, fill_color: impl Into<Color32>) -> Self {
|
||||||
Self::Circle {
|
Self::Circle {
|
||||||
center,
|
center,
|
||||||
|
|
Loading…
Reference in a new issue