sibutr Member Licensed User Longtime User Nov 23, 2015 #1 I need to mix 2 or 3 RGB colors in B4A ? Red + Green = ? ( Yellow ) button1.color and button2.color makes button3.color Last edited: Nov 23, 2015
I need to mix 2 or 3 RGB colors in B4A ? Red + Green = ? ( Yellow ) button1.color and button2.color makes button3.color
LucaMs Expert Licensed User Longtime User Nov 23, 2015 #2 Colors.ARGB. Button.Color is write only. Upvote 0
eurojam Well-Known Member Licensed User Longtime User Nov 23, 2015 #3 you can mixing the colors like this B4X: Sub mixColors(col1 As Int, col2 As Int) As Int Dim r1, g1, b1, r2, g2, b2, r3 ,g3, b3 As Int r1 = Bit.UnsignedShiftRight(Bit.And(col1, 0xff0000), 16) g1 = Bit.UnsignedShiftRight(Bit.And(col1, 0xff00), 8) b1 = Bit.And(col1, 0xff) r2 = Bit.UnsignedShiftRight(Bit.And(col2, 0xff0000), 16) g2 = Bit.UnsignedShiftRight(Bit.And(col2, 0xff00), 8) b2 = Bit.And(col2, 0xff) r3 = (r1 + r2)/2 g3 = (g1 + g2)/2 b3 = (b1 + b2)/2 Return Colors.RGB(r3, g3, b3) End Sub Last edited: Nov 23, 2015 Upvote 0
you can mixing the colors like this B4X: Sub mixColors(col1 As Int, col2 As Int) As Int Dim r1, g1, b1, r2, g2, b2, r3 ,g3, b3 As Int r1 = Bit.UnsignedShiftRight(Bit.And(col1, 0xff0000), 16) g1 = Bit.UnsignedShiftRight(Bit.And(col1, 0xff00), 8) b1 = Bit.And(col1, 0xff) r2 = Bit.UnsignedShiftRight(Bit.And(col2, 0xff0000), 16) g2 = Bit.UnsignedShiftRight(Bit.And(col2, 0xff00), 8) b2 = Bit.And(col2, 0xff) r3 = (r1 + r2)/2 g3 = (g1 + g2)/2 b3 = (b1 + b2)/2 Return Colors.RGB(r3, g3, b3) End Sub