Tightened the source code and README documentations in the library.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// Mirroring applied when drawing a bitmap.
|
||||
/// Mirroring applied when drawing a bitmap. Wraps `LCDBitmapFlip`.
|
||||
public enum BitmapFlip: UInt32, Sendable {
|
||||
case unflipped = 0
|
||||
case flippedX = 1
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// A drawing color: solid or an 8×8 pattern.
|
||||
/// Wraps `LCDColor`: a solid color or an 8×8 pattern.
|
||||
public enum Color: Sendable {
|
||||
/// Solid black.
|
||||
case black
|
||||
/// Solid white.
|
||||
case white
|
||||
/// Transparent; leaves the destination unchanged.
|
||||
/// Leaves the destination unchanged.
|
||||
case clear
|
||||
/// Inverts the destination pixels.
|
||||
/// Inverts the destination.
|
||||
case xor
|
||||
/// An 8×8 two-color pattern.
|
||||
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.
|
||||
/// For `.pattern`, the `LCDColor` points to a copy valid only during `body`.
|
||||
func withLCDColor<Result>(_ body: (LCDColor) -> Result) -> Result {
|
||||
switch self {
|
||||
case .black: return body(LCDColor(kColorBlack.rawValue))
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// How source pixels combine with the destination when drawing.
|
||||
/// Wraps `LCDBitmapDrawMode`: how bitmap and text pixels combine with the destination.
|
||||
public enum DrawMode: UInt32, Sendable {
|
||||
/// Source pixels replace the destination.
|
||||
case copy = 0
|
||||
/// White source pixels are treated as transparent.
|
||||
/// White source pixels are transparent.
|
||||
case whiteTransparent = 1
|
||||
/// Black source pixels are treated as transparent.
|
||||
/// Black source pixels are transparent.
|
||||
case blackTransparent = 2
|
||||
/// Opaque source pixels draw white.
|
||||
case fillWhite = 3
|
||||
/// Opaque source pixels draw black.
|
||||
case fillBlack = 4
|
||||
/// Source pixels are XORed with the destination.
|
||||
case xor = 5
|
||||
/// The inverse of `xor`.
|
||||
case nxor = 6
|
||||
/// Source pixels draw inverted.
|
||||
case inverted = 7
|
||||
|
||||
init(_ mode: LCDBitmapDrawMode) { self = DrawMode(rawValue: UInt32(mode.rawValue)) ?? .copy }
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// The end cap style used when drawing lines.
|
||||
/// Line end caps. Wraps `LCDLineCapStyle`.
|
||||
public enum LineCapStyle: UInt32, Sendable {
|
||||
/// Flat, ending at the endpoint.
|
||||
case butt = 0
|
||||
/// Square, extending past the endpoint.
|
||||
case square = 1
|
||||
case round = 2
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// The winding rule used by `fillPolygon`.
|
||||
/// Winding rule for `fillPolygon(points:color:fillRule:)`. Wraps `LCDPolygonFillRule`.
|
||||
public enum PolygonFillRule: UInt32, Sendable {
|
||||
/// Fills points with a nonzero winding number.
|
||||
case nonZero = 0
|
||||
/// Fills points crossed by an odd number of edges.
|
||||
case evenOdd = 1
|
||||
|
||||
var cValue: LCDPolygonFillRule { LCDPolygonFillRule(LCDPolygonFillRule.RawValue(rawValue)) }
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// A solid color, for APIs that cannot take a pattern.
|
||||
/// A color for APIs that cannot take a pattern. Wraps `LCDSolidColor`.
|
||||
public enum SolidColor: UInt32, Sendable {
|
||||
case black = 0
|
||||
case white = 1
|
||||
/// Transparent.
|
||||
case clear = 2
|
||||
/// Inverts the destination.
|
||||
case xor = 3
|
||||
|
||||
init(_ color: LCDSolidColor) { self = SolidColor(rawValue: UInt32(color.rawValue)) ?? .clear }
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// The encoding of text passed to the text functions.
|
||||
/// Text encoding for the C text functions. Wraps `PDStringEncoding`.
|
||||
/// The Swift text wrappers always pass UTF-8.
|
||||
public enum StringEncoding: UInt32, Sendable {
|
||||
case ascii = 0
|
||||
case utf8 = 1
|
||||
/// UTF-16, little-endian.
|
||||
case utf16LittleEndian = 2
|
||||
|
||||
var cValue: PDStringEncoding { PDStringEncoding(PDStringEncoding.RawValue(rawValue)) }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// Horizontal alignment for `drawText(in:)`.
|
||||
/// Alignment for the rect-bounded `drawText` overloads. Wraps `PDTextAlignment`.
|
||||
public enum TextAlignment: UInt32, Sendable {
|
||||
case left = 0
|
||||
case center = 1
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Graphics {
|
||||
/// How text wraps in `drawText(in:)`.
|
||||
/// Wrapping for the rect-bounded `drawText` overloads and `Font.textHeight`.
|
||||
/// Wraps `PDTextWrappingMode`.
|
||||
public enum TextWrappingMode: UInt32, Sendable {
|
||||
/// No wrapping; text past the edge is clipped.
|
||||
case clip = 0
|
||||
case character = 1
|
||||
case word = 2
|
||||
|
||||
Reference in New Issue
Block a user