This is a supporting class for my upcoming SmartHost class but may be useful on a standalone basis for other projects.
Put simply this library provides easy access to 255 named colors broken into color groups for easier navigation.
In addition it contain 4 functions as follows:
1) SetAlpha(MyColor as Int, Alpha as Int) as Int
2) RandomColorSolid() as Int
3) RandomColorTransparent(MinimumTransparency As Int, MaximumTransparency As Int) As Int
4) GetARGB(MyColor As Int) As Int()
You may be wondering why I used the name Colours as in MyColors.Colours. etc. Well if I use the word Colors inside the class is causes a conflict with the Colors function. Being British I went with the UK spelling.
If you experience a crash from this class then you probably did this.
btnTest.Color = MyColors.Colours.Blues when you should have done this
btnTest.Color = MyColors.Colours.Blues.corn_flower_blue
Put simply this library provides easy access to 255 named colors broken into color groups for easier navigation.
In addition it contain 4 functions as follows:
1) SetAlpha(MyColor as Int, Alpha as Int) as Int
2) RandomColorSolid() as Int
3) RandomColorTransparent(MinimumTransparency As Int, MaximumTransparency As Int) As Int
4) GetARGB(MyColor As Int) As Int()
B4X:
Dim MyColors As Colors_
'Use a named color from the list.
btnTest.Color = MyColors.Colours.Blues.corn_flower_blue
btnTest.Color = MyColors.Colours.Browns.chocolate
'Use a named color and make it partially transparent.
btnTest.Color = MyColors.setAlpha(Colors.Blue, 128)
btnTest.Color = MyColors.SetAlpha(MyColors.Colours.OrangeYellows.orange, 192)
'Use a randomly generated opaque color
btnTest.Color = MyColors.RandomColorSolid
'Use a randomly generated transparent color with transparency in the range of 192 and 255.
MyColors.Random_Color_Transparent(192, 255)
'Splits a Color into its ARGB values
Dim argb()As Int
argb = MyColors.GetARGB(MyColor)
'Split the colors
Dim Alpha as Int = argb(0)
Dim Red As Int = argb(1)
Dim Green As Int = argb(2)
Dim Blue As Int = argb(3)
You may be wondering why I used the name Colours as in MyColors.Colours. etc. Well if I use the word Colors inside the class is causes a conflict with the Colors function. Being British I went with the UK spelling.
If you experience a crash from this class then you probably did this.
btnTest.Color = MyColors.Colours.Blues when you should have done this
btnTest.Color = MyColors.Colours.Blues.corn_flower_blue