SlugFiller / godot-vector2d

2D vector graphics plugin for Godot
The Unlicense
2 stars 1 forks source link

Rounded corners on rect in parse_rect incorrectly require both rx and ry #5

Open lostminds opened 4 months ago

lostminds commented 4 months ago

In parse_rect: https://github.com/SlugFiller/godot-vector2d/blob/bd7940f568aee89a133b6995bbc7bf17bb4eb251/addons/vector2d/svg.gd#L568 it checks for both rx and ry to see if the rect should have rounded corners. However, this misses cases where only rx is set, which I think should be interpreted as a single radius used for both rx and ry.

Like for example in the Godot icon.svg file background rect: <rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/>

SlugFiller commented 4 months ago

Ah, you're correct. Some sites document the default for rx/ry to be 0, but the specs state the default is auto, which basically means "copy from the other option, after doing percentage->pixels conversion if necessary". To fix this, special handling for missing/auto would need to be added. Although, from the get-go, percentage values are not supported by this parser (It is a percentage of the SVG viewport, and that data point is not used). Also, negative values are also supposed to be interpreted as auto.