WoopsiGfx 1.4
Nintendo DS 2D Graphics Library
|
#include <libwoopsigfx/include/graphics.h>
Public Member Functions | |
Graphics (MutableBitmapBase *bitmap, const Rect &clipRect) | |
virtual | ~Graphics () |
void | setClipRect (const Rect &clipRect) |
void | getClipRect (Rect &rect) const |
const u16 | getPixel (s16 x, s16 y) const |
virtual void | drawPixel (s16 x, s16 y, u16 colour) |
virtual void | drawFilledRect (s16 x, s16 y, u16 width, u16 height, u16 colour) |
virtual void | drawRect (s16 x, s16 y, u16 width, u16 height, u16 colour) |
virtual void | drawXORPixel (s16 x, s16 y, u16 colour) |
virtual void | drawXORHorizLine (s16 x, s16 y, u16 width, u16 colour) |
virtual void | drawXORVertLine (s16 x, s16 y, u16 height, u16 colour) |
virtual void | drawFilledXORRect (s16 x, s16 y, u16 width, u16 height, u16 colour) |
virtual void | drawXORRect (s16 x, s16 y, u16 width, u16 height, u16 colour) |
virtual void | drawXORPixel (s16 x, s16 y) |
virtual void | drawXORHorizLine (s16 x, s16 y, u16 width) |
virtual void | drawXORVertLine (s16 x, s16 y, u16 height) |
virtual void | drawXORRect (s16 x, s16 y, u16 width, u16 height) |
virtual void | drawFilledXORRect (s16 x, s16 y, u16 width, u16 height) |
virtual void | drawBitmap (s16 x, s16 y, u16 width, u16 height, const BitmapBase *bitmap, s16 bitmapX, s16 bitmapY) |
virtual void | drawBitmap (s16 x, s16 y, u16 width, u16 height, const BitmapBase *bitmap, s16 bitmapX, s16 bitmapY, u16 transparentColour) |
virtual void | drawBitmapGreyScale (s16 x, s16 y, u16 width, u16 height, const BitmapBase *bitmap, s16 bitmapX, s16 bitmapY) |
virtual void | floodFill (s16 x, s16 y, u16 newColour) |
void | copy (s16 sourceX, s16 sourceY, s16 destX, s16 destY, u16 width, u16 height) |
void | dim (s16 x, s16 y, u16 width, u16 height) |
virtual void | drawLine (s16 x1, s16 y1, s16 x2, s16 y2, u16 colour) |
virtual void | drawEllipse (s16 xCentre, s16 yCentre, s16 horizRadius, s16 vertRadius, u16 colour) |
virtual void | drawFilledEllipse (s16 xCentre, s16 yCentre, s16 horizRadius, s16 vertRadius, u16 colour) |
void | greyScale (s16 x, s16 y, u16 width, u16 height) |
virtual void | drawText (s16 x, s16 y, FontBase *font, const WoopsiString &string) |
virtual void | drawText (s16 x, s16 y, FontBase *font, const WoopsiString &string, s32 startIndex, s32 length, u16 colour=0) |
void | drawBaselineText (s16 x, s16 y, FontBase *font, const WoopsiString &string, s32 startIndex, s32 length, u16 colour=0) |
virtual void | scroll (s16 x, s16 y, s16 xDistance, s16 yDistance, u16 width, u16 height, WoopsiArray< Rect > *revealedRects) |
virtual void | drawBevelledRect (s16 x, s16 y, u16 width, u16 height, u16 shineColour, u16 shadowColour) |
Protected Member Functions | |
virtual void | drawHorizLine (s16 x, s16 y, u16 width, u16 colour) |
virtual void | drawVertLine (s16 x, s16 y, u16 height, u16 colour) |
virtual void | drawCircle (s16 x0, s16 y0, u16 radius, u16 colour) |
virtual void | drawFilledCircle (s16 x0, s16 y0, u16 radius, u16 colour) |
bool | clipBitmapCoordinates (s16 *x, s16 *y, u16 *width, u16 *height) |
bool | popStack (s16 *x, s16 *y, WoopsiArray< s32 > &stack) |
void | pushStack (s16 x, s16 y, WoopsiArray< s32 > &stack) |
u8 | getClipLineOutCode (s16 x, s16 y, s16 xMin, s16 yMin, s16 xMax, s16 yMax) |
void | drawClippedLine (s16 x1, s16 y1, s16 x2, s16 y2, u16 colour) |
void | drawClippedBitmapGreyScale (s16 x, s16 y, u16 width, u16 height, const BitmapBase *bitmap, s16 bitmapX, s16 bitmapY) |
bool | clipCoordinates (s16 *x1, s16 *y1, s16 *x2, s16 *y2, const Rect &clipRect) |
Graphics (const Graphics &graphics) | |
Protected Attributes | |
MutableBitmapBase * | _bitmap |
u16 | _width |
u16 | _height |
Rect | _clipRect |
Class providing bitmap manipulation (drawing, etc) functions. Functions are all clipped to the size of the bitmap being drawn to.
Graphics::Graphics | ( | MutableBitmapBase * | bitmap, |
const Rect & | clipRect | ||
) |
Constructor.
bitmap | The bitmap that the port will draw to. |
clipRect | The clipping region within which the class must draw. |
virtual WoopsiGfx::Graphics::~Graphics | ( | ) | [inline, virtual] |
Destructor.
WoopsiGfx::Graphics::Graphics | ( | const Graphics & | graphics | ) | [inline, protected] |
Copy constructor is protected to prevent usage.
bool WoopsiGfx::Graphics::clipBitmapCoordinates | ( | s16 * | x, |
s16 * | y, | ||
u16 * | width, | ||
u16 * | height | ||
) | [protected] |
Clip the supplied rectangular dimensions to the size of the internal bitmap.
x | The x co-ordinate of the rectangle to clip (modified by the function). |
y | The y co-ordinate of the rectangle to clip (modified by the function). |
width | The width of the rectangle to clip (modified by the function). |
height | The height of the rectangle to clip (modified by the function). |
bool Graphics::clipCoordinates | ( | s16 * | x1, |
s16 * | y1, | ||
s16 * | x2, | ||
s16 * | y2, | ||
const Rect & | clipRect | ||
) | [protected] |
Clips the supplied co-ordinates so that they fit within the supplied clipping rectangle. If the clipped area is empty, the method returns false to indicate this. Otherwise, it returns true.
x1 | The top-left x co-ordinate. |
y1 | The top-left y co-ordinate. |
x2 | The bottom-right x co-ordinate. |
y2 | The bottom-right y co-ordinate. |
clipRect | A rect to clip to. |
void Graphics::copy | ( | s16 | sourceX, |
s16 | sourceY, | ||
s16 | destX, | ||
s16 | destY, | ||
u16 | width, | ||
u16 | height | ||
) |
Copy a rectangular region from the source co-ordinates to the destination co-ordinates. Uses the DMA for speed. Worst-case scenario uses an off-screen buffer for situations wherein there is no vertical movement and the source and destination overlap, in which case two copies are performed for each row (source to buffer and buffer to destination). Does not clip.
sourceX | Source x co-ord. |
sourceY | Source y co-ord. |
destX | Destination x co-ord. |
destY | Destination y co-ord. |
width | Width of the rectangle to copy. |
height | Height of the rectangle to copy. |
void Graphics::dim | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height | ||
) |
Halve the brightness of a specified region.
x | X co-ord of the region to dim. |
y | Y co-ord of the region to dim. |
width | Width of the region to dim. |
height | Height of the region to dim. |
void Graphics::drawBaselineText | ( | s16 | x, |
s16 | y, | ||
FontBase * | font, | ||
const WoopsiString & | string, | ||
s32 | startIndex, | ||
s32 | length, | ||
u16 | colour = 0 |
||
) |
Draw a portion of a string on a baseline (chars may have different tops/heights/depths) to the bitmap.
x | The x co-ordinate of the string. |
y | The y co-ordinate of the string. |
font | The font to draw with. |
string | The string to output. |
startIndex | The start index within the string from which drawing will commence. |
length | The number of characters to draw. |
colour | The colour of the string. If this is not specified the font's default colour will be used. |
void Graphics::drawBevelledRect | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height, | ||
u16 | shineColour, | ||
u16 | shadowColour | ||
) | [virtual] |
Draw a bevelled rectangle to the bitmap.
x | The x co-ordinate of the rectangle. |
y | The y co-ordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
shineColour | The colour of the top/left sides. |
shadowColour | The colour of the bottom/right sides. |
void Graphics::drawBitmap | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height, | ||
const BitmapBase * | bitmap, | ||
s16 | bitmapX, | ||
s16 | bitmapY | ||
) | [virtual] |
Draw an external bitmap to the internal bitmap.
x | The x co-ordinate to draw the bitmap to. |
y | The y co-ordinate to draw the bitmap to. |
width | The width of the bitmap to draw. |
height | The height of the bitmap to draw. |
bitmap | Pointer to the bitmap to draw. |
bitmapX | The x co-ordinate within the supplied bitmap to use as the origin. |
bitmapY | The y co-ordinate within the supplied bitmap to use as the origin. |
void Graphics::drawBitmap | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height, | ||
const BitmapBase * | bitmap, | ||
s16 | bitmapX, | ||
s16 | bitmapY, | ||
u16 | transparentColour | ||
) | [virtual] |
Draw a bitmap to the port's bitmap, using the supplied transparent colour as an invisible colour. This is considerably slower than the standard bitmap drawing routine as it plots pixel-by-pixel instead of using a scanline DMA copy.
x | The x co-ordinate to draw the bitmap to. |
y | The y co-ordinate to draw the bitmap to. |
width | The width of the bitmap to draw. |
height | The height of the bitmap to draw. |
bitmap | Pointer to the bitmap to draw. |
bitmapX | The x co-ordinate within the supplied bitmap to use as the origin. |
bitmapY | The y co-ordinate within the supplied bitmap to use as the origin. |
transparentColour | The transparent colour used in the bitmap. |
void Graphics::drawBitmapGreyScale | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height, | ||
const BitmapBase * | bitmap, | ||
s16 | bitmapX, | ||
s16 | bitmapY | ||
) | [virtual] |
Draw a bitmap to the port's bitmap in greyscale. This is considerably slower than the standard bitmap drawing routine as it plots pixel-by-pixel instead of using a scanline DMA copy.
x | The x co-ordinate to draw the bitmap to. |
y | The y co-ordinate to draw the bitmap to. |
width | The width of the bitmap to draw. |
height | The height of the bitmap to draw. |
bitmap | Pointer to the bitmap to draw. |
bitmapX | The x co-ordinate within the supplied bitmap to use as the origin. |
bitmapY | The y co-ordinate within the supplied bitmap to use as the origin. |
void Graphics::drawCircle | ( | s16 | x0, |
s16 | y0, | ||
u16 | radius, | ||
u16 | colour | ||
) | [protected, virtual] |
Draw an unfilled circle to the internal bitmap. Faster than drawEllipse() but limited to circles only.
x0 | The x co-ordinate of the circle. |
y0 | The y co-ordinate of the circle. |
radius | The radius of the circle. |
colour | The colour of the circle. |
void WoopsiGfx::Graphics::drawClippedBitmapGreyScale | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height, | ||
const BitmapBase * | bitmap, | ||
s16 | bitmapX, | ||
s16 | bitmapY | ||
) | [protected] |
Draws a bitmap in greyscale. The parameters must be pre-clipped by the drawBitmapGreyScale method.
x | The x co-ordinate to draw the bitmap to. |
y | The y co-ordinate to draw the bitmap to. |
width | The width of the bitmap to draw. |
height | The height of the bitmap to draw. |
bitmap | Pointer to the bitmap to draw. |
bitmapX | The x co-ordinate within the supplied bitmap to use as the origin. |
bitmapY | The y co-ordinate within the supplied bitmap to use as the origin. |
void Graphics::drawClippedLine | ( | s16 | x1, |
s16 | y1, | ||
s16 | x2, | ||
s16 | y2, | ||
u16 | colour | ||
) | [protected] |
Draws a line. The parameters must be pre-clipped by the drawLine() method.
x1 | The x co-ord of the start of the line. |
y1 | The y co-ord of the start of the line. |
x2 | The x co-ord of the end of the line. |
y2 | The y co-ord of the end of the line. |
colour | The colour of the line. |
void Graphics::drawEllipse | ( | s16 | xCentre, |
s16 | yCentre, | ||
s16 | horizRadius, | ||
s16 | vertRadius, | ||
u16 | colour | ||
) | [virtual] |
Draw an unfilled ellipse to the bitmap.
xCentre | The x co-ordinate of the ellipse's centre. |
yCentre | The y co-ordinate of the ellipse's centre. |
horizRadius | The size of the ellipse's horizontal radius. |
vertRadius | The size of the ellipse's vertical radius. |
colour | The colour of the ellipse. |
void Graphics::drawFilledCircle | ( | s16 | x0, |
s16 | y0, | ||
u16 | radius, | ||
u16 | colour | ||
) | [protected, virtual] |
Draw a filled circle to the internal bitmap. Faster than drawFilledEllipse() but limited to circles only.
x0 | The x co-ordinate of the circle. |
y0 | The y co-ordinate of the circle. |
radius | The radius of the circle. |
colour | The colour of the circle. |
void Graphics::drawFilledEllipse | ( | s16 | xCentre, |
s16 | yCentre, | ||
s16 | horizRadius, | ||
s16 | vertRadius, | ||
u16 | colour | ||
) | [virtual] |
Draw a filled ellipse to the bitmap.
xCentre | The x co-ordinate of the ellipse's centre. |
yCentre | The y co-ordinate of the ellipse's centre. |
horizRadius | The size of the ellipse's horizontal radius. |
vertRadius | The size of the ellipse's vertical radius. |
colour | The colour of the ellipse. |
void Graphics::drawFilledRect | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height, | ||
u16 | colour | ||
) | [virtual] |
Draw a filled rectangle to the internal bitmap.
x | The x co-ordinate of the rectangle. |
y | The y co-ordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
colour | The colour of the rectangle. |
void Graphics::drawFilledXORRect | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height | ||
) | [virtual] |
Invert the colour of a filled rectangle of pixels.
x | The x co-ordinate of the rectangle. |
y | The y co-ordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
void Graphics::drawFilledXORRect | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height, | ||
u16 | colour | ||
) | [virtual] |
XOR the colour of a filled rectangle of pixels against the supplied colour.
x | The x co-ordinate of the rectangle. |
y | The y co-ordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
colour | The colour to XOR against. |
void Graphics::drawHorizLine | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | colour | ||
) | [protected, virtual] |
Draw a horizontal line to the internal bitmap.
x | The x co-ordinate of the line. |
y | The y co-ordinate of the line. |
width | The width of the line. |
colour | The colour of the line. |
void Graphics::drawLine | ( | s16 | x1, |
s16 | y1, | ||
s16 | x2, | ||
s16 | y2, | ||
u16 | colour | ||
) | [virtual] |
Draw a line to the internal bitmap.
x1 | The x co-ordinate of the start point of the line. |
y1 | The y co-ordinate of the start point of the line. |
x2 | The x co-ordinate of the end point of the line. |
y2 | The y co-ordinate of the end point of the line. |
colour | The colour of the line. |
void Graphics::drawPixel | ( | s16 | x, |
s16 | y, | ||
u16 | colour | ||
) | [virtual] |
Draw a pixel to the internal bitmap.
x | The x co-ordinate of the pixel. |
y | The y co-ordinate of the pixel. |
colour | The colour of the pixel. |
void Graphics::drawRect | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height, | ||
u16 | colour | ||
) | [virtual] |
Draw an unfilled rectangle to the internal bitmap.
x | The x co-ordinate of the rectangle. |
y | The y co-ordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
colour | The colour of the rectangle. |
void Graphics::drawText | ( | s16 | x, |
s16 | y, | ||
FontBase * | font, | ||
const WoopsiString & | string | ||
) | [virtual] |
Draw a string to the internal bitmap.
x | The x co-ordinate of the string. |
y | The y co-ordinate of the string. |
font | The font to draw with. |
string | The string to output. |
void Graphics::drawText | ( | s16 | x, |
s16 | y, | ||
FontBase * | font, | ||
const WoopsiString & | string, | ||
s32 | startIndex, | ||
s32 | length, | ||
u16 | colour = 0 |
||
) | [virtual] |
Draw a particular length of a string to the bitmap in a specific colour.
x | The x co-ordinate of the string. |
y | The y co-ordinate of the string. |
font | The font to draw with. |
string | The string to output. |
startIndex | The start index within the string from which drawing will commence. |
length | The number of characters to draw. |
colour | The colour of the string. If this is not specified the font's default colour will be used. |
void Graphics::drawVertLine | ( | s16 | x, |
s16 | y, | ||
u16 | height, | ||
u16 | colour | ||
) | [protected, virtual] |
Draw a vertical line to the internal bitmap.
x | The x co-ordinate of the line. |
y | The y co-ordinate of the line. |
height | The height of the line. |
colour | The colour of the line. |
void Graphics::drawXORHorizLine | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | colour | ||
) | [virtual] |
XOR the colour of a horizontal line of pixels against the supplied colour.
x | The x co-ordinate of the line. |
y | The y co-ordinate of the line. |
width | The width of the line. |
colour | The colour to XOR against. |
void Graphics::drawXORHorizLine | ( | s16 | x, |
s16 | y, | ||
u16 | width | ||
) | [virtual] |
Invert the colour of a horizontal line of pixels.
x | The x co-ordinate of the line. |
y | The y co-ordinate of the line. |
width | The width of the line. |
void Graphics::drawXORPixel | ( | s16 | x, |
s16 | y | ||
) | [virtual] |
Invert the colour of the pixel at the specified co-ordinates.
x | The x co-ordinate of the pixel. |
y | The y co-ordinate of the pixel. |
void Graphics::drawXORPixel | ( | s16 | x, |
s16 | y, | ||
u16 | colour | ||
) | [virtual] |
XOR the colour of the pixel at the specified co-ordinates against the supplied colour.
x | The x co-ordinate of the pixel. |
y | The y co-ordinate of the pixel. |
colour | The colour to XOR against. |
void Graphics::drawXORRect | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height, | ||
u16 | colour | ||
) | [virtual] |
XOR the colour of an unfilled rectangle of pixels against the supplied colour.
x | The x co-ordinate of the rectangle. |
y | The y co-ordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
colour | The colour to XOR against. |
void Graphics::drawXORRect | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height | ||
) | [virtual] |
Invert the colour of an unfilled rectangle of pixels.
x | The x co-ordinate of the rectangle. |
y | The y co-ordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
void Graphics::drawXORVertLine | ( | s16 | x, |
s16 | y, | ||
u16 | height | ||
) | [virtual] |
Invert the colour of a vertical line of pixels.
x | The x co-ordinate of the line. |
y | The y co-ordinate of the line. |
height | The height of the line. |
void Graphics::drawXORVertLine | ( | s16 | x, |
s16 | y, | ||
u16 | height, | ||
u16 | colour | ||
) | [virtual] |
XOR the colour of a vertical line of pixels against the supplied colour.
x | The x co-ordinate of the line. |
y | The y co-ordinate of the line. |
height | The height of the line. |
colour | The colour to XOR against. |
void Graphics::floodFill | ( | s16 | x, |
s16 | y, | ||
u16 | newColour | ||
) | [virtual] |
Fill a region of the internal bitmap with the specified colour.
x | The x co-ordinate to use as the starting point of the fill. |
y | The y co-ordinate to use as the starting point of the fill. |
newColour | The colour to fill with. |
u8 Graphics::getClipLineOutCode | ( | s16 | x, |
s16 | y, | ||
s16 | xMin, | ||
s16 | yMin, | ||
s16 | xMax, | ||
s16 | yMax | ||
) | [protected] |
Get the clipping code for the given co-ordinates based on the given clipping region.
x | X co-ordinate to clip. |
y | Y co-ordinate to clip. |
xMin | Minimum x value. |
yMin | Minimum y value. |
xMax | Maximum x value. |
yMax | Maximum y value. |
void Graphics::getClipRect | ( | Rect & | rect | ) | const |
Get the current clipping region.
rect | A rect that will be populated with the current clipping region. |
const u16 Graphics::getPixel | ( | s16 | x, |
s16 | y | ||
) | const |
Get the colour of the pixel at the specified co-ordinates
x | The x co-ordinate of the pixel. |
y | The y co-ordinate of the pixel. |
void Graphics::greyScale | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height | ||
) |
Convert the region to greyscale.
x | X co-ord of the region to change. |
y | Y co-ord of the region to change. |
width | Width of the region to change. |
height | Height of the region to change. |
bool Graphics::popStack | ( | s16 * | x, |
s16 * | y, | ||
WoopsiArray< s32 > & | stack | ||
) | [protected] |
Remove the last item from the flood fill stack and insert its properties into the supplied x and y variables.
x | The x co-ordinate of the pixel from the stack (output by the function). |
y | The y co-ordinate of the pixel from the stack (output by the function). |
stack | The stack to pop from. |
void Graphics::pushStack | ( | s16 | x, |
s16 | y, | ||
WoopsiArray< s32 > & | stack | ||
) | [protected] |
Push new co-ordinates onto the stack.
x | The x co-ordinate of the pixel to add to the stack. |
y | The y co-ordinate of the pixel to add to the stack. |
stack | The stack to add a new value to. |
void Graphics::scroll | ( | s16 | x, |
s16 | y, | ||
s16 | xDistance, | ||
s16 | yDistance, | ||
u16 | width, | ||
u16 | height, | ||
WoopsiArray< Rect > * | revealedRects | ||
) | [virtual] |
Scroll a region by a specified distance in two dimensions. Performs a clipped copy to achieve scroll effect.
x | X co-ord of the area to scroll. |
y | Y co-ord of the area to scroll. |
xDistance | Horizontal distance to scroll. |
yDistance | Vertical distance to scroll. |
width | Width of the area to scroll. |
height | Height of the area to scroll. |
revealedRects | Populated with rects representing the region uncovered by the scroll method. This should be empty when passed, and the regions should be drawn to once the scroll has finished. |
void Graphics::setClipRect | ( | const Rect & | clipRect | ) |
Sets the clip rect. Attempts to draw outside of this region will be clipped out.
clipRect | The new clipping region. |
MutableBitmapBase* WoopsiGfx::Graphics::_bitmap [protected] |
Rect WoopsiGfx::Graphics::_clipRect [protected] |
Clipping rect that the object must draw within.
u16 WoopsiGfx::Graphics::_height [protected] |
Bitmap height
u16 WoopsiGfx::Graphics::_width [protected] |
Bitmap width