1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-28 07:23:13 -04:00

Add Shape::hline and Shape::vline

This commit is contained in:
Emil Ernerfeldt
2022-07-30 15:34:24 +02:00
parent c62f3409bd
commit d659e5d24f
2 changed files with 20 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
//! The different shapes that can be painted.
use std::ops::RangeInclusive;
use std::{any::Any, sync::Arc};
use crate::{
@@ -72,6 +73,22 @@ impl Shape {
}
}
/// A horizontal line.
pub fn hline(x: RangeInclusive<f32>, y: f32, stroke: impl Into<Stroke>) -> Self {
Shape::LineSegment {
points: [pos2(*x.start(), y), pos2(*x.end(), y)],
stroke: stroke.into(),
}
}
/// A vertical line.
pub fn vline(x: f32, y: RangeInclusive<f32>, stroke: impl Into<Stroke>) -> Self {
Shape::LineSegment {
points: [pos2(x, *y.start()), pos2(x, *y.end())],
stroke: stroke.into(),
}
}
/// A line through many points.
///
/// Use [`Self::line_segment`] instead if your line only connects two points.