summaryrefslogtreecommitdiffstats
path: root/wgpu/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-09-10 23:54:05 +0200
committerLibravatar GitHub <noreply@github.com>2024-09-10 23:54:05 +0200
commit2a17afb7374deabcc7571688e58fcce01182d646 (patch)
treeee262e6998a189cf7a9e088e79e0094ec667d308 /wgpu/src
parentf7bca570c3d0e73ce57a0406319c606e7c5f1463 (diff)
parentfe8f41278dc922e12ffeb7a50bfb17a47b4bf956 (diff)
downloadiced-2a17afb7374deabcc7571688e58fcce01182d646.tar.gz
iced-2a17afb7374deabcc7571688e58fcce01182d646.tar.bz2
iced-2a17afb7374deabcc7571688e58fcce01182d646.zip
Merge pull request #2473 from vladh/add-stroke-rectangle
Add stroke_rectangle
Diffstat (limited to 'wgpu/src')
-rw-r--r--wgpu/src/geometry.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs
index be65ba36..8e6f77d7 100644
--- a/wgpu/src/geometry.rs
+++ b/wgpu/src/geometry.rs
@@ -253,6 +253,44 @@ impl geometry::frame::Backend for Frame {
.expect("Stroke path");
}
+ fn stroke_rectangle<'a>(
+ &mut self,
+ top_left: Point,
+ size: Size,
+ stroke: impl Into<Stroke<'a>>,
+ ) {
+ let stroke = stroke.into();
+
+ let mut buffer = self
+ .buffers
+ .get_stroke(&self.transforms.current.transform_style(stroke.style));
+
+ let top_left = self
+ .transforms
+ .current
+ .0
+ .transform_point(lyon::math::Point::new(top_left.x, top_left.y));
+
+ let size =
+ self.transforms.current.0.transform_vector(
+ lyon::math::Vector::new(size.width, size.height),
+ );
+
+ let mut options = tessellation::StrokeOptions::default();
+ options.line_width = stroke.width;
+ options.start_cap = into_line_cap(stroke.line_cap);
+ options.end_cap = into_line_cap(stroke.line_cap);
+ options.line_join = into_line_join(stroke.line_join);
+
+ self.stroke_tessellator
+ .tessellate_rectangle(
+ &lyon::math::Box2D::new(top_left, top_left + size),
+ &options,
+ buffer.as_mut(),
+ )
+ .expect("Stroke rectangle");
+ }
+
fn fill_text(&mut self, text: impl Into<geometry::Text>) {
let text = text.into();