Skip to content

Instantly share code, notes, and snippets.

@atebit
Created April 24, 2024 13:57
Show Gist options
  • Select an option

  • Save atebit/0f9fc1418fc97cc7c8f27e6f17a186f9 to your computer and use it in GitHub Desktop.

Select an option

Save atebit/0f9fc1418fc97cc7c8f27e6f17a186f9 to your computer and use it in GitHub Desktop.
Swift Color Contrast Algo
func exportColor(flags: Int) {
if !(flags & leaveValue != 0) && valueElement != nil {
// Implement your logic for handling valueElement
}
var value = toString()
if caps {
value = value.uppercased()
}
if hash {
value = "#" + value
}
valueElement?.value = value
if !(flags & leaveStyle != 0) && styleElement != nil {
styleElement?.style.backgroundImage = "none"
styleElement?.style.backgroundColor = "#" + toString()
let color = (0.213
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment