@@ -45,33 +45,26 @@ const sfColor sfTransparent = sfColor_fromRGBA(0, 0, 0, 0);
45
45
// //////////////////////////////////////////////////////////
46
46
sfColor sfColor_fromRGB (uint8_t red, uint8_t green, uint8_t blue)
47
47
{
48
- return sfColor_fromRGBA ( red, green, blue, 255 ) ;
48
+ return { red, green, blue, 255 } ;
49
49
}
50
50
51
51
52
52
// //////////////////////////////////////////////////////////
53
53
sfColor sfColor_fromRGBA (uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
54
54
{
55
- sfColor color;
56
-
57
- color.r = red;
58
- color.g = green;
59
- color.b = blue;
60
- color.a = alpha;
61
-
62
- return color;
55
+ return {red, green, blue, alpha};
63
56
}
64
57
65
58
66
59
// //////////////////////////////////////////////////////////
67
60
sfColor sfColor_fromInteger (uint32_t color)
68
61
{
69
- auto red = static_cast < uint8_t >((color & 0xff000000 ) >> 24 );
70
- auto green = static_cast <uint8_t >((color & 0x00ff0000 ) >> 16 );
71
- auto blue = static_cast <uint8_t >((color & 0x0000ff00 ) >> 8 );
72
- auto alpha = static_cast <uint8_t >((color & 0x000000ff ) >> 0 );
73
-
74
- return sfColor_fromRGBA (red, green, blue, alpha) ;
62
+ return {
63
+ static_cast <uint8_t >((color & 0xff000000 ) >> 24 ),
64
+ static_cast <uint8_t >((color & 0x00ff0000 ) >> 16 ),
65
+ static_cast <uint8_t >((color & 0x0000ff00 ) >> 8 ),
66
+ static_cast < uint8_t >((color & 0x000000ff ) >> 0 ),
67
+ } ;
75
68
}
76
69
77
70
@@ -85,43 +78,34 @@ uint32_t sfColor_toInteger(sfColor color)
85
78
// //////////////////////////////////////////////////////////
86
79
sfColor sfColor_add (sfColor color1, sfColor color2)
87
80
{
88
- int red = std::min (color1.r + color2.r , 255 );
89
- int green = std::min (color1.g + color2.g , 255 );
90
- int blue = std::min (color1.b + color2.b , 255 );
91
- int alpha = std::min (color1.a + color2.a , 255 );
92
-
93
- return sfColor_fromRGBA (static_cast <uint8_t >(red),
94
- static_cast <uint8_t >(green),
95
- static_cast <uint8_t >(blue),
96
- static_cast <uint8_t >(alpha));
81
+ return {
82
+ static_cast <uint8_t >(std::min (color1.r + color2.r , 255 )),
83
+ static_cast <uint8_t >(std::min (color1.g + color2.g , 255 )),
84
+ static_cast <uint8_t >(std::min (color1.b + color2.b , 255 )),
85
+ static_cast <uint8_t >(std::min (color1.a + color2.a , 255 )),
86
+ };
97
87
}
98
88
99
89
100
90
// //////////////////////////////////////////////////////////
101
91
sfColor sfColor_subtract (sfColor color1, sfColor color2)
102
92
{
103
- int red = std::max (color1.r - color2.r , 0 );
104
- int green = std::max (color1.g - color2.g , 0 );
105
- int blue = std::max (color1.b - color2.b , 0 );
106
- int alpha = std::max (color1.a - color2.a , 0 );
107
-
108
- return sfColor_fromRGBA (static_cast <uint8_t >(red),
109
- static_cast <uint8_t >(green),
110
- static_cast <uint8_t >(blue),
111
- static_cast <uint8_t >(alpha));
93
+ return {
94
+ static_cast <uint8_t >(std::max (color1.r - color2.r , 0 )),
95
+ static_cast <uint8_t >(std::max (color1.g - color2.g , 0 )),
96
+ static_cast <uint8_t >(std::max (color1.b - color2.b , 0 )),
97
+ static_cast <uint8_t >(std::max (color1.a - color2.a , 0 )),
98
+ };
112
99
}
113
100
114
101
115
102
// //////////////////////////////////////////////////////////
116
103
sfColor sfColor_modulate (sfColor color1, sfColor color2)
117
104
{
118
- int red = color1.r * color2.r / 255 ;
119
- int green = color1.g * color2.g / 255 ;
120
- int blue = color1.b * color2.b / 255 ;
121
- int alpha = color1.a * color2.a / 255 ;
122
-
123
- return sfColor_fromRGBA (static_cast <uint8_t >(red),
124
- static_cast <uint8_t >(green),
125
- static_cast <uint8_t >(blue),
126
- static_cast <uint8_t >(alpha));
105
+ return {
106
+ static_cast <uint8_t >(color1.r * color2.r / 255 ),
107
+ static_cast <uint8_t >(color1.g * color2.g / 255 ),
108
+ static_cast <uint8_t >(color1.b * color2.b / 255 ),
109
+ static_cast <uint8_t >(color1.a * color2.a / 255 ),
110
+ };
127
111
}
0 commit comments