Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Should RGBA have got 4 arguments constructor?
Re: Should RGBA have got 4 arguments constructor? [message #43178 is a reply to message #43080] |
Thu, 29 May 2014 11:18   |
 |
mirek
Messages: 14257 Registered: November 2005
|
Ultimate Member |
|
|
According to C++03 rules, adding constructor would make RGBA non-POD, which has implications on what operations are legal with it.
Furthermore, the issue is tricky, because the standard format is premultiplied, so e.g.
RGBA(0, 255, 0, 128)
would be wrong if constructor would just assign numbers to respective fields.
RGBA rgba = Color(255, 0, 0);
rgba.a = 255;
No need to set .a here, it is automatically set to 255.
Note that there is also operator* to add alpha to Color:
RGBA x = 128 * Red(); // Sets Red with alpha = 128
[Updated on: Thu, 29 May 2014 11:18] Report message to a moderator
|
|
|
 |
 |
Should RGBA have got 4 arguments constructor?
By: Klugier on Sat, 03 May 2014 20:59
|
 |
|
Re: Should RGBA have got 4 arguments constructor?
By: unodgs on Sat, 03 May 2014 21:44
|
 |
|
Re: Should RGBA have got 4 arguments constructor?
By: mirek on Thu, 29 May 2014 11:18
|
 |
|
Re: Should RGBA have got 4 arguments constructor?
By: mirek on Thu, 29 May 2014 11:32
|
 |
|
Re: Should RGBA have got 4 arguments constructor?
By: Klugier on Thu, 24 July 2014 22:32
|
 |
|
Re: Should RGBA have got 4 arguments constructor?
By: mirek on Fri, 25 July 2014 07:46
|
 |
|
Re: Should RGBA have got 4 arguments constructor?
By: Klugier on Fri, 25 July 2014 20:26
|
 |
|
Re: Should RGBA have got 4 arguments constructor?
By: mirek on Mon, 04 August 2014 14:21
|
 |
|
Re: Should RGBA have got 4 arguments constructor?
By: Klugier on Tue, 05 August 2014 21:25
|
 |
|
Re: Should RGBA have got 4 arguments constructor?
By: mirek on Wed, 06 August 2014 17:56
|
 |
|
Re: Should RGBA have got 4 arguments constructor?
By: Klugier on Sat, 09 August 2014 19:35
|
Goto Forum:
Current Time: Tue May 13 01:38:59 CEST 2025
Total time taken to generate the page: 0.03684 seconds
|