Add stroke_rectangle

This method should be able to leverage performance improvements in lyon's
`tessellate_rectangle` over `tessellate_path`.
This commit is contained in:
Vlad-Stefan Harbuz 2024-06-21 10:41:17 +01:00 committed by Héctor Ramón Jiménez
parent abd323181d
commit ec39390c23
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 100 additions and 0 deletions

View file

@ -168,6 +168,31 @@ impl geometry::frame::Backend for Frame {
});
}
fn stroke_rectangle<'a>(
&mut self,
top_left: Point,
size: Size,
stroke: impl Into<Stroke<'a>>,
) {
let Some(path) = convert_path(&Path::rectangle(top_left, size))
.and_then(|path| path.transform(self.transform))
else {
return;
};
let stroke = stroke.into();
let skia_stroke = into_stroke(&stroke);
let mut paint = into_paint(stroke.style);
paint.shader.transform(self.transform);
self.primitives.push(Primitive::Stroke {
path,
paint,
stroke: skia_stroke,
});
}
fn fill_text(&mut self, text: impl Into<geometry::Text>) {
let text = text.into();