* Inverts all the colors in the surface according to a middle point. * Used for effects like shifting a button between pressed and unpressed. * @param mid Middle point. */
| 449 | * @param mid Middle point. |
| 450 | */ |
| 451 | void Surface::invert(Uint8 mid) |
| 452 | { |
| 453 | // Lock the surface |
| 454 | lock(); |
| 455 | |
| 456 | for (int x = 0, y = 0; x < getWidth() && y < getHeight();) |
| 457 | { |
| 458 | Uint8 pixel = getPixel(x, y); |
| 459 | if (pixel > 0) |
| 460 | { |
| 461 | setPixelIterative(&x, &y, pixel + 2 * ((int)mid - (int)pixel)); |
| 462 | } |
| 463 | else |
| 464 | { |
| 465 | setPixelIterative(&x, &y, 0); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | // Unlock the surface |
| 470 | unlock(); |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Runs any code the surface needs to keep updating every |
no outgoing calls
no test coverage detected