Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just a couple of personal fixes #86

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ function parsePathD(pathData) {
path += " ";
}

return wordwrap(path.trim(), 80, "\n");
return path.trim();
}


Expand Down Expand Up @@ -515,11 +515,11 @@ function printPath(pathData, stylesArray, groupLevel, clipPath) {
}

//If strokeWidth is needed but omitted, default to 1
var needsStrokeWidth = (typeof styles["stroke"] !== "undefined") ||
(typeof styles["stroke-opacity"] !== "undefined") ||
(typeof styles["stroke-alpha"] !== "undefined") ||
(typeof styles["stroke-linejoin"] !== "undefined") ||
(typeof styles["stroke-miterlimit"] !== "undefined") ||
var needsStrokeWidth = (typeof styles["stroke"] !== "undefined") ||
(typeof styles["stroke-opacity"] !== "undefined") ||
(typeof styles["stroke-alpha"] !== "undefined") ||
(typeof styles["stroke-linejoin"] !== "undefined") ||
(typeof styles["stroke-miterlimit"] !== "undefined") ||
(typeof styles["stroke-linecap"] !== "undefined");
if (needsStrokeWidth && (typeof styles["stroke-width"] === "undefined")) {
styles["stroke-width"] = "1";
Expand Down Expand Up @@ -589,6 +589,8 @@ function generateCode(inputXml) {
var dimensions = getDimensions(svg);
var width = dimensions.width;
var height = dimensions.height;
var viewportWidth = dimensions.viewportWidth;
var viewportHeight = dimensions.viewportHeight;

//XML Vector start
generatedOutput = '<?xml version="1.0" encoding="utf-8"?>\n';
Expand All @@ -597,8 +599,8 @@ function generateCode(inputXml) {
generatedOutput += '\n' + INDENT + 'android:width="{0}dp"\n'.f(width);
generatedOutput += INDENT + 'android:height="{0}dp"\n'.f(height);

generatedOutput += INDENT + 'android:viewportWidth="{0}"\n'.f(width);
generatedOutput += INDENT + 'android:viewportHeight="{0}"'.f(height);
generatedOutput += INDENT + 'android:viewportWidth="{0}"\n'.f(viewportWidth);
generatedOutput += INDENT + 'android:viewportHeight="{0}"'.f(viewportHeight);

generatedOutput += '>\n\n';

Expand Down Expand Up @@ -690,14 +692,19 @@ function getDimensions(svg) {
pushUnique(warnings, "width or height not set for svg (set -1)");
return {width: -1, height: -1};
} else {
return {width: convertDimensionToPx(widthAttr), height: convertDimensionToPx(heightAttr)};
return {width: convertDimensionToPx(widthAttr), height: convertDimensionToPx(heightAttr), viewportWidth: convertDimensionToPx(widthAttr), viewportHeight: convertDimensionToPx(heightAttr)};
}
} else {
var viewBoxAttrParts = viewBoxAttr.split(/[,\s]+/);
if (viewBoxAttrParts[0] > 0 || viewBoxAttrParts[1] > 0) {
pushUnique(warnings, "viewbox minx/miny is other than 0 (not supported)");
}
return {width: viewBoxAttrParts[2], height: viewBoxAttrParts[3]};

if (typeof widthAttr === "undefined" || typeof heightAttr === "undefined") {
return {width: viewBoxAttrParts[2], height: viewBoxAttrParts[3], viewportWidth: viewBoxAttrParts[2], viewportHeight: viewBoxAttrParts[3]};
} else {
return {width: convertDimensionToPx(widthAttr), height: convertDimensionToPx(heightAttr), viewportWidth: viewBoxAttrParts[2], viewportHeight: viewBoxAttrParts[3]};
}
}

}
Expand Down Expand Up @@ -876,4 +883,4 @@ function showLastUpdate(repo) {
}
});
});
}
}