MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GfxPreprocessLine

Function GfxPreprocessLine

src/gfx.cpp:378–391  ·  view source on GitHub ↗

* Align parameters of a line to the given DPI and check simple clipping. * @param dpi Screen parameters to align with. * @param x X coordinate of first point. * @param y Y coordinate of first point. * @param x2 X coordinate of second point. * @param y2 Y coordinate of second point. * @param width Width of the line. * @return True if the line is likely to be visible, false if it's certainly

Source from the content-addressed store, hash-verified

376 * invisible.
377 */
378static inline bool GfxPreprocessLine(DrawPixelInfo *dpi, int &x, int &y, int &x2, int &y2, int width)
379{
380 x -= dpi->left;
381 x2 -= dpi->left;
382 y -= dpi->top;
383 y2 -= dpi->top;
384
385 /* Check simple clipping */
386 if (x + width / 2 < 0 && x2 + width / 2 < 0 ) return false;
387 if (y + width / 2 < 0 && y2 + width / 2 < 0 ) return false;
388 if (x - width / 2 > dpi->width && x2 - width / 2 > dpi->width ) return false;
389 if (y - width / 2 > dpi->height && y2 - width / 2 > dpi->height) return false;
390 return true;
391}
392
393void GfxDrawLine(int x, int y, int x2, int y2, PixelColour colour, int width, int dash)
394{

Callers 2

GfxDrawLineFunction · 0.85
GfxDrawLineUnscaledFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected