In SVGPathEditor, when drawing a path element with elliptical arc segments, dragging the mouse will adjust the x and y radius values according to the mouse distance from the arc endpoint. If the option key is pressed, the x and y radius are set with independent values; otherwise, the larger value of the x or y distance from the endpoint is used for both radius values.

This commit is contained in:
dsward2
2017-03-05 23:29:43 -06:00
committed by dsward2
parent 98b5f6bde5
commit 2f87bbc6cb
2 changed files with 56 additions and 23 deletions
+1 -1
View File
@@ -105,7 +105,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0399</string>
<string>0407</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.graphics-design</string>
<key>LSMinimumSystemVersion</key>
+55 -22
View File
@@ -3188,6 +3188,7 @@ NSPoint bezierMidPoint(NSPoint p0, NSPoint p1, NSPoint p2)
}
case 'A': // elliptical arc absolute
{
// vary the arc x and y radius with mouse dragging
NSString * xString = pathSegmentDictionary[@"x"];
NSString * yString = pathSegmentDictionary[@"y"];
@@ -3197,41 +3198,73 @@ NSPoint bezierMidPoint(NSPoint p0, NSPoint p1, NSPoint p2)
float deltaX = domMouseEventsController.currentMousePoint.x - x;
float deltaY = domMouseEventsController.currentMousePoint.y - y;
float newX = x - deltaX;
float newY = y - deltaY;
NSString * newXString = [self allocFloatString:newX];
NSString * newYString = [self allocFloatString:newY];
deltaX = fabs(deltaX);
deltaY = fabs(deltaY);
pathSegmentDictionary[@"x"] = newXString;
pathSegmentDictionary[@"y"] = newYString;
CGEventRef event = CGEventCreate(NULL);
CGEventFlags modifiers = CGEventGetFlags(event);
CFRelease(event);
//CGEventFlags flags = (kCGEventFlagMaskShift | kCGEventFlagMaskCommand);
CGEventFlags flags = (kCGEventFlagMaskAlternate); // check for option key
if ((modifiers & flags) == 0)
{
// option key not pressed
if (deltaX > deltaY)
{
deltaY = deltaX;
}
else
{
deltaX = deltaY;
}
}
NSString * radiusXString = [self allocFloatString:deltaX];
NSString * radiusYString = [self allocFloatString:deltaY];
pathSegmentDictionary[@"rx"] = radiusXString; // radius x
pathSegmentDictionary[@"ry"] = radiusYString; // radius y
break;
}
case 'a': // elliptical arc relative
{
NSPoint currentPathPoint = [self absoluteXYPointAtPathSegmentIndex:(self.pathSegmentIndex - 1)];
// vary the arc x and y radius with mouse dragging
NSString * xString = pathSegmentDictionary[@"x"];
NSString * yString = pathSegmentDictionary[@"y"];
float x = xString.floatValue;
float y = yString.floatValue;
float mouseRelX = domMouseEventsController.currentMousePoint.x - currentPathPoint.x;
float mouseRelY = domMouseEventsController.currentMousePoint.y - currentPathPoint.y;
float deltaX = domMouseEventsController.currentMousePoint.x - x;
float deltaY = domMouseEventsController.currentMousePoint.y - y;
float deltaX = x - mouseRelX ;
float deltaY = y - mouseRelY;
float newX = x + deltaX;
float newY = y + deltaY;
NSString * newXString = [self allocFloatString:newX];
NSString * newYString = [self allocFloatString:newY];
deltaX = fabs(deltaX);
deltaY = fabs(deltaY);
pathSegmentDictionary[@"x"] = newXString;
pathSegmentDictionary[@"y"] = newYString;
CGEventRef event = CGEventCreate(NULL);
CGEventFlags modifiers = CGEventGetFlags(event);
CFRelease(event);
//CGEventFlags flags = (kCGEventFlagMaskShift | kCGEventFlagMaskCommand);
CGEventFlags flags = (kCGEventFlagMaskAlternate); // check for option key
if ((modifiers & flags) == 0)
{
// option key not pressed
if (deltaX > deltaY)
{
deltaY = deltaX;
}
else
{
deltaX = deltaY;
}
}
NSString * radiusXString = [self allocFloatString:deltaX];
NSString * radiusYString = [self allocFloatString:deltaY];
pathSegmentDictionary[@"rx"] = radiusXString; // radius x
pathSegmentDictionary[@"ry"] = radiusYString; // radius y
break;
}