Skip to content
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

support stroke dash offset function #1591

Closed
hermet opened this issue Aug 10, 2023 · 5 comments
Closed

support stroke dash offset function #1591

hermet opened this issue Aug 10, 2023 · 5 comments
Assignees
Labels
enhancement Improve features
Milestone

Comments

@hermet
Copy link
Member

hermet commented Aug 10, 2023

The "stroke dash offset" feature is commonly used.
The "stroke()" API might need to have an additional parameter to apply the offset in the drawing from the backend.

Result stroke(const float* dashPattern, uint32_t cnt) noexcept;
-> Result stroke(const float* dashPattern, uint32_t cnt, float offset = 0.0f) noexcept;

@hermet hermet added the feature New feature additions label Aug 10, 2023
@hermet hermet changed the title support stroke dash offset function. support stroke dash offset function Aug 10, 2023
@hermet hermet added enhancement Improve features and removed feature New feature additions labels Aug 10, 2023
@mgrudzinska mgrudzinska self-assigned this Aug 16, 2023
@mgrudzinska
Copy link
Collaborator

<svg viewBox="-10 0 50 20" xmlns="http://www.w3.org/2000/svg">
  <!-- No dash array -->
  <line x1="0" y1="1" x2="30" y2="1" stroke="black" />

  <!-- No dash offset -->
  <line x1="0" y1="3" x2="30" y2="3" stroke="black" stroke-dasharray="3.4 1.3 2 0.5" stroke-linecap="butt" />


  <line x1="0" y1="5" x2="30" y2="5" stroke="blue"
        stroke-dasharray="3.4 1.3 2 0.5" stroke-dashoffset="1.2" />

  <line x1="0" y1="6.1" x2="30" y2="6.1" stroke="blue"
        stroke-dasharray="3.4 1.3 2 0.5" stroke-dashoffset="8.4" />


  <line x1="0" y1="8" x2="30" y2="8" stroke="blue"
        stroke-dasharray="3.4 1.3 2 0.5" stroke-dashoffset="4.1" />

  <line x1="0" y1="9.1" x2="30" y2="9.1" stroke="blue"
        stroke-dasharray="3.4 1.3 2 0.5" stroke-dashoffset="11.3" />


  <line x1="0" y1="11" x2="30" y2="11" stroke="blue"
        stroke-dasharray="3.4 1.3 2 0.5" stroke-dashoffset="5.7" />

  <line x1="0" y1="12.1" x2="30" y2="12.1" stroke="blue"
        stroke-dasharray="3.4 1.3 2 0.5" stroke-dashoffset="12.9" />
</svg>

result from tvg after my changes (as expected):
Zrzut ekranu 2023-08-16 o 23 52 36

need to test negative values of offset and will be ready :)

@hermet hermet added this to the 1.0 milestone Aug 17, 2023
@hermet
Copy link
Member Author

hermet commented Aug 17, 2023

Great, I'm looking forward to the result. :-)

mgrudzinska added a commit to mgrudzinska/thorvg that referenced this issue Aug 17, 2023
The feature is supported also in the svg loader.

@issue: thorvg#1591
mgrudzinska added a commit to mgrudzinska/thorvg that referenced this issue Aug 17, 2023
The feature is supported also in the svg loader.

@issue: thorvg#1591
mgrudzinska added a commit to mgrudzinska/thorvg that referenced this issue Aug 17, 2023
The feature is supported also in the svg loader.

@issue: thorvg#1591
mgrudzinska added a commit to mgrudzinska/thorvg that referenced this issue Aug 17, 2023
The feature is supported also in the svg loader.

@issue: thorvg#1591
@mgrudzinska
Copy link
Collaborator

@hermet
changing api like this Result stroke(const float* dashPattern, uint32_t cnt, float offset = 0.0f) noexcept;
will cause a problem, because we have already Result stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;

so calling stroke(0, 255, 0) is ambiguous.
I'm not sure how to solve this... we could remove the def value of a but I assume that it's a common api, so probably not the best idea. so a new Result dashOffset(float offset) api?

