MCPcopy Create free account
hub / github.com/BruceDevices/firmware / setWindow

Method setWindow

lib/TFT_eSPI/Extensions/Sprite.cpp:1253–1283  ·  view source on GitHub ↗

** Function name: setWindow ** Description: Set the bounds of a window in the sprite ***************************************************************************************/ Intentionally not constrained to viewport area, does not manage 1bpp rotations

Source from the content-addressed store, hash-verified

1251***************************************************************************************/
1252// Intentionally not constrained to viewport area, does not manage 1bpp rotations
1253void TFT_eSprite::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
1254{
1255 if (x0 > x1) transpose(x0, x1);
1256 if (y0 > y1) transpose(y0, y1);
1257
1258 int32_t w = width();
1259 int32_t h = height();
1260
1261 if ((x0 >= w) || (x1 < 0) || (y0 >= h) || (y1 < 0))
1262 { // Point to that extra "off screen" pixel
1263 _xs = 0;
1264 _ys = _dheight;
1265 _xe = 0;
1266 _ye = _dheight;
1267 }
1268 else
1269 {
1270 if (x0 < 0) x0 = 0;
1271 if (x1 >= w) x1 = w - 1;
1272 if (y0 < 0) y0 = 0;
1273 if (y1 >= h) y1 = h - 1;
1274
1275 _xs = x0;
1276 _ys = y0;
1277 _xe = x1;
1278 _ye = y1;
1279 }
1280
1281 _xptr = _xs;
1282 _yptr = _ys;
1283}
1284
1285
1286/***************************************************************************************

Callers 1

pushRotatedMethod · 0.45

Calls 1

transposeFunction · 0.85

Tested by

no test coverage detected