Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 1 | #Topic Color4f |
Cary Clark | 137b874 | 2018-05-30 09:21:49 -0400 | [diff] [blame] | 2 | #Alias Color4f_Reference ## |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 3 | #Substitute SkColor4f |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 4 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 5 | #Struct SkPM4f |
| 6 | ## |
| 7 | |
| 8 | #Struct SkRGBA4f |
| 9 | |
| 10 | #Code |
| 11 | #Populate |
| 12 | ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 13 | |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 14 | Each component is stored as a 32-bit single precision floating point float value. |
| 15 | All values are allowed, but only the range from zero to one is meaningful. |
| 16 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 17 | Components are independent of the others if defined with kUnpremul_SkAlphaType; |
| 18 | fA Alpha is may be greater or smaller than fG green, fB blue, or fR red. |
| 19 | SkColor4f is shorthand for Unpremultiplied SkRGBA4f. |
| 20 | |
| 21 | Components are connnected if defined with kPremul_SkAlphaType; |
| 22 | fA Alpha is equal to or larger than fG green, fB blue, and fR red. The values |
| 23 | stored in fG, fB, and fR combine the color component with the Alpha component. |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 24 | |
| 25 | Values smaller than zero or larger than one are allowed. Values out of range |
| 26 | may be used with Blend_Mode so that the final component is in range. |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 27 | |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 28 | #Member float fR |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 29 | #Line # red component ## |
| 30 | Single precision float for red ranges from no red (0.0) to full red (1.0). |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 31 | ## |
| 32 | |
| 33 | #Member float fG |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 34 | #Line # green component ## |
| 35 | Single precision float for green ranges from no green (0.0) to full green (1.0). |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 36 | ## |
| 37 | |
| 38 | #Member float fB |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 39 | #Line # blue component ## |
| 40 | Single precision float for blue ranges from no blue (0.0) to full blue (1.0). |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 41 | ## |
| 42 | |
| 43 | #Member float fA |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 44 | #Line # alpha component ## |
| 45 | Single precision float for Alpha ranges from no Alpha (0.0) to full Alpha (1.0). |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 46 | ## |
| 47 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 48 | |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 49 | # ------------------------------------------------------------------------------ |
| 50 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 51 | #Method bool operator==(const SkRGBA4f& other)_const |
| 52 | #Line # compares SkRGBA4f for equality ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 53 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 54 | Compares SkRGBA4f with other, and returns true if all components are equivalent. |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 55 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 56 | #Param other SkRGBA4f to compare ## |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 57 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 58 | #Return true if SkRGBA4f equals other ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 59 | |
| 60 | #Example |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 61 | SkColor4f colorRed = { 1, 0, 0, 1 };
|
| 62 | SkColor4f colorNamedRed = SkColor4f::FromColor(SK_ColorRED);
|
| 63 | SkDebugf("colorRed %c= colorNamedRed", colorRed == colorNamedRed ? '=' : '!');
|
| 64 | #StdOut |
| 65 | colorRed == colorNamedRed |
| 66 | ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 67 | ## |
| 68 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 69 | #SeeAlso operator!=(const SkRGBA4f& other)_const |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 70 | |
| 71 | #Method ## |
| 72 | |
| 73 | # ------------------------------------------------------------------------------ |
| 74 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 75 | #Method bool operator!=(const SkRGBA4f& other)_const |
| 76 | #Line # compares SkRGBA4f for inequality ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 77 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 78 | Compares SkRGBA4f with other, and returns true if all components are not |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 79 | equivalent. |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 80 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 81 | #Param other SkRGBA4f to compare ## |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 82 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 83 | #Return true if SkRGBA4f is not equal to other ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 84 | |
| 85 | #Example |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 86 | SkColor4f colorGray = { .5, .5, .5, 1 };
|
| 87 | SkColor4f colorNamedGray = SkColor4f::FromColor(SK_ColorGRAY);
|
| 88 | SkDebugf("colorGray %c= colorNamedGray ", colorGray != colorNamedGray ? '!' : '=');
|
| 89 | #StdOut |
| 90 | colorGray != colorNamedGray |
| 91 | ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 92 | ## |
| 93 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 94 | #SeeAlso operator==(const SkRGBA4f& other)_const |
| 95 | |
| 96 | #Method ## |
| 97 | |
| 98 | #Method SkRGBA4f operator*(float scale)_const |
| 99 | #Line # multiplies components by scale ## |
| 100 | |
| 101 | Multiplies each component by scale. Does not pin the result. |
| 102 | |
| 103 | #Param scale component multiplier ## |
| 104 | |
| 105 | #Return scaled color ## |
| 106 | |
| 107 | #NoExample |
| 108 | ## |
| 109 | |
| 110 | #SeeAlso SkBlendMode::kMultiply |
| 111 | |
| 112 | #Method ## |
| 113 | |
| 114 | #Method SkRGBA4f operator*(const SkRGBA4f& scale)_const |
| 115 | |
| 116 | Multiplies each component by scale component. Does not pin the result. |
| 117 | |
| 118 | #Param scale SkRGBA4f component multipliers ## |
| 119 | |
| 120 | #Return scaled color ## |
| 121 | |
| 122 | #NoExample |
| 123 | ## |
| 124 | |
| 125 | #SeeAlso SkBlendMode::kMultiply |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 126 | |
| 127 | #Method ## |
| 128 | |
| 129 | # ------------------------------------------------------------------------------ |
| 130 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 131 | #Subtopic Property_Functions |
| 132 | #Line # member values ## |
| 133 | #Subtopic Property_Functions ## |
| 134 | |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 135 | #Method const float* vec() const |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 136 | #In Property_Functions |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 137 | #Line # returns array of components ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 138 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 139 | Returns SkRGBA4f components as a read-only array. |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 140 | |
| 141 | #Return components as read-only array ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 142 | |
| 143 | #Example |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 144 | SkColor4f color = SkColor4f::FromColor(0x884488CC);
|
| 145 | SkDebugf("red=%g green=%g blue=%g alpha=%g\n", color.fR, color.fG, color.fB, color.fA);
|
| 146 | const float* array = color.vec();
|
| 147 | SkDebugf("[0]=%g [1]=%g [2]=%g [3]=%g\n", array[0], array[1], array[2], array[3]);
|
| 148 | #StdOut |
Cary Clark | 5b1f953 | 2018-08-28 14:53:37 -0400 | [diff] [blame] | 149 | red=0.266667 green=0.533333 blue=0.8 alpha=0.533333
|
| 150 | [0]=0.266667 [1]=0.533333 [2]=0.8 [3]=0.533333 |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 151 | ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 152 | ## |
| 153 | |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 154 | #SeeAlso SkColor4f |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 155 | |
| 156 | #Method ## |
| 157 | |
| 158 | # ------------------------------------------------------------------------------ |
| 159 | |
| 160 | #Method float* vec() |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 161 | #In Property_Functions |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 162 | #Line # returns array of components ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 163 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 164 | Returns SkRGBA4f components as a writable array. |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 165 | |
| 166 | #Return components as writable array ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 167 | |
| 168 | #Example |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 169 | SkColor4f color = SkColor4f::FromColor(0x884488CC);
|
| 170 | SkDebugf("red=%g green=%g blue=%g alpha=%g\n", color.fR, color.fG, color.fB, color.fA);
|
| 171 | float* array = color.vec();
|
| 172 | array[3] = 1;
|
| 173 | SkDebugf("[0]=%g [1]=%g [2]=%g [3]=%g\n", array[0], array[1], array[2], array[3]); |
| 174 | #StdOut |
Cary Clark | 5b1f953 | 2018-08-28 14:53:37 -0400 | [diff] [blame] | 175 | red=0.266667 green=0.533333 blue=0.8 alpha=0.533333
|
| 176 | [0]=0.266667 [1]=0.533333 [2]=0.8 [3]=1 |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 177 | ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 178 | ## |
| 179 | |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 180 | #SeeAlso SkColor4f |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 181 | |
| 182 | #Method ## |
| 183 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 184 | #Method float operator[](int index)_const |
| 185 | #Line # returns component by index ## |
| 186 | |
| 187 | Returns SkRGBA4f component by index, zero through three. index out of range |
| 188 | triggers an assert in debug builds. |
| 189 | |
| 190 | #Param index component, zero through three ## |
| 191 | #Return component by index ## |
| 192 | |
| 193 | #NoExample |
| 194 | ## |
| 195 | |
| 196 | #SeeAlso vec |
| 197 | |
| 198 | #Method ## |
| 199 | |
| 200 | #Method float& operator[](int index) |
| 201 | #Line # returns writable component reference ## |
| 202 | |
| 203 | Returns writable component reference by index, zero through three. index out of range |
| 204 | triggers an assert in debug builds. |
| 205 | |
| 206 | #Param index component, zero through three ## |
| 207 | #Return writable component reference by index ## |
| 208 | |
| 209 | #NoExample |
| 210 | ## |
| 211 | |
| 212 | #SeeAlso vec |
| 213 | |
| 214 | #Method ## |
| 215 | |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 216 | # ------------------------------------------------------------------------------ |
| 217 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 218 | #Subtopic Utility_Functions |
| 219 | #Line # less common functions ## |
| 220 | #Subtopic Utility_Functions ## |
| 221 | |
| 222 | #Method bool isOpaque() const |
| 223 | #In Utility_Functions |
| 224 | #Line # returns if Alpha component is at maximum ## |
| 225 | |
| 226 | Returns true if Alpha component is one. Color has no transparency regardless of |
| 227 | whether color is Premultiplied or Unpremultiplied. Triggers a debugging assert |
| 228 | if Alpha not valid. |
| 229 | |
| 230 | #Return true if Alpha is one ## |
| 231 | |
| 232 | #NoExample |
| 233 | ## |
| 234 | |
| 235 | #SeeAlso vec SkColorGetA |
| 236 | |
| 237 | ## |
| 238 | |
| 239 | # ------------------------------------------------------------------------------ |
| 240 | |
| 241 | #Method static SkRGBA4f Pin(float r, float g, float b, float a) |
| 242 | #In Utility_Functions |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 243 | #Line # sets components to valid range ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 244 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 245 | Constructs and returns SkRGBA4f with each component pinned from zero to one. |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 246 | |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 247 | #Param r red component ## |
| 248 | #Param g green component ## |
| 249 | #Param b blue component ## |
| 250 | #Param a Alpha component ## |
| 251 | |
| 252 | #Return Color4f with valid components ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 253 | |
| 254 | #Example |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 255 | #Height 40 |
| 256 | uint32_t storage[8]; |
| 257 | SkImageInfo info = SkImageInfo::MakeN32Premul(8, 1); |
| 258 | SkPixmap pixmap(info, storage, info.minRowBytes()); |
| 259 | pixmap.erase(SK_ColorWHITE); |
| 260 | SkIRect bounds = {0, 0, 1, 1}; |
| 261 | SkColor4f colors[] = { SkColor4f::Pin(1.5, 0.45f, 0.0, 1), |
| 262 | SkColor4f::Pin(1, 0.45f, -0.25, 1), |
| 263 | {1.5, 0.45f, 0.0, 1}, |
| 264 | {1, 0.45f, -0.25, 1}, |
| 265 | }; |
| 266 | for (auto color4f : colors) { |
| 267 | pixmap.erase(color4f, &bounds); |
| 268 | bounds.offset(2, 0); |
| 269 | } |
| 270 | SkBitmap bitmap; |
| 271 | canvas->scale(20, 20); |
| 272 | bitmap.installPixels(pixmap); |
| 273 | canvas->drawBitmap(bitmap, 0, 0); |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 274 | ## |
| 275 | |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 276 | #SeeAlso pin() FromColor |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 277 | |
| 278 | #Method ## |
| 279 | |
| 280 | # ------------------------------------------------------------------------------ |
| 281 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 282 | #Method SkRGBA4f pin() const |
| 283 | #In Utility_Functions |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 284 | #Line # sets components to valid range ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 285 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 286 | Returns SkRGBA4f with all components in the range from zero to one. |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 287 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 288 | #Return SkRGBA4f with valid components ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 289 | |
| 290 | #Example |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 291 | #Height 40 |
| 292 | uint32_t storage[8]; |
| 293 | SkImageInfo info = SkImageInfo::MakeN32Premul(8, 1); |
| 294 | SkPixmap pixmap(info, storage, info.minRowBytes()); |
| 295 | pixmap.erase(SK_ColorWHITE); |
| 296 | SkIRect bounds = {0, 0, 1, 1}; |
| 297 | SkColor4f colors[] = { {1.5, 0.45f, 0.0, 1}, |
| 298 | {1, 0.45f, -0.25, 1}, |
| 299 | }; |
| 300 | for (auto color4f : colors) { |
| 301 | pixmap.erase(color4f, &bounds); |
| 302 | bounds.offset(2, 0); |
| 303 | pixmap.erase(color4f.pin(), &bounds); |
| 304 | bounds.offset(2, 0); |
| 305 | } |
| 306 | SkBitmap bitmap; |
| 307 | canvas->scale(20, 20); |
| 308 | bitmap.installPixels(pixmap); |
| 309 | canvas->drawBitmap(bitmap, 0, 0); |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 310 | ## |
| 311 | |
Cary Clark | ffb3d68 | 2018-05-17 12:17:28 -0400 | [diff] [blame] | 312 | #SeeAlso Pin |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 313 | |
| 314 | #Method ## |
| 315 | |
| 316 | # ------------------------------------------------------------------------------ |
| 317 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 318 | #Method static SkRGBA4f FromColor(SkColor) |
| 319 | #In Utility_Functions |
| 320 | #Line # sets components from Color ## |
| 321 | |
| 322 | Converts to closest SkRGBA4f. |
| 323 | |
| 324 | #Param SkColor Color with Alpha, red, blue, and green components ## |
| 325 | |
| 326 | #Return SkRGBA4f equivalent ## |
| 327 | |
| 328 | #Example |
| 329 | uint8_t red = 77, green = 101, blue = 153, alpha = 43;
|
| 330 | SkColor argb = SkColorSetARGB(alpha, red, green, blue);
|
| 331 | SkColor4f color4f = SkColor4f::FromColor(argb);
|
| 332 | SkDebugf("red=%g green=%g blue=%g alpha=%g\n", color4f.fR, color4f.fG, color4f.fB, color4f.fA);
|
| 333 | SkColor fromColor4f = color4f.toSkColor();
|
| 334 | SkDebugf("red=%d green=%d blue=%d alpha=%d\n", SkColorGetR(fromColor4f),
|
| 335 | SkColorGetG(fromColor4f), SkColorGetB(fromColor4f), SkColorGetA(fromColor4f)); |
| 336 | #StdOut |
| 337 | red=0.301961 green=0.396078 blue=0.6 alpha=0.168627
|
| 338 | red=77 green=101 blue=153 alpha=43 |
| 339 | ## |
| 340 | ## |
| 341 | |
| 342 | #SeeAlso toSkColor |
| 343 | |
| 344 | #Method ## |
| 345 | |
| 346 | # ------------------------------------------------------------------------------ |
| 347 | |
| 348 | #Method SkColor toSkColor() const |
| 349 | #In Utility_Functions |
| 350 | #Line # returns closest Color ## |
| 351 | |
| 352 | Converts to closest SkColor. |
| 353 | |
| 354 | #Return closest Color ## |
| 355 | |
| 356 | #Example |
| 357 | float red = 0.07, green = 0.13, blue = 0.32, alpha = 0.17;
|
| 358 | SkColor4f color4f = { red, green, blue, alpha };
|
| 359 | SkColor argb = color4f.toSkColor();
|
| 360 | SkDebugf("red=%d green=%d blue=%d alpha=%d\n", SkColorGetR(argb),
|
| 361 | SkColorGetG(argb), SkColorGetB(argb), SkColorGetA(argb)); |
| 362 | SkColor4f fromSkColor = SkColor4f::FromColor(argb);
|
| 363 | SkDebugf("red=%g green=%g blue=%g alpha=%g\n", fromSkColor.fR, fromSkColor.fG,
|
| 364 | fromSkColor.fB, fromSkColor.fA);
|
| 365 | #StdOut
|
| 366 | red=18 green=33 blue=82 alpha=43
|
| 367 | red=0.0705882 green=0.129412 blue=0.321569 alpha=0.168627
|
| 368 | ##
|
| 369 | ## |
| 370 | |
| 371 | #SeeAlso FromColor |
| 372 | |
| 373 | #Method ## |
| 374 | |
| 375 | # ------------------------------------------------------------------------------ |
| 376 | |
| 377 | #Method static SkRGBA4f FromPMColor(SkPMColor) |
| 378 | #In Utility_Functions |
| 379 | #Line # converts from Premultiplied Color ## |
| 380 | |
| 381 | Converts from Premultiplied integer components to Unpremultiplied float |
| 382 | components. |
| 383 | |
| 384 | #Param SkPMColor Premultiplied color ## |
| 385 | |
| 386 | #Return Unpremultiplied color ## |
| 387 | |
| 388 | #NoExample |
| 389 | ## |
| 390 | |
| 391 | #SeeAlso FromColor |
| 392 | |
| 393 | #Method ## |
| 394 | |
| 395 | # ------------------------------------------------------------------------------ |
| 396 | |
| 397 | #Method SkRGBA4f<kPremul_SkAlphaType> premul() const |
Cary Clark | b94f6da | 2018-06-08 11:54:32 -0400 | [diff] [blame] | 398 | #In Utility |
Cary Clark | c9b49fe | 2018-09-21 14:26:30 -0400 | [diff] [blame] | 399 | #Line # returns Premultiplied color ## |
| 400 | |
| 401 | Returns SkColor4f with all components premultiplied by Alpha. |
| 402 | |
| 403 | #Return Premultiplied color ## |
| 404 | |
| 405 | #NoExample |
| 406 | ## |
| 407 | |
| 408 | #SeeAlso unpremul |
| 409 | |
| 410 | #Method ## |
| 411 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 412 | #Method SkRGBA4f<kUnpremul_SkAlphaType> unpremul() const |
Cary Clark | c9b49fe | 2018-09-21 14:26:30 -0400 | [diff] [blame] | 413 | #In Utility |
| 414 | #Line # returns Unpremultiplied color ## |
| 415 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 416 | Returns SkRGBA4f with all components independent of Alpha. |
Cary Clark | c9b49fe | 2018-09-21 14:26:30 -0400 | [diff] [blame] | 417 | |
| 418 | #Return Unpremultiplied color ## |
| 419 | |
| 420 | #NoExample |
| 421 | ## |
| 422 | |
| 423 | #SeeAlso premul |
| 424 | |
| 425 | #Method ## |
| 426 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 427 | #Struct ## |
Cary Clark | c9b49fe | 2018-09-21 14:26:30 -0400 | [diff] [blame] | 428 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 429 | #Typedef SkRGBA4f SkColor4f |
| 430 | #Line # defines Unpremultiplied Color using floats ## |
| 431 | |
| 432 | #Code |
| 433 | using SkColor4f = SkRGBA4f<kUnpremul_SkAlphaType>; |
Cary Clark | b94f6da | 2018-06-08 11:54:32 -0400 | [diff] [blame] | 434 | ## |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 435 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 436 | ## |
| 437 | |
Cary Clark | 2d4bf5f | 2018-04-16 08:37:38 -0400 | [diff] [blame] | 438 | #Topic Color4f ## |