Bug? [B4X] [XUI] library Transparent color

klaus

Expert
Licensed User
Longtime User
In the Designer, the transparent color is #00FFFFFF.
In the XUI library, xui.Color_Transparent = 0
In the xChart CustumView Class I get the color with: Graph.ChartBackgroundColor = xui.PaintOrColorToColor(Props.Get("ChartBackgroundColor"))
It retuns : 16777215 (#00FFFFFF).
I would have expected getting 0, the xui.Color_Transparent value, with the xui.PaintOrColorToColor method.

Current workaround:
B4X:
Graph.ChartBackgroundColor = xui.PaintOrColorToColor(Props.Get("ChartBackgroundColor"))
If Graph.ChartBackgroundColor = 16777215 Then '#00FFFFFF
    Graph.ChartBackgroundColor = xui.Color_Transparent
End If
 

Cableguy

Expert
Licensed User
Longtime User
I may be out of line but, Transparent is NOT A COLOR, but rather a property of a color... All colors can be transparent.
 

klaus

Expert
Licensed User
Longtime User
For me, there is a difference, at least in B4A and B4i.
In B4A and B4i, when you draw with Colors.Transparent or xui.Color_Transparent the background pixels of the canvas parent view are set to transparent.
This is different than Colors.ARGB(0, x, x, x) with Alpha = 0
Drawing any color with Alpha = 0 does nothing.
Only Colors.ARGB(0, 0, 0, 0) or xui.Color_ARGB(0, 0, 0, 0) sets the background pixels to transparent, which is Colors.Transparent or xui.Color_Transparent!
This is not the case in B4J, where you need to use Canvas.ClearRect to set the background to transparent. Drawing with fx.Colors.Transparent or xui.Color_Transparent does nothing.
 

Cableguy

Expert
Licensed User
Longtime User
I never meant that you are wrong, as all that you point out is the difference of values for the same "color" between IDEs.

Maybe the different IDEs are "calculating" this value from different base colors with the transparency value set to 0

I just pointed that "Transparent" is not a color and should not be treated as such.
 

klaus

Expert
Licensed User
Longtime User
I just pointed that "Transparent" is not a color and should not be treated as such.
That's exactly where I don't agree.
What exactly does Colors.Transparent mean be to you ?
Any 00XXXXXX, which does nothing ?
Or 00000000 which sets the background pixels to transparent (in B4A and B4i).
My origin concern was, and still is, that in the Designer Transparent color is 00FFFFFF.
But, when you look in the code at Log(Colors.Transparent) it returns 00000000, which is not the same as in the Designer!
When you set in the Designer the Color to Transparent as a property, and you get the color back in DesignerCreateView you get 00FFFFFF which in the code is NOT the same as Colors.Transparent nor xui.Color_Transparent !?

Attached a small test program showing what I mean.
 

Attachments

  • TestTransparentColor.zip
    8.8 KB · Views: 192
Last edited:

Cableguy

Expert
Licensed User
Longtime User
Klaus, I'm not going to start an argument with you. I understood your point in the first post.
And you are very close to make me regret I ever gave my two cents in this thread...
 

Star-Dust

Expert
Licensed User
I may be out of line but, Transparent is NOT A COLOR, but rather a property of a color... All colors can be transparent.
I agree, transparent is a property of color. However @klaus also says well, it is not true that it should have no effect.

All this depends on whether the transparent color is superimposed (PUT) to the underlying color or Mixed (XOR).

With XOR no effect, but with PUT it should replace it (with the effect of canceling the underlying color)
 
Top