Add focal point, focal radius#4139
Conversation
|
@jsjgdh I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
Code Review
This pull request enhances gradient support by introducing focal points, focal radii, and gradient units to the Gradient structure. It improves SVG import capabilities by adding support for percentage-based offsets, 3-digit hex colors, and named CSS colors via the svgtypes crate. Additionally, it implements a mechanism for gradient stops to inherit from other gradients using href. Feedback focuses on making the href resolution more robust to handle multi-level or out-of-order references and simplifying the color parsing logic to better utilize the svgtypes library and correctly handle alpha multiplication.
There was a problem hiding this comment.
1 issue found across 10 files
Confidence score: 4/5
- This PR looks generally safe to merge, but there is a moderate, user-visible rendering issue in
editor/src/messages/portfolio/document/graph_operation/graph_operation_message_handler.rswhere parsed color alpha is dropped. - The most significant impact is that stop-colors using embedded alpha (for example
rgba(...),hsla(...), or 8-digit hex) may render with incorrect opacity, which can change gradient appearance. - Given the single mid-severity finding (5/10) with good confidence, this is a limited-risk fix area rather than a likely broad regression.
- Pay close attention to
editor/src/messages/portfolio/document/graph_operation/graph_operation_message_handler.rs- preserve and propagatec.alphawhen converting parsed colors.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="editor/src/messages/portfolio/document/graph_operation/graph_operation_message_handler.rs">
<violation number="1" location="editor/src/messages/portfolio/document/graph_operation/graph_operation_message_handler.rs:625">
P2: `svgtypes::Color::from_str` already parses alpha for formats like `rgba(...)`, `hsla(...)`, and 8-digit hex, but the alpha component (`c.alpha`) is discarded here. This means any stop-color with an embedded alpha channel will lose it. Furthermore, per SVG2, the final opacity should be `(c.alpha / 255) * stop_opacity` — a product of the color's alpha and the `stop-opacity` attribute — but `parse_stop_color` currently uses `alpha.unwrap_or(opacity)`, choosing one or the other instead of multiplying them.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
@jsjgdh I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 11 files
Confidence score: 3/5
- In
node-graph/libraries/rendering/src/render_ext.rs, thegradientUnitswrite condition appears inverted, soUserSpaceOnUseis skipped and SVG renderers can fall back to the default coordinate space, producing visibly incorrect gradients for affected exports — fix the condition (and ideally add a regression test forUserSpaceOnUse) before merging.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="node-graph/libraries/rendering/src/render_ext.rs">
<violation number="1" location="node-graph/libraries/rendering/src/render_ext.rs:57">
P1: `gradientUnits` emission condition is inverted: `UserSpaceOnUse` (non-default) is omitted, causing SVG consumers to misinterpret the gradient coordinate space</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| format!(r#" spreadMethod="{}""#, self.spread_method.svg_name()) | ||
| }; | ||
|
|
||
| let gradient_units = if self.gradient_units == GradientUnits::UserSpaceOnUse { |
There was a problem hiding this comment.
P1: gradientUnits emission condition is inverted: UserSpaceOnUse (non-default) is omitted, causing SVG consumers to misinterpret the gradient coordinate space
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At node-graph/libraries/rendering/src/render_ext.rs, line 57:
<comment>`gradientUnits` emission condition is inverted: `UserSpaceOnUse` (non-default) is omitted, causing SVG consumers to misinterpret the gradient coordinate space</comment>
<file context>
@@ -54,21 +54,39 @@ impl RenderExt for Gradient {
format!(r#" spreadMethod="{}""#, self.spread_method.svg_name())
};
+ let gradient_units = if self.gradient_units == GradientUnits::UserSpaceOnUse {
+ String::new()
+ } else {
</file context>
4b7a823 to
847b8e9
Compare
15fcaac to
d5f0140
Compare
Enhance gradient functionality with new features:
fx/fy/frattributeshref-based stop inheritance is handled