Skip to content

Commit 8156beb

Browse files
committed
Update SVGPath to 1.1.5
1 parent 3c3c603 commit 8156beb

File tree

5 files changed

+49
-13
lines changed

5 files changed

+49
-13
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let package = Package(
2323
),
2424
.package(
2525
url: "https://github.com/nicklockwood/SVGPath.git",
26-
.upToNextMinor(from: "1.1.4")
26+
.upToNextMinor(from: "1.1.5")
2727
),
2828
],
2929
targets: [

SVGPath/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [1.1.5](https://github.com/nicklockwood/SVGPath/releases/tag/1.1.5) (2024-04-28)
2+
3+
- Fixed incorrect calculation for relative `moveTo` commands
4+
- Added `+=` and `-=` operators for `SVGPoint`
5+
16
## [1.1.4](https://github.com/nicklockwood/SVGPath/releases/tag/1.1.4) (2023-12-09)
27

38
- Fixed inverted arc rotation argument

SVGPath/SVGPath.xcodeproj/project.pbxproj

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@
162162
016FAB2021BFE78100AF60DC /* Project object */ = {
163163
isa = PBXProject;
164164
attributes = {
165-
LastSwiftUpdateCheck = 1010;
166-
LastUpgradeCheck = 1400;
165+
BuildIndependentTargetsInParallel = YES;
166+
LastSwiftUpdateCheck = 1530;
167+
LastUpgradeCheck = 1530;
167168
ORGANIZATIONNAME = "Nick Lockwood";
168169
TargetAttributes = {
169170
016FAB2821BFE78100AF60DC = {
@@ -428,6 +429,7 @@
428429
DYLIB_COMPATIBILITY_VERSION = 1;
429430
DYLIB_CURRENT_VERSION = 1;
430431
DYLIB_INSTALL_NAME_BASE = "@rpath";
432+
ENABLE_MODULE_VERIFIER = YES;
431433
FRAMEWORK_VERSION = A;
432434
INFOPLIST_FILE = Sources/Info.plist;
433435
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
@@ -436,7 +438,8 @@
436438
"@executable_path/../Frameworks",
437439
"@loader_path/Frameworks",
438440
);
439-
MARKETING_VERSION = 1.1.4;
441+
MARKETING_VERSION = 1.1.5;
442+
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
440443
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=75";
441444
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.SVGPath;
442445
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)";
@@ -465,6 +468,7 @@
465468
DYLIB_COMPATIBILITY_VERSION = 1;
466469
DYLIB_CURRENT_VERSION = 1;
467470
DYLIB_INSTALL_NAME_BASE = "@rpath";
471+
ENABLE_MODULE_VERIFIER = YES;
468472
FRAMEWORK_VERSION = A;
469473
INFOPLIST_FILE = Sources/Info.plist;
470474
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
@@ -473,7 +477,8 @@
473477
"@executable_path/../Frameworks",
474478
"@loader_path/Frameworks",
475479
);
476-
MARKETING_VERSION = 1.1.4;
480+
MARKETING_VERSION = 1.1.5;
481+
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
477482
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=75";
478483
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.SVGPath;
479484
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)";

SVGPath/SVGPath.xcodeproj/xcshareddata/xcschemes/SVGPath.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1400"
3+
LastUpgradeVersion = "1530"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

SVGPath/Sources/SVGPath.swift

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public struct SVGPath: Hashable {
100100
}
101101
var control = lastPoint - lastControl
102102
if !isRelative {
103-
control = control + lastPoint
103+
control += lastPoint
104104
}
105105
return .quadratic(control, SVGPoint(x: numbers[0], y: -numbers[1]))
106106
}
@@ -123,7 +123,7 @@ public struct SVGPath: Hashable {
123123
}
124124
var control = lastPoint - lastControl
125125
if !isRelative {
126-
control = control + lastPoint
126+
control += lastPoint
127127
}
128128
return .cubic(
129129
control,
@@ -162,7 +162,7 @@ public struct SVGPath: Hashable {
162162

163163
func appendCommand(_ command: SVGCommand) {
164164
commands.append(
165-
isRelative ? command.relative(to: commands.lastPoint) : command
165+
isRelative ? command.relative(to: commands) : command
166166
)
167167
}
168168

@@ -317,6 +317,13 @@ private extension Array where Element == SVGCommand {
317317
}
318318
return .zero
319319
}
320+
321+
var lastMove: SVGPoint {
322+
for case let .moveTo(point) in reversed() {
323+
return point
324+
}
325+
return .zero
326+
}
320327
}
321328

322329
public enum SVGError: Error, Hashable {
@@ -360,6 +367,15 @@ public extension SVGCommand {
360367
}
361368
}
362369

370+
private var startPoint: SVGPoint? {
371+
switch self {
372+
case let .moveTo(point):
373+
return point
374+
default:
375+
return nil
376+
}
377+
}
378+
363379
var control1: SVGPoint? {
364380
switch self {
365381
case let .cubic(control1, _, _), let .quadratic(control1, _):
@@ -441,18 +457,20 @@ public extension SVGCommand {
441457
}
442458
}
443459

444-
fileprivate func relative(to last: SVGPoint) -> SVGCommand {
460+
fileprivate func relative(to commands: [SVGCommand]) -> SVGCommand {
445461
switch self {
446462
case let .moveTo(point):
447-
return .moveTo(point + last)
463+
return .moveTo(point + commands.lastMove)
448464
case let .lineTo(point):
449-
return .lineTo(point + last)
465+
return .lineTo(point + commands.lastPoint)
450466
case let .cubic(control1, control2, point):
467+
let last = commands.lastPoint
451468
return .cubic(control1 + last, control2 + last, point + last)
452469
case let .quadratic(control, point):
470+
let last = commands.lastPoint
453471
return .quadratic(control + last, point + last)
454472
case let .arc(arc):
455-
return .arc(arc.relative(to: last))
473+
return .arc(arc.relative(to: commands.lastPoint))
456474
case .end:
457475
return .end
458476
}
@@ -475,9 +493,17 @@ public extension SVGPoint {
475493
SVGPoint(x: lhs.x + rhs.x, y: lhs.y + rhs.y)
476494
}
477495

496+
static func += (lhs: inout SVGPoint, rhs: SVGPoint) {
497+
lhs = lhs + rhs
498+
}
499+
478500
static func - (lhs: SVGPoint, rhs: SVGPoint) -> SVGPoint {
479501
SVGPoint(x: lhs.x - rhs.x, y: lhs.y - rhs.y)
480502
}
503+
504+
static func -= (lhs: inout SVGPoint, rhs: SVGPoint) {
505+
lhs = lhs - rhs
506+
}
481507
}
482508

483509
public struct SVGArc: Hashable {

0 commit comments

Comments
 (0)