-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Render List<String> as raw paths in SVG and Vello mode instead of ever becoming List<Vector> #4141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
2f9fd96
577228e
b702e34
c78e02e
e5ffec3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -77,6 +77,12 @@ pub const ATTR_SPREAD_METHOD: &str = "spread_method"; | |||||
| /// Gradient's `GradientType` (`Linear` or `Radial`). | ||||||
| pub const ATTR_GRADIENT_TYPE: &str = "gradient_type"; | ||||||
|
|
||||||
| /// Text item's font family (`String`, implicit default `"sans-serif"`). | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Doc comment claims implicit default Prompt for AI agents
Suggested change
|
||||||
| pub const ATTR_FONT_FAMILY: &str = "font_family"; | ||||||
|
|
||||||
| /// Text item's font size in document-space units (`f64`, implicit default `16.`). | ||||||
| pub const ATTR_FONT_SIZE: &str = "font_size"; | ||||||
|
|
||||||
| // ======================== | ||||||
| // TRAIT: AnyAttributeValue | ||||||
| // ======================== | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,7 @@ pub enum Graphic { | |||||||||||||||||||||||||||||||||||
| RasterGPU(List<Raster<GPU>>), | ||||||||||||||||||||||||||||||||||||
| Color(List<Color>), | ||||||||||||||||||||||||||||||||||||
| Gradient(List<GradientStops>), | ||||||||||||||||||||||||||||||||||||
| Text(List<String>), | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| impl Default for Graphic { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -103,6 +104,18 @@ impl From<List<GradientStops>> for Graphic { | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // String | ||||||||||||||||||||||||||||||||||||
| impl From<String> for Graphic { | ||||||||||||||||||||||||||||||||||||
| fn from(text: String) -> Self { | ||||||||||||||||||||||||||||||||||||
| Graphic::Text(List::new_from_element(text)) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| impl From<List<String>> for Graphic { | ||||||||||||||||||||||||||||||||||||
| fn from(text: List<String>) -> Self { | ||||||||||||||||||||||||||||||||||||
| Graphic::Text(text) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /// Deeply flattens a `List<Graphic>`, collecting only elements matching a specific variant (extracted by `extract_variant`) | ||||||||||||||||||||||||||||||||||||
| /// and discarding all other non-matching content. Recursion through `Graphic::Graphic` sub-`List`s composes transforms and opacity. | ||||||||||||||||||||||||||||||||||||
| fn flatten_graphic_list<T>(content: List<Graphic>, extract_variant: fn(Graphic) -> Option<List<T>>) -> List<T> { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -199,6 +212,12 @@ impl TryFromGraphic for GradientStops { | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| impl TryFromGraphic for String { | ||||||||||||||||||||||||||||||||||||
| fn try_from_graphic(graphic: Graphic) -> Option<List<Self>> { | ||||||||||||||||||||||||||||||||||||
| if let Graphic::Text(t) = graphic { Some(t) } else { None } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Local trait to convert types to List<Graphic> (avoids orphan rule issues) | ||||||||||||||||||||||||||||||||||||
| pub trait IntoGraphicList { | ||||||||||||||||||||||||||||||||||||
| fn into_graphic_list(self) -> List<Graphic>; | ||||||||||||||||||||||||||||||||||||
|
|
@@ -255,6 +274,12 @@ impl IntoGraphicList for List<GradientStops> { | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| impl IntoGraphicList for List<String> { | ||||||||||||||||||||||||||||||||||||
| fn into_graphic_list(self) -> List<Graphic> { | ||||||||||||||||||||||||||||||||||||
| List::new_from_element(Graphic::Text(self)) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+277
to
+281
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| impl IntoGraphicList for DAffine2 { | ||||||||||||||||||||||||||||||||||||
| fn into_graphic_list(self) -> List<Graphic> { | ||||||||||||||||||||||||||||||||||||
| List::new_from_element(Graphic::default()) | ||||||||||||||||||||||||||||||||||||
|
|
@@ -324,6 +349,7 @@ impl Graphic { | |||||||||||||||||||||||||||||||||||
| Graphic::RasterGPU(list) => all_clipped(list), | ||||||||||||||||||||||||||||||||||||
| Graphic::Color(list) => all_clipped(list), | ||||||||||||||||||||||||||||||||||||
| Graphic::Gradient(list) => all_clipped(list), | ||||||||||||||||||||||||||||||||||||
| Graphic::Text(list) => all_clipped(list), | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
@@ -348,6 +374,7 @@ impl BoundingBox for Graphic { | |||||||||||||||||||||||||||||||||||
| Graphic::Graphic(list) => list.bounding_box(transform, include_stroke), | ||||||||||||||||||||||||||||||||||||
| Graphic::Color(list) => list.bounding_box(transform, include_stroke), | ||||||||||||||||||||||||||||||||||||
| Graphic::Gradient(list) => list.bounding_box(transform, include_stroke), | ||||||||||||||||||||||||||||||||||||
| Graphic::Text(_) => RenderBoundingBox::Infinite, | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
@@ -359,6 +386,7 @@ impl BoundingBox for Graphic { | |||||||||||||||||||||||||||||||||||
| Graphic::Graphic(graphic) => graphic.thumbnail_bounding_box(transform, include_stroke), | ||||||||||||||||||||||||||||||||||||
| Graphic::Color(color) => color.thumbnail_bounding_box(transform, include_stroke), | ||||||||||||||||||||||||||||||||||||
| Graphic::Gradient(gradient) => gradient.thumbnail_bounding_box(transform, include_stroke), | ||||||||||||||||||||||||||||||||||||
| Graphic::Text(_) => RenderBoundingBox::Infinite, | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
@@ -388,6 +416,7 @@ impl RenderComplexity for Graphic { | |||||||||||||||||||||||||||||||||||
| Self::RasterGPU(list) => list.render_complexity(), | ||||||||||||||||||||||||||||||||||||
| Self::Color(list) => list.render_complexity(), | ||||||||||||||||||||||||||||||||||||
| Self::Gradient(list) => list.render_complexity(), | ||||||||||||||||||||||||||||||||||||
| Self::Text(list) => list.len(), | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Unnecessary per-frame font allocation overhead in
execute_networkPrompt for AI agents