From 40edd22d114603612e223796f593e1b214035490 Mon Sep 17 00:00:00 2001 From: Dave Aitken Date: Fri, 3 Oct 2025 10:09:10 +0100 Subject: [PATCH 1/3] fix: transform concatenation order --- Source/CoreGraphicsPolyfill.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/CoreGraphicsPolyfill.swift b/Source/CoreGraphicsPolyfill.swift index 36ec038..83c47ad 100644 --- a/Source/CoreGraphicsPolyfill.swift +++ b/Source/CoreGraphicsPolyfill.swift @@ -316,12 +316,12 @@ import Foundation public func concatenating(_ t: CGAffineTransform) -> CGAffineTransform { return CGAffineTransform( - a: a * t.a + c * t.b, - b: b * t.a + d * t.b, - c: a * t.c + c * t.d, - d: b * t.c + d * t.d, - tx: a * t.tx + c * t.ty + tx, - ty: b * t.tx + d * t.ty + ty + a: a * t.a + b * t.c, + b: a * t.b + b * t.d, + c: c * t.a + d * t.c, + d: c * t.b + d * t.d, + tx: tx * t.a + ty * t.c + t.tx, + ty: tx * t.b + ty * t.d + t.ty ) } From de77dbab1c63793673ba071b5393b0bd8df67ab3 Mon Sep 17 00:00:00 2001 From: Dave Aitken Date: Fri, 3 Oct 2025 12:10:23 +0100 Subject: [PATCH 2/3] test: update tests for new concat order --- Tests/CoreGraphicsPolyfillTests/PolyfillTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/CoreGraphicsPolyfillTests/PolyfillTests.swift b/Tests/CoreGraphicsPolyfillTests/PolyfillTests.swift index 3bab052..86555c9 100644 --- a/Tests/CoreGraphicsPolyfillTests/PolyfillTests.swift +++ b/Tests/CoreGraphicsPolyfillTests/PolyfillTests.swift @@ -84,8 +84,8 @@ final class PolyfillTests: XCTestCase { XCTAssertEqual(combined.a, 2) XCTAssertEqual(combined.d, 3) - XCTAssertEqual(combined.tx, 5) - XCTAssertEqual(combined.ty, 10) + XCTAssertEqual(combined.tx, 10) + XCTAssertEqual(combined.ty, 30) } func testTransformFluent() { From 886701bc7fb8bff06789040a1f383a9a4a515926 Mon Sep 17 00:00:00 2001 From: Dave Aitken Date: Fri, 3 Oct 2025 13:48:34 +0100 Subject: [PATCH 3/3] add test for standard impl of concat operation --- Tests/SVGViewTests/CGTests.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Tests/SVGViewTests/CGTests.swift diff --git a/Tests/SVGViewTests/CGTests.swift b/Tests/SVGViewTests/CGTests.swift new file mode 100644 index 0000000..41f926c --- /dev/null +++ b/Tests/SVGViewTests/CGTests.swift @@ -0,0 +1,17 @@ +import XCTest +@testable import SVGView + +class CGTests: BaseTestCase { + + func testTransformConcatenation() { + let transform1 = CGAffineTransform(translationX: 5, y: 10) + let transform2 = CGAffineTransform(scaleX: 2, y: 3) + let combined = transform1.concatenating(transform2) + + XCTAssertEqual(combined.a, 2) + XCTAssertEqual(combined.d, 3) + XCTAssertEqual(combined.tx, 10) + XCTAssertEqual(combined.ty, 30) + } + +}