terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
16.69k stars 417 forks source link

Feature Request: Sketch Support for border-radius #1098

Open bonesmoses opened 1 year ago

bonesmoses commented 1 year ago

While using sketch mode, it would be nice to also have more rounded edges as well. Activating sketch currently ignores any previously supplied border-radius specifications.

PUJAmangale1221 commented 1 year ago

Hey Maintainers, I want to contribute to this issue how can I proceed to do so...?

alixander commented 1 year ago

@PUJAmangale1221 awesome, all yours!

After setting up the environment from CONTRIBUTING.md,

I would start by adding a test here, just a simple x.style.border-radius: 5.

https://github.com/terrastruct/d2/blob/4924a8babf39bd9adf7f9db1115c1d7bd13db1ac/d2renderers/d2sketch/sketch_test.go#L33

Run the test and save: TESTDATA_ACCEPT=1 ./ci/test.sh ./d2renderers/d2sketch/ -run TestSketch/name-of-your-test -v

Open the newly produced svg file, and seeing that it has no border radius.

The code that draws it in sketch mode is here:

https://github.com/terrastruct/d2/blob/4924a8babf39bd9adf7f9db1115c1d7bd13db1ac/d2renderers/d2sketch/sketch.go#L86

And then you can search in d2svg how regular border radius's are drawn for shapes that are not in sketch mode, and just modify the sketch drawing as appropriate, rerunning the test until it looks good.