1/* 2 * Copyright 2013, 2020 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * John Scipione, jscipione@gmail.com 7 * Niels Sascha Reedijk, niels.reedijk@gmail.com 8 * 9 * Corresponds to: 10 * headers/os/interface/GraphicsDefs.h hrev54374 11 * src/kits/interface/GraphicsDefs.cpp hrev49977 12 */ 13 14 15/*! 16 \file GraphicsDefs.h 17 \ingroup interface 18 \ingroup libbe 19 \brief Graphics-related functions and variables used by the Interface Kit. 20*/ 21 22 23///// Pattern ///// 24 25 26/*! 27 \name Patterns 28*/ 29 30 31//! @{ 32 33 34/*! 35 \struct pattern 36 \ingroup interface 37 \ingroup libbe 38 \brief A pattern to use when drawing. 39 40 \since BeOS R3 41*/ 42 43 44/*! 45 \fn bool operator==(const pattern &a, const pattern &b) 46 \brief Comparison operator for two patterns 47 48 \retval true The patterns match 49 \retval false The patterns do not match 50 51 \since Haiku R1 52*/ 53 54 55/*! 56 \fn bool operator!=(const pattern &a, const pattern &b) 57 \brief Comparison operator for two patterns 58 59 \retval true The patterns do not match 60 \retval false The patterns match 61 62 \since Haiku R1 63*/ 64 65 66/*! 67 \var B_SOLID_HIGH 68 69 Draw using the view's high color. 70 71 \since BeOS R3 72*/ 73 74 75/*! 76 \var B_MIXED_COLORS 77 78 Draw a pattern of the view's high and low colors. 79 80 \since BeOS R3 81*/ 82 83 84/*! 85 \var B_SOLID_LOW 86 87 Draw using the view's low color. 88 89 \since BeOS R3 90*/ 91 92//! @} 93 94 95///// struct rgb_color ///// 96 97 98/*! 99 \name RGB Colors 100*/ 101 102 103//! @{ 104 105 106/*! 107 \struct rgb_color 108 \ingroup interface 109 \ingroup libbe 110 \brief Structure representing a 32 bit RGBA color. 111 112 \since BeOS R3 113*/ 114 115 116/*! 117 \var uint8 rgb_color::red 118 \brief Red value for the color. 119 120 \since BeOS R3 121*/ 122 123 124/*! 125 \var uint8 rgb_color::green 126 \brief Green value for the color. 127 128 \since BeOS R3 129*/ 130 131 132/*! 133 \var uint8 rgb_color::blue 134 \brief Blue value for the color. 135 136 \since BeOS R3 137*/ 138 139 140/*! 141 \var uint8 rgb_color::alpha 142 \brief Alpha value for the color. 143 144 \since BeOS R3 145*/ 146 147 148/*! 149 \fn rgb_color& rgb_color::set_to(uint8 r, uint8 g, uint8 b, uint8 a=255) 150 \brief Helper method to set all values of the color. 151 152 \param r Red value. 153 \param g Green value. 154 \param b Blue value. 155 \param a Alpha value. 156 157 \return A reference to this object. 158 159 \since Haiku R1 160*/ 161 162 163/*! 164 \fn bool rgb_color::operator==(const rgb_color &other) const 165 \brief Comparison operator. 166 167 \param other The other color to compare to. 168 169 \retval true The colors match. 170 \retval false The colors are different. 171 172 \since Haiku R1 173*/ 174 175 176/*! 177 \fn bool rgb_color::operator!=(const rgb_color &other) const 178 \brief Comparison operator. 179 180 \param other The other color to compare to. 181 182 \retval true The colors are different. 183 \retval false The colors match. 184 185 \since Haiku R1 186*/ 187 188 189/*! 190 \fn rgb_color& rgb_color::operator=(const rgb_color &other) 191 \brief Assign values from another color object. 192 193 \param other The other color to copy. 194 195 \return A reference to this object. 196 197 \since Haiku R1 198*/ 199 200 201/*! 202 \fn int32 rgb_color::Brightness() const 203 \brief Calculates a value representing the brightness of this color. 204 205 This method uses a fast algorithm to calculate the brightness in Luma of 206 the color. 207 208 \return A value representing the brightness. 209 210 \since Haiku R1 211*/ 212 213 214/*! 215 \fn rgb_color make_color(uint8 red, uint8 green, uint8 blue, uint8 alpha=255) 216 \brief Create a \a rgb_color from RGBA values. 217 218 \param red The value for red. 219 \param green The value for green. 220 \param blue The value for blue. 221 \param alpha The alpha value. Set to opaque by default. 222 223 \return A new rgb_color set to the selected colors. 224 225 \since Haiku R1 226*/ 227 228 229/*! 230 \fn rgb_color mix_color(rgb_color color1, rgb_color color2, uint8 amount) 231 \brief Mix two colors without respect for their alpha values. 232 233 \param color1 First color. 234 \param color2 Second color. 235 \param amount The relative weight of \a color1 to mix in. 236 237 \return The newly-mixed \ref rgb_color. 238 239 \since Haiku R1 240*/ 241 242 243/*! 244 \fn rgb_color blend_color(rgb_color color1, rgb_color color2, uint8 amount) 245 \brief Mix two colors, respecting their alpha values. 246 247 \param color1 First color. 248 \param color2 Second color. 249 \param amount The relative weight of \a color1 to mix in. 250 251 \return The newly-mixed \ref rgb_color. 252 253 \since Haiku R1 254*/ 255 256 257/*! 258 \fn rgb_color disable_color(rgb_color color, rgb_color background) 259 \brief Calculate a color for a disabled look. 260 261 \param color The color that it would be if the use of your color is \em not 262 disabled. 263 \param background The background on which will be drawn. 264 265 \return A newly-mixed \ref rgb_color. 266 267 \since Haiku R1 268*/ 269 270 271/*! 272 \var const rgb_color B_TRANSPARENT_COLOR 273 \brief A transparent color. 274 275 \since Haiku R1 276*/ 277 278 279/*! 280 \var const uint8 B_TRANSPARENT_MAGIC_CMAP8 281 \brief Transparent color. 282 283 \since Haiku R1 284*/ 285 286 287/*! 288 \var const uint16 B_TRANSPARENT_MAGIC_RGBA15 289 \brief Transparent color. 290 291 \since Haiku R1 292*/ 293 294 295/*! 296 \var const uint16 B_TRANSPARENT_MAGIC_RGBA15_BIG 297 \brief Transparent color. 298 299 \since Haiku R1 300*/ 301 302 303/*! 304 \var const uint32 B_TRANSPARENT_MAGIC_RGBA32 305 \brief Transparent color. 306 307 \since Haiku R1 308*/ 309 310 311/*! 312 \var const uint32 B_TRANSPARENT_MAGIC_RGBA32_BIG 313 \brief Transparent color. 314 315 \since Haiku R1 316*/ 317 318 319/*! 320 \var const uint8 B_TRANSPARENT_8_BIT 321 \brief Transparent color. 322 323 \since BeOS R3 324*/ 325 326 327/*! 328 \var const rgb_color B_TRANSPARENT_32_BIT 329 \brief Transparent color. 330 331 \since BeOS R3 332*/ 333 334 335//! @} 336 337 338///// Drawing modes ///// 339 340 341/*! 342 \name Drawing Modes 343*/ 344 345 346//! @{ 347 348 349/*! 350 \enum source_alpha 351 \ingroup interface 352 353 Blending alpha mode constants. 354 355 \since BeOS R3 356*/ 357 358 359/*! 360 \var source_alpha B_PIXEL_ALPHA 361 362 Use the alpha value of each pixel when drawing a bitmap. 363 364 \since BeOS R3 365*/ 366 367 368/*! 369 \var source_alpha B_CONSTANT_ALPHA 370 371 Use the alpha channel of the view's high color. 372 373 \since BeOS R3 374*/ 375 376 377/*! 378 \enum alpha_function 379 \ingroup interface 380 381 Blending alpha function constants. 382 383 \since BeOS R3 384*/ 385 386 387/*! 388 \var alpha_function B_ALPHA_OVERLAY 389 390 Used for drawing a image with transparency over an opaque background. 391 392 \since BeOS R3 393*/ 394 395 396/*! 397 \var alpha_function B_ALPHA_COMPOSITE 398 399 Used to composite two or more transparent images together offscreen to 400 produce a new image drawn using \c B_ALPHA_OVERLAY mode. 401 402 \since BeOS R3 403*/ 404 405 406/*! 407 \var alpha_function B_ALPHA_COMPOSITE_SOURCE_OVER 408 409 Draws source over destination preserving transparency. Same as 410 \c B_ALPHA_COMPOSITE. 411 412 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 413 -> 414 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 415 = 416 \image{inline} html B_ALPHA_COMPOSITE_SOURCE_OVER.png "Result" 417 418 \since Haiku R1 419*/ 420 421 422/*! 423 \var alpha_function B_ALPHA_COMPOSITE_SOURCE_IN 424 425 Draws source only where destination is not transparent. 426 427 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 428 -> 429 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 430 = 431 \image{inline} html B_ALPHA_COMPOSITE_SOURCE_IN.png "Result" 432 433 \since Haiku R1 434*/ 435 436 437/*! 438 \var alpha_function B_ALPHA_COMPOSITE_SOURCE_OUT 439 440 Draws source only where destination is transparent. 441 442 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 443 -> 444 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 445 = 446 \image{inline} html B_ALPHA_COMPOSITE_SOURCE_OUT.png "Result" 447 448 \since Haiku R1 449*/ 450 451 452/*! 453 \var alpha_function B_ALPHA_COMPOSITE_SOURCE_ATOP 454 455 Draws source only where destination is not transparent. Colors from both 456 are used in the result. 457 458 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 459 -> 460 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 461 = 462 \image{inline} html B_ALPHA_COMPOSITE_SOURCE_ATOP.png "Result" 463 464 \since Haiku R1 465*/ 466 467 468/*! 469 \var alpha_function B_ALPHA_COMPOSITE_DESTINATION_OVER 470 471 Draws source where destination is transparent, making it appear as if it 472 is drawn behind. 473 474 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 475 -> 476 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 477 = 478 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION_OVER.png "Result" 479 480 \since Haiku R1 481*/ 482 483 484/*! 485 \var alpha_function B_ALPHA_COMPOSITE_DESTINATION_IN 486 487 Blends source alpha channel with destination. 488 489 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 490 -> 491 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 492 = 493 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION_IN.png "Result" 494 495 \since Haiku R1 496*/ 497 498 499/*! 500 \var alpha_function B_ALPHA_COMPOSITE_DESTINATION_OUT 501 502 Blends inverse of source alpha channel with destination. Result appears as 503 if source was cut out of destination. 504 505 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 506 -> 507 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 508 = 509 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION_OUT.png "Result" 510 511 \since Haiku R1 512*/ 513 514 515/*! 516 \var alpha_function B_ALPHA_COMPOSITE_DESTINATION_ATOP 517 518 Draws source only where it is not transparent. Destination is blended on 519 top of it. Colors from both are used in the result. 520 521 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 522 -> 523 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 524 = 525 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION_ATOP.png "Result" 526 527 \since Haiku R1 528*/ 529 530 531/*! 532 \var alpha_function B_ALPHA_COMPOSITE_XOR 533 534 Result is transparent only where both source and destination are transparent 535 or opaque. 536 537 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 538 -> 539 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 540 = 541 \image{inline} html B_ALPHA_COMPOSITE_XOR.png "Result" 542 543 \since Haiku R1 544*/ 545 546 547/*! 548 \var alpha_function B_ALPHA_COMPOSITE_CLEAR 549 550 Erases destination to full transparency, regardless of source alpha value. 551 552 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 553 -> 554 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 555 = 556 \image{inline} html B_ALPHA_COMPOSITE_CLEAR.png "Result" 557 558 \since Haiku R1 559*/ 560 561 562/*! 563 \var alpha_function B_ALPHA_COMPOSITE_DIFFERENCE 564 565 Subtracts both inputs in a way that always yields positive result. 566 567 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 568 -> 569 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 570 = 571 \image{inline} html B_ALPHA_COMPOSITE_DIFFERENCE.png "Result" 572 573 \since Haiku R1 574*/ 575 576 577/*! 578 \var alpha_function B_ALPHA_COMPOSITE_LIGHTEN 579 580 Retains lighter pixels of both inputs. 581 582 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 583 -> 584 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 585 = 586 \image{inline} html B_ALPHA_COMPOSITE_LIGHTEN.png "Result" 587 588 \since Haiku R1 589*/ 590 591 592/*! 593 \var alpha_function B_ALPHA_COMPOSITE_DARKEN 594 595 Retains darker pixels of both inputs. 596 597 \image{inline} html B_ALPHA_COMPOSITE_SOURCE.png "Source" 598 -> 599 \image{inline} html B_ALPHA_COMPOSITE_DESTINATION.png "Destination" 600 = 601 \image{inline} html B_ALPHA_COMPOSITE_DARKEN.png "Result" 602 603 \since Haiku R1 604*/ 605 606 607//! @} 608