- [SVG] Fix error when loading file.

This commit is contained in:
Tanasart 2024-06-15 09:24:51 +07:00
parent a06e66c453
commit 271bc53343
2 changed files with 6 additions and 9 deletions

View File

@ -18,7 +18,12 @@ function SVGElement(svgObj = noone) constructor {
stroke = struct_try_get(attr, "stroke", undefined);
stroke_width = struct_try_get(attr, "stroke-width", undefined);
if(is_string(fill)) fill = color_from_rgb(string_replace_all(fill, "#", ""));
if(is_string(stroke)) stroke = color_from_rgb(string_replace_all(stroke, "#", ""));
shapeAttr(attr);
return self;
}
static shapeAttr = function(attr) {}
@ -39,8 +44,6 @@ function SVG(svgObj = noone) : SVGElement(svgObj) constructor {
static mapX = function(px) { return lerp_invert(px, bbox[0], bbox[0] + bbox[2]) * width; }
static mapY = function(py) { return lerp_invert(py, bbox[1], bbox[1] + bbox[3]) * height; }
static setAttr = function(attr) {}
static getSurface = function(scale = 1) { return surface_create(width * scale, height * scale); }
static draw = function(scale = 1) {

View File

@ -13,7 +13,7 @@ function svg_parse(xmlStr) {
var ww = struct_try_get(attr, "width", 1);
var hh = struct_try_get(attr, "height", 1);
var svg = new SVG();
var svg = new SVG().setAttr(attr);
svg.width = toNumber(string_digits(ww));
svg.height = toNumber(string_digits(hh));
@ -25,12 +25,6 @@ function svg_parse(xmlStr) {
svg.bbox = bbox;
}
if(struct_has(attr, "fill")) {
var _f = attr.fill;
_f = string_replace_all(_f, "#", "");
svg.fill = color_from_rgb(_f);
}
if(struct_has(svg_object, "children")) {
var _ind = 0;