rotating flip flags

This commit is contained in:
2024-09-21 10:21:26 +10:00
parent 1f5c59fe77
commit 9640a4042f
4 changed files with 216 additions and 36 deletions

View File

@ -6,8 +6,8 @@ public struct Sprite {
}
public static let none: Self = Self(rawValue: 0)
public static let x: Self = Self(rawValue: 1 << 0)
public static let y: Self = Self(rawValue: 1 << 1)
public static let horz: Self = Self(rawValue: 1 << 0)
public static let vert: Self = Self(rawValue: 1 << 1)
public static let diag: Self = Self(rawValue: 1 << 2)
}
@ -21,3 +21,15 @@ public struct Sprite {
var flip: Flip
var color: Color<Float>
}
public extension Sprite.Flip {
var clockwise: Self {
[Self](arrayLiteral: [ .vert, .diag ], [ .horz, .vert, .diag ], .diag,
[ .horz, .diag ], .horz, .none, [ .horz, .vert ], .vert)[Int(self.rawValue)]
}
var counterClockwise: Self {
[Self](arrayLiteral: [ .horz, .diag ], .diag, [ .horz, .vert, .diag ],
[ .vert, .diag ], .vert, [ .horz, .vert ], .none, .horz)[Int(self.rawValue)]
}
}