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

Function DrawBox

src/gfx.cpp:425–454  ·  view source on GitHub ↗

* Draws the projection of a parallelepiped. * This can be used to draw boxes in world coordinates. * * @param x Screen X-coordinate of top front corner. * @param y Screen Y-coordinate of top front corner. * @param dx1 Screen X-length of first edge. * @param dy1 Screen Y-length of first edge. * @param dx2 Screen X-length of second edge. * @param dy2 Screen Y-length of second edge. * @p

Source from the content-addressed store, hash-verified

423 * @param dy3 Screen Y-length of third edge.
424 */
425void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3)
426{
427 /* ....
428 * .. ....
429 * .. ....
430 * .. ^
431 * <--__(dx1,dy1) /(dx2,dy2)
432 * : --__ / :
433 * : --__ / :
434 * : *(x,y) :
435 * : | :
436 * : | ..
437 * .... |(dx3,dy3)
438 * .... | ..
439 * ....V.
440 */
441
442 static constexpr PixelColour colour = PC_WHITE;
443
444 GfxDrawLineUnscaled(x, y, x + dx1, y + dy1, colour);
445 GfxDrawLineUnscaled(x, y, x + dx2, y + dy2, colour);
446 GfxDrawLineUnscaled(x, y, x + dx3, y + dy3, colour);
447
448 GfxDrawLineUnscaled(x + dx1, y + dy1, x + dx1 + dx2, y + dy1 + dy2, colour);
449 GfxDrawLineUnscaled(x + dx1, y + dy1, x + dx1 + dx3, y + dy1 + dy3, colour);
450 GfxDrawLineUnscaled(x + dx2, y + dy2, x + dx2 + dx1, y + dy2 + dy1, colour);
451 GfxDrawLineUnscaled(x + dx2, y + dy2, x + dx2 + dx3, y + dy2 + dy3, colour);
452 GfxDrawLineUnscaled(x + dx3, y + dy3, x + dx3 + dx1, y + dy3 + dy1, colour);
453 GfxDrawLineUnscaled(x + dx3, y + dy3, x + dx3 + dx2, y + dy3 + dy2, colour);
454}
455
456/**
457 * Draw the outline of a Rect

Callers 1

Calls 1

GfxDrawLineUnscaledFunction · 0.85

Tested by

no test coverage detected