3

Using QGIS 3.16, I am trying to set color through expression builder, using #RRGGBBAA format.

The problem, I was using the same color, let's say '#94AFDCff', it should return the same color as '#94AFDC' in #RRGGBB format, yet the color that is rendered is fully different. I cannot seem to find out why. Could anyone help?

The code is simple, it is used in symbol, as a condition of fill colors of circles.

CASE
    WHEN   "Cat_Num" = 1 THEN '#94AFDC66'
    WHEN  "Cat_Num"  = 2 THEN '#FFFF0066'
    WHEN  "Cat_Num"  =  3 THEN '#ffc40366'
    WHEN  "Cat_Num"  =  4 THEN '#54823566'
    WHEN  "Cat_Num"  =  5 THEN '#7030a066'
    WHEN  "Cat_Num"  =  6 THEN '#843c0c66'
    WHEN  "Cat_Num"  =  7 THEN '#38c0f666'
    WHEN  "Cat_Num"  =  8 THEN '#CCCC0066'
    WHEN  "Cat_Num"  =  9 THEN '#C55A1166'
    WHEN  "Cat_Num"  =  10 THEN '#8d5a9966'
    ELSE 'pink'
END

but this code resulted in (notice that the 2 circles are "Cat_Num" = 8 THEN '#CCCC0066' and "Cat_Num" = 10 THEN '#8d5a9966')

result picture

In the end, I did change the code to rgba format, so that "Cat_Num" = 8 THEN '204, 204, 0, 90' and "Cat_Num" = 10 THEN '141, 90, 153, 90' with this result:

result

How are these 2 so different?? The hex color returns pink result for "Cat_Num" = 8 THEN '#CCCC0066' (the bigger circle). The smaller circle, which should return purplish, became greenish... Did I make a mistake?

As a reference, in QGIS' own color picker, inputting '#CCCC0066' will have the same color as '141, 90, 153, 90', only different transparency value (90 is about 0.65% for RRGGBBAA and 66 in hex is 40% )

Color Picker

4
  • 1
    Please provide both your expression, as well as a screenshot. Thanks.
    – Erik
    Dec 10, 2020 at 8:11
  • Already did, thanks.
    – necrohiero
    Dec 11, 2020 at 11:06
  • I had a somewhat similar color issue : gis.stackexchange.com/questions/320696/… , maybe just double check that all your expression are exactly right...
    – J.R
    Dec 11, 2020 at 13:35
  • I tried, but no difference. I mean, #RRGGBBAA format shouldn't have space in between. And #RRGGBB format returns the right colour. So the problem is the AA behind.. but it should be a hex number, as both format are hex codes anyways. ff should be 255 (which means 100%/opaque) and 00 should be fully transparent, hence the 66 should return 102, which is 0.4 of 255. But, this changes the colour. In my case '#CCCC0066' returns a completely different colour than '#CCCC00'
    – necrohiero
    Dec 11, 2020 at 15:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.