Skip to content

Instantly share code, notes, and snippets.

@BanditTech
Created February 9, 2021 10:50
Show Gist options
  • Save BanditTech/1e38fd26ba7d85ea8d3a8f94a6c28038 to your computer and use it in GitHub Desktop.
Save BanditTech/1e38fd26ba7d85ea8d3a8f94a6c28038 to your computer and use it in GitHub Desktop.
Color class for ARGB
Class ARGB {
__New(ARGB){
This.ARGB :=Format("0x{1:08x}", ARGB)
This.A := (This.ARGB >> 24) & 0xFF
This.R := (This.ARGB >> 16) & 0xFF
This.G := (This.ARGB >> 8) & 0xFF
This.B := (This.ARGB >> 0) & 0xFF
This.RGB := Format("0x{1:02x}{2:02x}{3:02x}", This.R, This.G, This.B)
Return This
}
NoPrefix(key){
If This.HasKey(Key) {
Return Format("{1:" (key="ARGB"?"08":key="RGB"?"06":"02") "x}",This[key])
}
}
Set(key,value){
Static keys := {A:"",R:"",G:"",B:""}
If keys.HasKey(Key) {
This[key] := Format("0x{1:02x}", value)
This.RGB := Format("0x{1:02x}{2:02x}{3:02x}", This.R, This.G, This.B)
This.ARGB := Format("0x{1:02x}{2:02x}{3:02x}{4:02x}", This.A, This.R, This.G, This.B)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment