Skip to content

Commit 1de9dc1

Browse files
committed
Rename CGConetxtCoordinates.adjusted to .natural
1 parent fcd6b31 commit 1de9dc1

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

Sources/EasyImagy/ImageCoreGraphics.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Foundation
44

55
public enum CGContextCoordinates {
66
case original
7-
case adjusted
7+
case natural
88
}
99

1010
extension Image where Pixel == RGBA<UInt8> {
@@ -350,7 +350,7 @@ extension Image where Pixel == PremultipliedRGBA<UInt8> {
350350
)
351351
}
352352

353-
public mutating func withCGContext(coordinates: CGContextCoordinates = .adjusted, _ body: (CGContext) throws -> Void) rethrows {
353+
public mutating func withCGContext(coordinates: CGContextCoordinates = .natural, _ body: (CGContext) throws -> Void) rethrows {
354354
let width = self.width
355355
let height = self.height
356356

@@ -369,7 +369,7 @@ extension Image where Pixel == PremultipliedRGBA<UInt8> {
369369
switch coordinates {
370370
case .original:
371371
break
372-
case .adjusted:
372+
case .natural:
373373
context.scaleBy(x: 1, y: -1)
374374
context.translateBy(x: 0.5, y: 0.5 - CGFloat(height))
375375
}
@@ -430,7 +430,7 @@ extension Image where Pixel == PremultipliedRGBA<UInt16> {
430430
)
431431
}
432432

433-
public mutating func withCGContext(coordinates: CGContextCoordinates = .adjusted, _ body: (CGContext) throws -> Void) rethrows {
433+
public mutating func withCGContext(coordinates: CGContextCoordinates = .natural, _ body: (CGContext) throws -> Void) rethrows {
434434
let width = self.width
435435
let height = self.height
436436

@@ -449,7 +449,7 @@ extension Image where Pixel == PremultipliedRGBA<UInt16> {
449449
switch coordinates {
450450
case .original:
451451
break
452-
case .adjusted:
452+
case .natural:
453453
context.scaleBy(x: 1, y: -1)
454454
context.translateBy(x: 0.5, y: 0.5 - CGFloat(height))
455455
}
@@ -510,7 +510,7 @@ extension Image where Pixel == PremultipliedRGBA<UInt32> {
510510
)
511511
}
512512

513-
public mutating func withCGContext(coordinates: CGContextCoordinates = .adjusted, _ body: (CGContext) throws -> Void) rethrows {
513+
public mutating func withCGContext(coordinates: CGContextCoordinates = .natural, _ body: (CGContext) throws -> Void) rethrows {
514514
let width = self.width
515515
let height = self.height
516516

@@ -529,7 +529,7 @@ extension Image where Pixel == PremultipliedRGBA<UInt32> {
529529
switch coordinates {
530530
case .original:
531531
break
532-
case .adjusted:
532+
case .natural:
533533
context.scaleBy(x: 1, y: -1)
534534
context.translateBy(x: 0.5, y: 0.5 - CGFloat(height))
535535
}
@@ -666,7 +666,7 @@ extension Image where Pixel == UInt8 {
666666
)
667667
}
668668

669-
public mutating func withCGContext(coordinates: CGContextCoordinates = .adjusted, _ body: (CGContext) throws -> Void) rethrows {
669+
public mutating func withCGContext(coordinates: CGContextCoordinates = .natural, _ body: (CGContext) throws -> Void) rethrows {
670670
let width = self.width
671671
let height = self.height
672672

@@ -685,7 +685,7 @@ extension Image where Pixel == UInt8 {
685685
switch coordinates {
686686
case .original:
687687
break
688-
case .adjusted:
688+
case .natural:
689689
context.scaleBy(x: 1, y: -1)
690690
context.translateBy(x: 0.5, y: 0.5 - CGFloat(height))
691691
}
@@ -746,7 +746,7 @@ extension Image where Pixel == UInt16 {
746746
)
747747
}
748748

749-
public mutating func withCGContext(coordinates: CGContextCoordinates = .adjusted, _ body: (CGContext) throws -> Void) rethrows {
749+
public mutating func withCGContext(coordinates: CGContextCoordinates = .natural, _ body: (CGContext) throws -> Void) rethrows {
750750
let width = self.width
751751
let height = self.height
752752

@@ -765,7 +765,7 @@ extension Image where Pixel == UInt16 {
765765
switch coordinates {
766766
case .original:
767767
break
768-
case .adjusted:
768+
case .natural:
769769
context.scaleBy(x: 1, y: -1)
770770
context.translateBy(x: 0.5, y: 0.5 - CGFloat(height))
771771
}
@@ -826,7 +826,7 @@ extension Image where Pixel == UInt32 {
826826
)
827827
}
828828

829-
public mutating func withCGContext(coordinates: CGContextCoordinates = .adjusted, _ body: (CGContext) throws -> Void) rethrows {
829+
public mutating func withCGContext(coordinates: CGContextCoordinates = .natural, _ body: (CGContext) throws -> Void) rethrows {
830830
let width = self.width
831831
let height = self.height
832832

@@ -845,7 +845,7 @@ extension Image where Pixel == UInt32 {
845845
switch coordinates {
846846
case .original:
847847
break
848-
case .adjusted:
848+
case .natural:
849849
context.scaleBy(x: 1, y: -1)
850850
context.translateBy(x: 0.5, y: 0.5 - CGFloat(height))
851851
}

Sources/EasyImagy/ImageCoreGraphics.swift.gyb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Foundation
1212

1313
public enum CGContextCoordinates {
1414
case original
15-
case adjusted
15+
case natural
1616
}
1717
% for type in uint_types:
1818
% summable = type_to_summable[type]
@@ -216,7 +216,7 @@ extension Image where Pixel == PremultipliedRGBA<${type}> {
216216
)
217217
}
218218

219-
public mutating func withCGContext(coordinates: CGContextCoordinates = .adjusted, _ body: (CGContext) throws -> Void) rethrows {
219+
public mutating func withCGContext(coordinates: CGContextCoordinates = .natural, _ body: (CGContext) throws -> Void) rethrows {
220220
let width = self.width
221221
let height = self.height
222222

@@ -235,7 +235,7 @@ extension Image where Pixel == PremultipliedRGBA<${type}> {
235235
switch coordinates {
236236
case .original:
237237
break
238-
case .adjusted:
238+
case .natural:
239239
context.scaleBy(x: 1, y: -1)
240240
context.translateBy(x: 0.5, y: 0.5 - CGFloat(height))
241241
}
@@ -340,7 +340,7 @@ extension Image where Pixel == ${type} {
340340
)
341341
}
342342

343-
public mutating func withCGContext(coordinates: CGContextCoordinates = .adjusted, _ body: (CGContext) throws -> Void) rethrows {
343+
public mutating func withCGContext(coordinates: CGContextCoordinates = .natural, _ body: (CGContext) throws -> Void) rethrows {
344344
let width = self.width
345345
let height = self.height
346346

@@ -359,7 +359,7 @@ extension Image where Pixel == ${type} {
359359
switch coordinates {
360360
case .original:
361361
break
362-
case .adjusted:
362+
case .natural:
363363
context.scaleBy(x: 1, y: -1)
364364
context.translateBy(x: 0.5, y: 0.5 - CGFloat(height))
365365
}

Tests/EasyImagyTests/ImageCoreGraphicsTest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ import EasyImagy
248248

249249
do {
250250
var image = Image<PremultipliedRGBA<UInt8>>(width: 4, height: 4, pixel: PremultipliedRGBA<UInt8>(red: 0, green: 0, blue: 0, alpha: 255))
251-
image.withCGContext(coordinates: .adjusted) { context in
251+
image.withCGContext(coordinates: .natural) { context in
252252
context.setLineWidth(1)
253253
context.setStrokeColor(red)
254254
context.move(to: CGPoint(x: 1, y: -1))
@@ -281,7 +281,7 @@ import EasyImagy
281281

282282
do {
283283
var image = Image<UInt8>(width: 4, height: 4, pixel: 0)
284-
image.withCGContext(coordinates: .adjusted) { context in
284+
image.withCGContext(coordinates: .natural) { context in
285285
context.setLineWidth(1)
286286
context.setStrokeColor(white)
287287
context.move(to: CGPoint(x: 1, y: -1))

0 commit comments

Comments
 (0)