Support giving color values as percentage
This commit is contained in:
parent
911db304ae
commit
e65f684654
2 changed files with 42 additions and 1 deletions
|
@ -119,13 +119,25 @@ extension Scanner {
|
|||
func commaSeparated() -> [UInt8]? {
|
||||
var result: [UInt8] = []
|
||||
repeat {
|
||||
guard let int = scanInt(), let component = UInt8(exactly: int) else {
|
||||
guard let component = self.component() else {
|
||||
return nil
|
||||
}
|
||||
result.append(component)
|
||||
} while string(",")
|
||||
return result
|
||||
}
|
||||
|
||||
func component() -> UInt8? {
|
||||
guard var int = scanInt() else {
|
||||
return nil
|
||||
}
|
||||
|
||||
if string("%") {
|
||||
int = int * 0xFF / 100
|
||||
}
|
||||
|
||||
return UInt8(exactly: int)
|
||||
}
|
||||
}
|
||||
|
||||
private extension Scanner {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue