Skip to content

Commit

Permalink
svg rect trim path fix and removing unused string processes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hernan-Dev committed Jun 19, 2015
1 parent 850a591 commit cbc7cd1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 63 deletions.
2 changes: 1 addition & 1 deletion player/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
<!-- endbuild -->
</head>
<body style="background-color:#fff; margin: 0px;height: 100%; font-family: sans-serif;font-size: 10px">
<div style="width:500px;height:500px;background-color:#000;display:inline-block" class="bodymovin" data-bm-path="exports/letters/full" data-bm-type="svg" data-bm-loop="true" data-bm-prerender="true"></div>
<div style="width:500px;height:500px;background-color:#000;display:inline-block" class="bodymovin" data-bm-path="exports/letters/full" data-bm-type="canvas" data-bm-loop="true" data-bm-prerender="true"></div>
</body>
</html>
68 changes: 6 additions & 62 deletions player/js/utils/DataManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,11 +640,7 @@ function dataFunctionManager(){
pathData.pathNodes = keyframes;
}
}else{
if(renderType == 'svg'){
pathData.pathNodes = trimPath(keyframes,pathData.closed, trimData, false);
}else{
pathData.pathNodes = trimPath(keyframes,pathData.closed, trimData, false);
}
pathData.pathNodes = trimPath(keyframes,pathData.closed, trimData, false);
}
return pathData;
}else{
Expand Down Expand Up @@ -687,11 +683,7 @@ function dataFunctionManager(){
pathData.pathNodes = keyframes.__minValue;
}
}else{
if(renderType == 'svg'){
pathData.pathNodes = trimPath(keyframes.__minValue,pathData.closed, trimData, false);
}else{
pathData.pathNodes = trimPath(keyframes.__minValue,pathData.closed, trimData, false);
}
pathData.pathNodes = trimPath(keyframes.__minValue,pathData.closed, trimData, false);
}
return pathData;
}else if(frameNum > keyframes[keyframes.length - 1].t-offsetTime){
Expand Down Expand Up @@ -726,11 +718,7 @@ function dataFunctionManager(){
pathData.pathNodes = keyframes.__maxValue;
}
}else{
if(renderType == 'svg'){
pathData.pathNodes = trimPath(keyframes.__maxValue,pathData.closed, trimData, false);
}else{
pathData.pathNodes = trimPath(keyframes.__maxValue,pathData.closed, trimData, false);
}
pathData.pathNodes = trimPath(keyframes.__maxValue,pathData.closed, trimData, false);
}
return pathData;
}else{
Expand Down Expand Up @@ -814,11 +802,7 @@ function dataFunctionManager(){
pathData.pathNodes = propertyArray[0];
}
}else{
if(renderType == 'svg'){
pathData.pathNodes = trimPath(propertyArray[0],pathData.closed, trimData, false);
}else{
pathData.pathNodes = trimPath(propertyArray[0],pathData.closed, trimData, false);
}
pathData.pathNodes = trimPath(propertyArray[0],pathData.closed, trimData, false);
}
return pathData;
}
Expand Down Expand Up @@ -1070,7 +1054,6 @@ function dataFunctionManager(){
renderedData.an.matrixArray = matrixInstance.getMatrixArrayFromParams(matrixParams.r,matrixParams.sx,matrixParams.sy,matrixParams.px,matrixParams.py);
}else{
renderedData.an.matrixArray = matrixInstance.getMatrixArrayFromParams(matrixParams.r,matrixParams.sx,matrixParams.sy,matrixParams.px,matrixParams.py);
renderedData.an.matrixValue = matrixInstance.getMatrix2FromParams(matrixParams.r,matrixParams.sx,matrixParams.sy,matrixParams.px,matrixParams.py) + 'translate('+ -dataOb.a[0]+' '+ -dataOb.a[1]+')';
}
item.renderedData[offsettedFrameNum] = renderedData;
if(item.hasMask){
Expand Down Expand Up @@ -1205,17 +1188,7 @@ function dataFunctionManager(){
closed: true
}
};
/*if(renderType == 'svg'){
pathData.pathString = trimPath(keyframes,pathData.closed, trimData, true);
}else{
pathData.pathNodes = trimPath(keyframes,pathData.closed, trimData, false);
}*/
if(renderType == 'svg'){
//shapeItem.renderedData[offsettedFrameNum].path.pathString = convertRectToPath(elmPos,elmSize,elmRound,renderType);
shapeItem.renderedData[offsettedFrameNum].path.pathString = trimPath(convertRectToPath(elmPos,elmSize,elmRound),true, addedTrim, true);
}else{
shapeItem.renderedData[offsettedFrameNum].path.pathNodes = trimPath(convertRectToPath(elmPos,elmSize,elmRound),true, addedTrim, false);
}
shapeItem.renderedData[offsettedFrameNum].path.pathNodes = trimPath(convertRectToPath(elmPos,elmSize,elmRound),true, addedTrim, false);
}
}else if(shapeItem.ty == 'el'){
elmPos = getInterpolatedValue(shapeItem.p,offsettedFrameNum, startTime,interpolatedParams);
Expand All @@ -1225,34 +1198,6 @@ function dataFunctionManager(){
size : elmSize
};
if(renderType == 'svg'){
var cp1X,cp1Y,cp2X,cp2Y;
var pathString = '';
pathString += 'M'+elmPos[0]+','+ (elmPos[1]-elmSize[1]/2);

cp1X = elmPos[0] - (elmSize[0]/2)*.55;
cp1Y = elmPos[1] - elmSize[1]/2;
cp2X = elmPos[0] - (elmSize[0]/2);
cp2Y = elmPos[1] - (elmSize[1]/2)*.55;
pathString += ' C'+cp1X+','+cp1Y+' '+cp2X+','+cp2Y+ ' '+(elmPos[0]-elmSize[0]/2)+','+elmPos[1];

cp1X = elmPos[0] - (elmSize[0]/2);
cp1Y = elmPos[1] + (elmSize[1]/2)*.55;
cp2X = elmPos[0] - (elmSize[0]/2)*.55;
cp2Y = elmPos[1] + (elmSize[1]/2);
pathString += ' C'+cp1X+','+cp1Y+' '+cp2X+','+cp2Y+ ' '+(elmPos[0])+','+(elmPos[1]+elmSize[1]/2);

cp1X = elmPos[0] + (elmSize[0]/2)*.55;
cp1Y = elmPos[1] + (elmSize[1]/2);
cp2X = elmPos[0] + (elmSize[0]/2);
cp2Y = elmPos[1] + (elmSize[1]/2)*.55;
pathString += ' C'+cp1X+','+cp1Y+' '+cp2X+','+cp2Y+ ' '+(elmPos[0]+elmSize[0]/2)+','+(elmPos[1]);


cp1X = elmPos[0] + (elmSize[0]/2);
cp1Y = elmPos[1] - (elmSize[1]/2)*.55;
cp2X = elmPos[0] + (elmSize[0]/2)*.55;
cp2Y = elmPos[1] - (elmSize[1]/2);
pathString += ' C'+cp1X+','+cp1Y+' '+cp2X+','+cp2Y+ ' '+(elmPos[0])+','+(elmPos[1]-elmSize[1]/2);

var pathNodes = {
v:[],
Expand All @@ -1272,7 +1217,7 @@ function dataFunctionManager(){
pathNodes.o.push([elmPos[0] + (elmSize[0]/2),elmPos[1] - (elmSize[1]/2)*.55]);
pathNodes.i.push([elmPos[0] + (elmSize[0]/2),elmPos[1] + (elmSize[1]/2)*.55]);

shapeItem.renderedData[offsettedFrameNum].path = {pathString:pathString,pathNodes:pathNodes};
shapeItem.renderedData[offsettedFrameNum].path = {pathNodes:pathNodes};
shapeItem.closed = true;
}
}else if(shapeItem.ty == 'st'){
Expand Down Expand Up @@ -1322,7 +1267,6 @@ function dataFunctionManager(){
shapeItem.renderedData[offsettedFrameNum].mtArr = matrixInstance.getMatrixArrayFromParams(matrixParams.r,matrixParams.sx,matrixParams.sy,matrixParams.px,matrixParams.py);
}else{
shapeItem.renderedData[offsettedFrameNum].mtArr = matrixInstance.getMatrixArrayFromParams(matrixParams.r,matrixParams.sx,matrixParams.sy,matrixParams.px,matrixParams.py);
shapeItem.renderedData[offsettedFrameNum].mt = matrixInstance.getMatrix2FromParams(matrixParams.r,matrixParams.sx,matrixParams.sy,matrixParams.px,matrixParams.py);
}
}else if(shapeItem.ty == 'tm'){
trimS = getInterpolatedValue(shapeItem.s,offsettedFrameNum, startTime,interpolatedParams);
Expand Down

0 comments on commit cbc7cd1

Please sign in to comment.