Skip to content

Commit

Permalink
fixed parsing problem in SvgToBezier.m
Browse files Browse the repository at this point in the history
  • Loading branch information
arielelkin committed Aug 2, 2012
1 parent e1ddbd5 commit 5d8a88c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions PocketSVG/SvgToBezier.m
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ - (void)appendSVGSCommand:(Token *)token
}
NSInteger index = 0;
while ((index + 3) < [token valence]) { // we must have 4 floats here (x2, y2, x, y).
CGFloat x1 = lastControlPoint.x; // + ([token command] == 's' ? lastPoint.x : 0);
CGFloat y1 = lastControlPoint.y; // + ([token command] == 's' ? lastPoint.y : 0);
CGFloat x1 = lastPoint.x + (lastPoint.x - lastControlPoint.x); // + ([token command] == 's' ? lastPoint.x : 0);
CGFloat y1 = lastPoint.y + (lastPoint.y - lastControlPoint.y); // + ([token command] == 's' ? lastPoint.y : 0);
CGFloat x2 = [token parameter:index++] + ([token command] == 's' ? lastPoint.x : 0);
CGFloat y2 = [token parameter:index++] + ([token command] == 's' ? lastPoint.y : 0);
CGFloat x = [token parameter:index++] + ([token command] == 's' ? lastPoint.x : 0);
Expand Down
7 changes: 4 additions & 3 deletions PocketSVG/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ - (void)viewDidLoad
{
[super viewDidLoad];

//Set the frame in which to draw our bezier curve.
//In this case, it's the screen's dimensions.
CGRect frameRect = [[UIScreen mainScreen] applicationFrame];
//Set the frame in which to draw our SVG:
CGRect frameRect = CGRectMake(0, 0, 1024, 768);

//Create an SvgTobezier with the content of our SVG's "d" string:
SvgToBezier *myBezier = [[SvgToBezier alloc] initFromSVGPathNodeDAttr:@"M176.17,369.617c0,0,335.106-189.361,214.894,38.298s129.787,282.978,178.723,42.553C618.724,210.042,834.681,87.702,790,307.915" rect:frameRect];

UIBezierPath *myPath = myBezier.bezier;

[myPath setLineWidth:3];

CAShapeLayer *myShapeLayer = [CAShapeLayer layer];
myShapeLayer.path = myPath.CGPath;

Expand Down

0 comments on commit 5d8a88c

Please sign in to comment.