diff options
author | frosch <frosch@openttd.org> | 2011-04-02 16:39:30 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-04-02 16:39:30 +0000 |
commit | b18211bb9d1f8f758e814a5b5f6dc74e78183c51 (patch) | |
tree | 1fa7d4f5b289ca68bb97d0e167b36a80ee9b4eae /src/gfx.cpp | |
parent | 7659575cfa52b6fd9eea9c1256b325f84261e29f (diff) | |
download | openttd-b18211bb9d1f8f758e814a5b5f6dc74e78183c51.tar.xz |
(svn r22291) -Add: a linewidth argument to GfxDrawLine() and Blitter::DrawLine().
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r-- | src/gfx.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index 6253238a3..62b8b024a 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -192,23 +192,25 @@ void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectM } } -void GfxDrawLine(int x, int y, int x2, int y2, int colour) +void GfxDrawLine(int x, int y, int x2, int y2, int colour, int width) { Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); DrawPixelInfo *dpi = _cur_dpi; + assert(width > 0); + x -= dpi->left; x2 -= dpi->left; y -= dpi->top; y2 -= dpi->top; /* Check clipping */ - if (x < 0 && x2 < 0) return; - if (y < 0 && y2 < 0) return; - if (x > dpi->width && x2 > dpi->width) return; - if (y > dpi->height && y2 > dpi->height) return; + if (x + width / 2 < 0 && x2 + width / 2 < 0 ) return; + if (y + width / 2 < 0 && y2 + width / 2 < 0 ) return; + if (x - width / 2 > dpi->width && x2 - width / 2 > dpi->width ) return; + if (y - width / 2 > dpi->height && y2 - width / 2 > dpi->height) return; - blitter->DrawLine(dpi->dst_ptr, x, y, x2, y2, dpi->width, dpi->height, colour); + blitter->DrawLine(dpi->dst_ptr, x, y, x2, y2, dpi->width, dpi->height, colour, width); } void GfxDrawLineUnscaled(int x, int y, int x2, int y2, int colour) @@ -229,7 +231,7 @@ void GfxDrawLineUnscaled(int x, int y, int x2, int y2, int colour) blitter->DrawLine(dpi->dst_ptr, UnScaleByZoom(x, dpi->zoom), UnScaleByZoom(y, dpi->zoom), UnScaleByZoom(x2, dpi->zoom), UnScaleByZoom(y2, dpi->zoom), - UnScaleByZoom(dpi->width, dpi->zoom), UnScaleByZoom(dpi->height, dpi->zoom), colour); + UnScaleByZoom(dpi->width, dpi->zoom), UnScaleByZoom(dpi->height, dpi->zoom), colour, 1); } /** |