Download

Problem with FLinearColor

I need some specific colors for my text blocks in a widget.
I am using FLinearColor to set the value in the


ColorAndOpacity

property of the text block.

I am using the constructor that takes in RGBA values, however they do not work as expected.

For example this should be a green but it shows as white in - game:


FLinearColor(54.f, 204.f, 54.f);

Same for these reds that have no difference in - game although they are a different shade:


FLinearColor(255.f, 0.f, 0.f);
FLinearColor(153.f, 0.f, 0.f);

Anyone knows what’s wrong?

You have a wrong interpretation of constructor function.
If were it asking for RGBA value it would ask for uint8 integers, not floats…

Constructor asking for a float means function expect you input in range 0.0f ~ 1.0f value.
0.5f = 127 rgba.

A simple way to remember, while using float type between 0.f ~ 1.f you already have more than enough possibilities because float are using 32bits - 2^32-1 maximum variations.

If your value is capped at 255 it means you most likely work with 8bits because of 2^8-1=255 .

I used floats from 0.0f - 1.0f and it worked like it should!

Thank you both for your help.