Created
February 9, 2021 10:50
-
-
Save BanditTech/1e38fd26ba7d85ea8d3a8f94a6c28038 to your computer and use it in GitHub Desktop.
Color class for ARGB
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
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