Restructured the source code in the Playdate bindings target.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// Mirroring applied when drawing a bitmap.
|
||||
public enum BitmapFlip: UInt32, Sendable {
|
||||
case unflipped = 0
|
||||
case flippedX = 1
|
||||
case flippedY = 2
|
||||
case flippedXY = 3
|
||||
|
||||
init(_ flip: LCDBitmapFlip) { self = BitmapFlip(rawValue: UInt32(flip.rawValue)) ?? .unflipped }
|
||||
var cValue: LCDBitmapFlip { LCDBitmapFlip(LCDBitmapFlip.RawValue(rawValue)) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// A drawing color: solid or an 8×8 pattern.
|
||||
public enum Color: Sendable {
|
||||
case black
|
||||
case white
|
||||
case clear
|
||||
case xor
|
||||
case pattern(Pattern)
|
||||
|
||||
/// Materializes the `LCDColor` for the duration of `body`. Pattern
|
||||
/// colors pass a pointer to a temporary, so the value must not be
|
||||
/// stored beyond the call.
|
||||
func withLCDColor<Result>(_ body: (LCDColor) -> Result) -> Result {
|
||||
switch self {
|
||||
case .black: return body(LCDColor(kColorBlack.rawValue))
|
||||
case .white: return body(LCDColor(kColorWhite.rawValue))
|
||||
case .clear: return body(LCDColor(kColorClear.rawValue))
|
||||
case .xor: return body(LCDColor(kColorXOR.rawValue))
|
||||
case .pattern(let pattern):
|
||||
return withUnsafeBytes(of: pattern.bytes) { buffer in
|
||||
body(LCDColor(UInt(bitPattern: buffer.baseAddress)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// How source pixels combine with the destination when drawing.
|
||||
public enum DrawMode: UInt32, Sendable {
|
||||
case copy = 0
|
||||
case whiteTransparent = 1
|
||||
case blackTransparent = 2
|
||||
case fillWhite = 3
|
||||
case fillBlack = 4
|
||||
case xor = 5
|
||||
case nxor = 6
|
||||
case inverted = 7
|
||||
|
||||
init(_ mode: LCDBitmapDrawMode) { self = DrawMode(rawValue: UInt32(mode.rawValue)) ?? .copy }
|
||||
var cValue: LCDBitmapDrawMode { LCDBitmapDrawMode(LCDBitmapDrawMode.RawValue(rawValue)) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// The end cap style used when drawing lines.
|
||||
public enum LineCapStyle: UInt32, Sendable {
|
||||
case butt = 0
|
||||
case square = 1
|
||||
case round = 2
|
||||
|
||||
var cValue: LCDLineCapStyle { LCDLineCapStyle(LCDLineCapStyle.RawValue(rawValue)) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// The winding rule used by `fillPolygon`.
|
||||
public enum PolygonFillRule: UInt32, Sendable {
|
||||
case nonZero = 0
|
||||
case evenOdd = 1
|
||||
|
||||
var cValue: LCDPolygonFillRule { LCDPolygonFillRule(LCDPolygonFillRule.RawValue(rawValue)) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// A solid color, for APIs that cannot take a pattern.
|
||||
public enum SolidColor: UInt32, Sendable {
|
||||
case black = 0
|
||||
case white = 1
|
||||
case clear = 2
|
||||
case xor = 3
|
||||
|
||||
init(_ color: LCDSolidColor) { self = SolidColor(rawValue: UInt32(color.rawValue)) ?? .clear }
|
||||
var cValue: LCDSolidColor { LCDSolidColor(LCDSolidColor.RawValue(rawValue)) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// The encoding of text passed to the text functions.
|
||||
public enum StringEncoding: UInt32, Sendable {
|
||||
case ascii = 0
|
||||
case utf8 = 1
|
||||
case utf16LittleEndian = 2
|
||||
|
||||
var cValue: PDStringEncoding { PDStringEncoding(PDStringEncoding.RawValue(rawValue)) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// Horizontal alignment for `drawText(in:)`.
|
||||
public enum TextAlignment: UInt32, Sendable {
|
||||
case left = 0
|
||||
case center = 1
|
||||
case right = 2
|
||||
|
||||
var cValue: PDTextAlignment { PDTextAlignment(PDTextAlignment.RawValue(rawValue)) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// How text wraps in `drawText(in:)`.
|
||||
public enum TextWrappingMode: UInt32, Sendable {
|
||||
case clip = 0
|
||||
case character = 1
|
||||
case word = 2
|
||||
|
||||
var cValue: PDTextWrappingMode { PDTextWrappingMode(PDTextWrappingMode.RawValue(rawValue)) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user