parseRectNode method
ShapePath
parseRectNode(
- XmlElement node
Implementation
ShapePath parseRectNode(XmlElement node) {
final x = parseFloatWithUnits(node.getAttribute('x') ?? '0');
final y = parseFloatWithUnits(node.getAttribute('y') ?? '0');
final rx = parseFloatWithUnits(node.getAttribute('rx') ?? '0');
final ry = parseFloatWithUnits(node.getAttribute('ry') ?? '0');
final w = parseFloatWithUnits(node.getAttribute('width'));
final h = parseFloatWithUnits(node.getAttribute('height'));
final 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;
}