@hermet
Copy link
Member Author

hermet commented Aug 18, 2023

how about -> strokeDash(dashPattern, patternCnt, offset) ?

@hermet
Copy link
Member Author

hermet commented Aug 18, 2023

ok, you already pushed a patch. Reverting alpha value might be better to go for now.

mgrudzinska added a commit to mgrudzinska/thorvg that referenced this issue Aug 18, 2023
The feature is supported also in the svg loader.

@issue: thorvg#1591
mgrudzinska added a commit to mgrudzinska/thorvg that referenced this issue Aug 19, 2023
The feature is supported also in the svg loader.

@issue: thorvg#1591
hermet pushed a commit that referenced this issue Aug 23, 2023
The feature is supported also in the svg loader.

@issue: #1591
@hermet hermet closed this as completed Aug 23, 2023
hermet pushed a commit that referenced this issue Aug 25, 2023
The feature is supported also in the svg loader.

@issue: #1591
@hermet hermet modified the milestones: 1.0, 0.11 Sep 4, 2023
capnm added a commit to capnm/godot4 that referenced this issue Sep 29, 2023
See https://github.com/thorvg/thorvg/releases/tag/v0.11.0

+ Infrastructure
    Repository folder structure was make it more intuitive and coherent.
        "thorvg/src/lib" -> "thorvg/src/common"
            (providing essential common functionalities
                used internally among the renderer and sub-modules)
        "thorvg/src/lib" -> "thorvg/src/renderer"
            (for vector drawing features)

+ SVG related
    Fix stroke regression thorvg/thorvg#1670
    Support stroke dash offset function thorvg/thorvg#1591 (comment)
    Support Focal property in Radial Gradient thorvg/thorvg#1558
capnm added a commit to capnm/godot4 that referenced this issue Sep 29, 2023
See https://github.com/thorvg/thorvg/releases/tag/v0.11.0

+ Infrastructure
    Repository folder structure was make it more intuitive and coherent.
        "thorvg/src/lib" -> "thorvg/src/common"
            (providing essential common functionalities
                used internally among the renderer and sub-modules)
        "thorvg/src/lib" -> "thorvg/src/renderer"
            (for vector drawing features)

+ SVG related
    Fix stroke regression thorvg/thorvg#1670
    Support stroke dash offset function thorvg/thorvg#1591 (comment)
    Support Focal property in Radial Gradient thorvg/thorvg#1558
capnm added a commit to capnm/godot4 that referenced this issue Sep 29, 2023
See https://github.com/thorvg/thorvg/releases/tag/v0.11.0

+ Infrastructure
    Repository folder structure was make it more intuitive and coherent.
        "thorvg/src/lib" -> "thorvg/src/common"
            (providing essential common functionalities
                used internally among the renderer and sub-modules)
        "thorvg/src/lib" -> "thorvg/src/renderer"
            (for vector drawing features)

+ SVG related
    Fix stroke regression thorvg/thorvg#1670
    Support stroke dash offset function thorvg/thorvg#1591 (comment)
    Support Focal property in Radial Gradient thorvg/thorvg#1558
mandryskowski pushed a commit to mandryskowski/godot that referenced this issue Oct 11, 2023
See https://github.com/thorvg/thorvg/releases/tag/v0.11.0

+ Infrastructure
    Repository folder structure was make it more intuitive and coherent.
        "thorvg/src/lib" -> "thorvg/src/common"
            (providing essential common functionalities
                used internally among the renderer and sub-modules)
        "thorvg/src/lib" -> "thorvg/src/renderer"
            (for vector drawing features)

+ SVG related
    Fix stroke regression thorvg/thorvg#1670
    Support stroke dash offset function thorvg/thorvg#1591 (comment)
    Support Focal property in Radial Gradient thorvg/thorvg#1558
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve features
Projects
Status: Done 0.11
Development

No branches or pull requests

2 participants