summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget/canvas/frame.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-01-05 00:00:36 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-08-26 14:54:02 +0700
commitd0fe7b57ea343665905933cdf206d8206be462b9 (patch)
tree52878042744926f82c7f0a4379a37870de4dcaa2 /graphics/src/widget/canvas/frame.rs
parent6821114cae2e41fd2bc69d6fcaee1e8574ac061d (diff)
downloadiced-d0fe7b57ea343665905933cdf206d8206be462b9.tar.gz
iced-d0fe7b57ea343665905933cdf206d8206be462b9.tar.bz2
iced-d0fe7b57ea343665905933cdf206d8206be462b9.zip
Update `lyon` to `0.17` in `iced_graphics`
Diffstat (limited to 'graphics/src/widget/canvas/frame.rs')
-rw-r--r--graphics/src/widget/canvas/frame.rs44
1 files changed, 20 insertions, 24 deletions
diff --git a/graphics/src/widget/canvas/frame.rs b/graphics/src/widget/canvas/frame.rs
index 5af9d11f..dd9986af 100644
--- a/graphics/src/widget/canvas/frame.rs
+++ b/graphics/src/widget/canvas/frame.rs
@@ -108,7 +108,10 @@ impl Frame {
size: Size,
fill: impl Into<Fill>,
) {
- use lyon::tessellation::{BuffersBuilder, FillOptions};
+ use lyon::path::builder::PathBuilder;
+ use lyon::tessellation::{
+ BuffersBuilder, FillOptions, FillTessellator,
+ };
let Fill { color, rule } = fill.into();
@@ -127,12 +130,17 @@ impl Frame {
lyon::math::Vector::new(size.width, size.height),
);
- let _ = lyon::tessellation::basic_shapes::fill_rectangle(
+ let mut tessellator = FillTessellator::new();
+ let options = FillOptions::default().with_fill_rule(rule.into());
+
+ let mut builder = tessellator.builder(&options, &mut buffers);
+
+ builder.add_rectangle(
&lyon::math::Rect::new(top_left, size.into()),
- &FillOptions::default().with_fill_rule(rule.into()),
- &mut buffers,
- )
- .expect("Fill rectangle");
+ lyon::path::Winding::Positive,
+ );
+
+ let _ = builder.build().expect("Fill rectangle");
}
/// Draws the stroke of the given [`Path`] on the [`Frame`] with the
@@ -282,28 +290,15 @@ impl Frame {
struct FillVertex([f32; 4]);
-impl lyon::tessellation::BasicVertexConstructor<triangle::Vertex2D>
- for FillVertex
-{
- fn new_vertex(
- &mut self,
- position: lyon::math::Point,
- ) -> triangle::Vertex2D {
- triangle::Vertex2D {
- position: [position.x, position.y],
- color: self.0,
- }
- }
-}
-
impl lyon::tessellation::FillVertexConstructor<triangle::Vertex2D>
for FillVertex
{
fn new_vertex(
&mut self,
- position: lyon::math::Point,
- _attributes: lyon::tessellation::FillAttributes<'_>,
+ vertex: lyon::tessellation::FillVertex<'_>,
) -> triangle::Vertex2D {
+ let position = vertex.position();
+
triangle::Vertex2D {
position: [position.x, position.y],
color: self.0,
@@ -318,9 +313,10 @@ impl lyon::tessellation::StrokeVertexConstructor<triangle::Vertex2D>
{
fn new_vertex(
&mut self,
- position: lyon::math::Point,
- _attributes: lyon::tessellation::StrokeAttributes<'_, '_>,
+ vertex: lyon::tessellation::StrokeVertex<'_, '_>,
) -> triangle::Vertex2D {
+ let position = vertex.position();
+
triangle::Vertex2D {
position: [position.x, position.y],
color: self.0,