Skip to content

Commit

Permalink
fix: improve native method spec conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
msand committed Oct 6, 2019
1 parent 974f3a8 commit c63f9e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public WritableMap getCTM(int tag) {
return null;
}

float scale = svg.mScale;
Matrix ctm = new Matrix(svg.mCTM);
Matrix invViewBoxMatrix = svg.getSvgView().mInvViewBoxMatrix;
ctm.preConcat(invViewBoxMatrix);
Expand All @@ -171,8 +172,8 @@ public WritableMap getCTM(int tag) {
result.putDouble("b", values[Matrix.MSKEW_Y]);
result.putDouble("c", values[Matrix.MSKEW_X]);
result.putDouble("d", values[Matrix.MSCALE_Y]);
result.putDouble("e", values[Matrix.MTRANS_X]);
result.putDouble("f", values[Matrix.MTRANS_Y]);
result.putDouble("e", values[Matrix.MTRANS_X] / scale);
result.putDouble("f", values[Matrix.MTRANS_Y] / scale);
return result;
}

Expand All @@ -186,17 +187,15 @@ public WritableMap getScreenCTM(int tag) {

float[] values = new float[9];
svg.mCTM.getValues(values);

SvgView root = svg.getSvgView();
float scale = svg.mScale;

WritableMap result = Arguments.createMap();
result.putDouble("a", values[Matrix.MSCALE_X]);
result.putDouble("b", values[Matrix.MSKEW_Y]);
result.putDouble("c", values[Matrix.MSKEW_X]);
result.putDouble("d", values[Matrix.MSCALE_Y]);
result.putDouble("e", values[Matrix.MTRANS_X] + root.getLeft() / scale);
result.putDouble("f", values[Matrix.MTRANS_Y] + root.getTop() / scale);
result.putDouble("e", values[Matrix.MTRANS_X] / scale);
result.putDouble("f", values[Matrix.MTRANS_Y] / scale);
return result;
}
}
10 changes: 3 additions & 7 deletions ios/ViewManagers/RNSVGRenderableManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,14 @@ - (RNSVGRenderable *)node
}

RNSVGRenderable *svg = (RNSVGRenderable *)view;
RNSVGSvgView* root = svg.svgView;
CGAffineTransform viewbox = [root getViewBoxTransform];
CGAffineTransform ctm = CGAffineTransformConcat(svg.ctm, viewbox);
CGPoint offset = [root convertPoint:CGPointZero toView:svg.window];

CGAffineTransform ctm = svg.ctm;
return @{
@"a":@(ctm.a),
@"b":@(ctm.b),
@"c":@(ctm.c),
@"d":@(ctm.d),
@"e":@(ctm.tx + offset.x),
@"f":@(ctm.ty + offset.y)
@"e":@(ctm.tx),
@"f":@(ctm.ty)
};
}

Expand Down

0 comments on commit c63f9e2

Please sign in to comment.