Socket
Socket
Sign inDemoInstall

svgo

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svgo - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

5

CHANGELOG.md

@@ -0,1 +1,6 @@

### [ [>](https://github.com/svg/svgo/tree/v0.3.4) ] 0.3.4 / 06.05.2013
* plugins/convertPathData: fix m->M bug in some cases
* plugins/transformsWithOnePath: fix last point calculation for C/S/Q/T
* plugins/mergePaths: add space delimiter between z and m
### [ [>](https://github.com/svg/svgo/tree/v0.3.3) ] 0.3.3 / 05.05.2013

@@ -2,0 +7,0 @@ * plugins/convertPathData: convert very first m to M, fix applyTransforms with translate() (fix [#112](https://github.com/svg/svgo/issues/112))

2

package.json
{
"name": "svgo",
"version": "0.3.3",
"version": "0.3.4",
"description": "Nodejs-based tool for optimizing SVG vector graphics files",

@@ -5,0 +5,0 @@ "keywords": [ "svgo", "svg", "optimize", "minify" ],

@@ -195,3 +195,2 @@ 'use strict';

var matrix = transformsMultiply(transform2js(elem.attr('transform').value)),
currentPoint = [0, 0],
newPoint;

@@ -243,7 +242,2 @@

currentPoint[0] += pathItem.data[pathItem.data.length - 2];
currentPoint[1] += pathItem.data[pathItem.data.length - 1];
pathItem.point = currentPoint.slice(0);
}

@@ -250,0 +244,0 @@

@@ -231,3 +231,2 @@ 'use strict';

item.data = data;
item.point = point.slice(0);

@@ -239,2 +238,3 @@ }

point = subpathPoint;
mM = false;
}

@@ -259,6 +259,3 @@

data,
point = [0, 0],
prev = {
point: [0, 0]
};
prev;

