gpui: Add PathBuilder
based on lyon to build Path
(#22808)
Release Notes: - N/A --- Continue https://github.com/zed-industries/zed/pull/20499 We to draw more complex Path. Before this change, we only have `line_to`, but it is not enough. Add a new `PathBuilder` to use [lyon](https://github.com/nical/lyon) to build more complex path. And then with PR #22812 to enable anti-aliasing, all thing will be perfect. ## Show case ```bash cargo run -p gpui --example painting ``` Before: <img width="1136" alt="image" src="https://github.com/user-attachments/assets/0c15833a-ec95-404c-a469-24cf172cfd86" /> After: <img width="1136" alt="image" src="https://github.com/user-attachments/assets/42cfa35e-7e8f-4ef3-bb2d-b98defc62ad6" />
This commit is contained in:
parent
706f7be5e7
commit
31fa414422
8 changed files with 449 additions and 79 deletions
|
@ -715,6 +715,13 @@ impl Path<Pixels> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Move the start, current point to the given point.
|
||||
pub fn move_to(&mut self, to: Point<Pixels>) {
|
||||
self.contour_count += 1;
|
||||
self.start = to;
|
||||
self.current = to;
|
||||
}
|
||||
|
||||
/// Draw a straight line from the current point to the given point.
|
||||
pub fn line_to(&mut self, to: Point<Pixels>) {
|
||||
self.contour_count += 1;
|
||||
|
@ -744,7 +751,8 @@ impl Path<Pixels> {
|
|||
self.current = to;
|
||||
}
|
||||
|
||||
fn push_triangle(
|
||||
/// Push a triangle to the Path.
|
||||
pub fn push_triangle(
|
||||
&mut self,
|
||||
xy: (Point<Pixels>, Point<Pixels>, Point<Pixels>),
|
||||
st: (Point<f32>, Point<f32>, Point<f32>),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue