Skip to content

Commit

Permalink
Merge pull request #1 from CubesterYT/develop
Browse files Browse the repository at this point in the history
Fix `rx` and `ry` attributes
  • Loading branch information
GarboMuffin authored Jul 16, 2024
2 parents ebf4bb2 + a0792cf commit 76c20bc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/svg/SvgImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,24 @@ new function() {

// https://www.w3.org/TR/SVG/shapes.html#RectElement
rect: function(node) {
var rx = SvgElement.get(node, 'rx');
var ry = SvgElement.get(node, 'ry');
if (rx === null && ry !== null) {
rx = ry;
} else if (ry === null && rx !== null) {
ry = rx;
}
if (/%\s*$/.test(rx)) {
rx = parseFloat(rx) * rootSize.width / 100;
}
if (/%\s*$/.test(ry)) {
ry = parseFloat(ry) * rootSize.height / 100;
}
var radius = rx !== null && ry !== null ? new Size(rx, ry) : null;
return new Shape.Rectangle(new Rectangle(
getPoint(node),
getSize(node)
), getSize(node, 'rx', 'ry'));
), radius);
},

// https://www.w3.org/TR/SVG/shapes.html#LineElement
Expand Down
9 changes: 9 additions & 0 deletions test/assets/rectangles.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion test/tests/SvgImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ if (!isNodeContext) {
'gradients-1': {},
'gradients-2': !isPhantomContext && {},
'gradients-3': {},
'gradients-4': {}
'gradients-4': {},
'rectangles': {}
};
Base.each(svgFiles, function(options, name) {
if (options) {
Expand Down

0 comments on commit 76c20bc

Please sign in to comment.