@@ -269,3 +266,2 @@ path = path.filter(function(item) {

data = item.data;
point = item.point;

@@ -310,3 +306,3 @@ if (data) {

else if (
prev.item &&
prev &&
instruction === 'q' &&

@@ -332,9 +328,9 @@ isCurveStraightLine(

if (
prev.item &&
prev.item.original &&
prev.item.original.instruction === 'q'
prev &&
prev.original &&
prev.original.instruction === 'q'
) {
if (isCurveStraightLine(
[ prev.item.original.data[0], prev.item.original.data[2], data[0] ],
[ prev.item.original.data[1], prev.item.original.data[3], data[1] ]
[ prev.original.data[0], prev.original.data[2], data[0] ],
[ prev.original.data[1], prev.original.data[3], data[1] ]
)) {

@@ -344,4 +340,4 @@ instruction = 'l';

} else {
prev.item.instruction = 'q';
prev.item.data = prev.item.original.data;
prev.instruction = 'q';
prev.data = prev.original.data;
}

@@ -351,3 +347,3 @@ }

// [^qt] + t
else if (!prev.item || 'qt'.indexOf(prev.item.instruction) === -1) {
else if (!prev || 'qt'.indexOf(prev.instruction) === -1) {
instruction = 'l';

@@ -386,3 +382,3 @@ data = data.slice(-2);

// convert curves into smooth shorthands
if (params.curveSmoothShorthands && prev.item) {
if (params.curveSmoothShorthands && prev) {

@@ -394,5 +390,5 @@ // curveto

if (
prev.item.instruction === 'c' &&
data[0] === -(prev.item.data[2] - prev.item.data[4]) &&
data[1] === -(prev.item.data[3] - prev.item.data[5])
prev.instruction === 'c' &&
data[0] === -(prev.data[2] - prev.data[4]) &&
data[1] === -(prev.data[3] - prev.data[5])
) {

@@ -405,5 +401,5 @@ instruction = 's';

else if (
prev.item.instruction === 's' &&
data[0] === -(prev.item.data[0] - prev.item.data[2]) &&
data[1] === -(prev.item.data[1] - prev.item.data[3])
prev.instruction === 's' &&
data[0] === -(prev.data[0] - prev.data[2]) &&
data[1] === -(prev.data[1] - prev.data[3])
) {

@@ -416,3 +412,3 @@ instruction = 's';

else if (
'cs'.indexOf(prev.item.instruction) === -1 &&
'cs'.indexOf(prev.instruction) === -1 &&
data[0] === 0 &&

@@ -432,5 +428,5 @@ data[1] === 0

if (
prev.item.instruction === 'q' &&
data[0] === (prev.item.data[2] - prev.item.data[0]) &&
data[1] === (prev.item.data[3] - prev.item.data[1])
prev.instruction === 'q' &&
data[0] === (prev.data[2] - prev.data[0]) &&
data[1] === (prev.data[3] - prev.data[1])
) {

@@ -443,5 +439,5 @@ instruction = 't';

else if (
prev.item.instruction === 't' &&
data[2] === prev.item.data[0] &&
data[3] === prev.item.data[1]
prev.instruction === 't' &&
data[2] === prev.data[0] &&
data[3] === prev.data[1]
) {

@@ -483,6 +479,3 @@ instruction = 't';

prev = {
item: item,
point: point.slice(0)
};
prev = item;

@@ -489,0 +482,0 @@ }

@@ -19,3 +19,4 @@ 'use strict';

var prevContentItem;
var prevContentItem,
delim = '';

@@ -34,4 +35,10 @@ item.content = item.content.filter(function(contentItem) {

) {
prevContentItem.attr('d').value += contentItem.attr('d').value;
// "zM", but "z m"
// looks like a FontForge parsing bug
if (contentItem.attr('d').value.charAt(0) === 'm') {
delim = ' ';
}
prevContentItem.attr('d').value += delim + contentItem.attr('d').value;
return false;

@@ -38,0 +45,0 @@ }

@@ -58,8 +58,8 @@ 'use strict';

ys = [],
currentPoint = [0, 0],
controlPoint,
controlPoint = [0, 0],
cubicBoundingBox,
quadraticBoundingBox,
i,
segment;
segment,
lastPoint = [0, 0];

@@ -81,2 +81,5 @@ path.forEach(function(pathItem) {

controlPoint = pathItem.data.slice(-2);
lastPoint = pathItem.data.slice(-2);
// H

@@ -89,2 +92,5 @@ } else if (pathItem.instruction === 'H') {

controlPoint[0] = pathItem.data[pathItem.data.length - 2];
lastPoint[0] = pathItem.data[pathItem.data.length - 2];
// V

@@ -97,2 +103,5 @@ } else if (pathItem.instruction === 'V') {

controlPoint[1] = pathItem.data[pathItem.data.length - 1];
lastPoint[1] = pathItem.data[pathItem.data.length - 1];
// C

@@ -105,3 +114,3 @@ } else if (pathItem.instruction === 'C') {

cubicBoundingBox = computeCubicBoundingBox.apply(this, currentPoint.concat(segment));
cubicBoundingBox = computeCubicBoundingBox.apply(this, lastPoint.concat(segment));

@@ -120,4 +129,3 @@ xs.push(cubicBoundingBox.minx);

currentPoint[0] = segment[4];
currentPoint[1] = segment[5];
lastPoint = pathItem.data.slice(-2);

@@ -133,3 +141,3 @@ }

cubicBoundingBox = computeCubicBoundingBox.apply(this, currentPoint.concat(controlPoint).concat(segment));
cubicBoundingBox = computeCubicBoundingBox.apply(this, lastPoint.concat(controlPoint).concat(segment));

@@ -148,4 +156,3 @@ xs.push(cubicBoundingBox.minx);

currentPoint[0] = segment[2];
currentPoint[1] = segment[3];
lastPoint = pathItem.data.slice(-2);

@@ -161,3 +168,3 @@ }

quadraticBoundingBox = computeQuadraticBoundingBox.apply(this, currentPoint.concat(segment));
quadraticBoundingBox = computeQuadraticBoundingBox.apply(this, lastPoint.concat(segment));

@@ -176,4 +183,3 @@ xs.push(quadraticBoundingBox.minx);

currentPoint[0] = segment[2];
currentPoint[1] = segment[3];
lastPoint = pathItem.data.slice(-2);

@@ -189,3 +195,3 @@ }

quadraticBoundingBox = computeQuadraticBoundingBox.apply(this, currentPoint.concat(controlPoint).concat(segment));
quadraticBoundingBox = computeQuadraticBoundingBox.apply(this, lastPoint.concat(controlPoint).concat(segment));

@@ -198,10 +204,10 @@ xs.push(quadraticBoundingBox.minx);

// TODO: BUGGY
// reflected control point for the next possible T
controlPoint = [
2 * segment[0] - segment[0],
2 * segment[1] - segment[1]
2 * segment[0] - lastPoint[0],
2 * segment[1] - lastPoint[1]
];
currentPoint[0] = segment[0];
currentPoint[1] = segment[1];
lastPoint = pathItem.data.slice(-2);

@@ -212,8 +218,2 @@ }

if (pathItem.data) {
currentPoint = pathItem.point;
}
});

@@ -229,4 +229,2 @@

realHeight = Math.round(ymax - ymin),
centerX = realWidth / 2,
centerY = realHeight / 2,
transform = '',

@@ -243,4 +241,4 @@ scale;

svgElem.attr('width').value = params.width;
svgElem.attr('height').value = params.height;
svgWidth = svgElem.attr('width').value = params.width;
svgHeight = svgElem.attr('height').value = params.height;

@@ -257,4 +255,4 @@ transform += ' scale(' + scale + ')';

svgElem.attr('width').value = params.width;
svgElem.attr('height').value = svgHeight * scale;
svgWidth = svgElem.attr('width').value = params.width;
svgHeight = svgElem.attr('height').value = svgHeight * scale;

@@ -271,4 +269,4 @@ transform += ' scale(' + scale + ')';

svgElem.attr('width').value = svgWidth * scale;
svgElem.attr('height').value = params.height;
svgWidth = svgElem.attr('width').value = svgWidth * scale;
svgHeight = svgElem.attr('height').value = params.height;

@@ -281,5 +279,3 @@ transform += ' scale(' + scale + ')';

if (params.shiftX) {
var shiftX = params.shiftX;
transform += ' translate(' + realWidth * shiftX + ', 0)';
transform += ' translate(' + realWidth * params.shiftX + ', 0)';
}

@@ -289,5 +285,3 @@

if (params.shiftY) {
var shiftY = params.shiftY;
transform += ' translate(0, ' + realHeight * shiftY + ')';
transform += ' translate(0, ' + realHeight * params.shiftY + ')';
}

@@ -299,12 +293,12 @@

var shiftX = svgWidth / 2,
shiftY = svgHeight / 2;
realWidth = realWidth * scale;
realHeight = realHeight * scale;
centerX = realWidth / 2;
centerY = realHeight / 2;
if (params.shiftX || params.shiftY) {
transform += ' scale(' + scale + ')';
} else {
transform += ' translate(' + (-centerX * (scale - 1)) + ', ' + (-centerY * (scale - 1)) + ') scale(' + scale + ')';
transform += ' translate(' + shiftX + ' ' + shiftY + ') scale(' + scale + ') translate(-' + shiftX + ' -' + shiftY + ')';
}

@@ -311,0 +305,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc