MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / invert

Method invert

src/Engine/Surface.cpp:451–471  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

449 * @param mid Middle point.
450 */
451void 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

Callers 3

mousePressMethod · 0.80
drawMethod · 0.80
drawMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected