Skip to content

Conversation

@melsonic
Copy link
Contributor

@melsonic melsonic commented Apr 8, 2025

Before d2 was throwing error while using gradient color values in sketch mode. The error was originating from the following line

lc, err := color.LuminanceCategory(o.fill)

Basically, It can't parse a element fill value set as url('#grad-<hash>')

Now, as a part of the fix, we are checking fill value against a regex ^url\('#grad-[a-f0-9]{40}'\)$, it it matches, we set the luminance value to normal, since we don't have access to actual gradient-colors anymore. Else we calculate the luminance value from the color value.

/fixes #2481

Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a test to d2compiler?

@melsonic
Copy link
Contributor Author

can you add a test to d2compiler?

Sure, I was waiting for your review on the implementation part. Will add it in the next commit.

@melsonic melsonic requested a review from alixander April 10, 2025 20:15
@melsonic melsonic requested a review from alixander April 13, 2025 11:55
Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Lastly, could you add a line to next.md?

@melsonic
Copy link
Contributor Author

lgtm!

Lastly, could you add a line to next.md?

Sorry, I forgot to update it this time. Will update in next commit

@alixander alixander merged commit 31519e9 into terrastruct:master Apr 14, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linear gradients don't work with sketch mode

2 participants