Last active
March 30, 2019 23:14
-
-
Save mxcl/8912454832d426b23025f9223f85127d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/swift sh | |
import Foundation | |
import Chalk // @mxcl == 0.3 | |
extension Int { | |
var fg: UInt8 { | |
if !(16..<250 ~= self) || 24...36 ~= (self - 16) % 36 { | |
return 16 | |
} else { | |
return 255 | |
} | |
} | |
var bg: UInt8 { | |
return UInt8(self) | |
} | |
var paddedString: String { | |
return " \(self)".padding(toLength: 5, withPad: " ", startingAt: 0) | |
} | |
var terminator: String { | |
return (self + 3).isMultiple(of: 6) ? "\n" : "" | |
} | |
} | |
for x in 0...255 { | |
print("\(x.paddedString, color: x.fg, background: x.bg)", terminator: x.terminator) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment