parseRectNode method
dynamic
parseRectNode(
- dynamic node
Implementation
parseRectNode(node) {
var x = parseFloatWithUnits(node.getAttribute('x') ?? 0);
var y = parseFloatWithUnits(node.getAttribute('y') ?? 0);
var rx = parseFloatWithUnits(node.getAttribute('rx') ?? 0);
var ry = parseFloatWithUnits(node.getAttribute('ry') ?? 0);
var w = parseFloatWithUnits(node.getAttribute('width'));
var h = parseFloatWithUnits(node.getAttribute('height'));
var path = ShapePath();
path.moveTo(x + 2 * rx, y);
path.lineTo(x + w - 2 * rx, y);
if (rx != 0 || ry != 0) {
path.bezierCurveTo(x + w, y, x + w, y, x + w, y + 2 * ry);
}
path.lineTo(x + w, y + h - 2 * ry);
if (rx != 0 || ry != 0) {
path.bezierCurveTo(x + w, y + h, x + w, y + h, x + w - 2 * rx, y + h);
}
path.lineTo(x + 2 * rx, y + h);
if (rx != 0 || ry != 0) {
path.bezierCurveTo(x, y + h, x, y + h, x, y + h - 2 * ry);
}
path.lineTo(x, y + 2 * ry);
if (rx != 0 || ry != 0) {
path.bezierCurveTo(x, y, x, y, x + 2 * rx, y);
}
return path;
}