Update lyon to 0.17 in iced_graphics

This commit is contained in:
Héctor Ramón Jiménez 2021-01-05 00:00:36 +01:00
parent 31522e30aa
commit bfa08d6d69
4 changed files with 24 additions and 28 deletions

View File

@ -36,7 +36,7 @@ version = "0.2"
path = "../style" path = "../style"
[dependencies.lyon] [dependencies.lyon]
version = "0.16" version = "0.17"
optional = true optional = true
[dependencies.qrcode] [dependencies.qrcode]

View File

@ -108,7 +108,10 @@ impl Frame {
size: Size, size: Size,
fill: impl Into<Fill>, 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(); let Fill { color, rule } = fill.into();
@ -127,12 +130,17 @@ impl Frame {
lyon::math::Vector::new(size.width, size.height), 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()), &lyon::math::Rect::new(top_left, size.into()),
&FillOptions::default().with_fill_rule(rule.into()), lyon::path::Winding::Positive,
&mut buffers, );
)
.expect("Fill rectangle"); let _ = builder.build().expect("Fill rectangle");
} }
/// Draws the stroke of the given [`Path`] on the [`Frame`] with the /// Draws the stroke of the given [`Path`] on the [`Frame`] with the
@ -282,28 +290,15 @@ impl Frame {
struct FillVertex([f32; 4]); 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> impl lyon::tessellation::FillVertexConstructor<triangle::Vertex2D>
for FillVertex for FillVertex
{ {
fn new_vertex( fn new_vertex(
&mut self, &mut self,
position: lyon::math::Point, vertex: lyon::tessellation::FillVertex<'_>,
_attributes: lyon::tessellation::FillAttributes<'_>,
) -> triangle::Vertex2D { ) -> triangle::Vertex2D {
let position = vertex.position();
triangle::Vertex2D { triangle::Vertex2D {
position: [position.x, position.y], position: [position.x, position.y],
color: self.0, color: self.0,
@ -318,9 +313,10 @@ impl lyon::tessellation::StrokeVertexConstructor<triangle::Vertex2D>
{ {
fn new_vertex( fn new_vertex(
&mut self, &mut self,
position: lyon::math::Point, vertex: lyon::tessellation::StrokeVertex<'_, '_>,
_attributes: lyon::tessellation::StrokeAttributes<'_, '_>,
) -> triangle::Vertex2D { ) -> triangle::Vertex2D {
let position = vertex.position();
triangle::Vertex2D { triangle::Vertex2D {
position: [position.x, position.y], position: [position.x, position.y],
color: self.0, color: self.0,

View File

@ -62,7 +62,7 @@ impl Path {
transform: &lyon::math::Transform, transform: &lyon::math::Transform,
) -> Path { ) -> Path {
Path { Path {
raw: self.raw.transformed(transform), raw: self.raw.clone().transformed(transform),
} }
} }
} }

View File

@ -1,14 +1,14 @@
use crate::canvas::path::{arc, Arc, Path}; use crate::canvas::path::{arc, Arc, Path};
use iced_native::{Point, Size}; use iced_native::{Point, Size};
use lyon::path::builder::{Build, FlatPathBuilder, PathBuilder, SvgBuilder}; use lyon::path::builder::SvgPathBuilder;
/// A [`Path`] builder. /// A [`Path`] builder.
/// ///
/// Once a [`Path`] is built, it can no longer be mutated. /// Once a [`Path`] is built, it can no longer be mutated.
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct Builder { pub struct Builder {
raw: lyon::path::builder::SvgPathBuilder<lyon::path::Builder>, raw: lyon::path::builder::WithSvg<lyon::path::path::Builder>,
} }
impl Builder { impl Builder {