Woopsi 1.3
Nintendo DS Gui Framework
Public Member Functions | Protected Member Functions | Protected Attributes
WoopsiUI::Graphics Class Reference

#include <libwoopsi/include/graphics.h>

List of all members.

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

Detailed Description

Class providing bitmap manipulation (drawing, etc) functions. Functions are all clipped to the size of the bitmap being drawn to.


Constructor & Destructor Documentation

WoopsiUI::Graphics::Graphics ( MutableBitmapBase bitmap,
const Rect clipRect 
)

Constructor.

Parameters:
bitmapThe bitmap that the port will draw to.
clipRectThe clipping region within which the class must draw.
virtual WoopsiUI::Graphics::~Graphics ( ) [inline, virtual]

Destructor.

WoopsiUI::Graphics::Graphics ( const Graphics graphics) [inline, protected]

Copy constructor is protected to prevent usage.


Member Function Documentation

bool WoopsiUI::Graphics::clipBitmapCoordinates ( s16 *  x,
s16 *  y,
u16 *  width,
u16 *  height 
) [protected]

Clip the supplied rectangular dimensions to the size of the internal bitmap.

Parameters:
xThe x co-ordinate of the rectangle to clip (modified by the function).
yThe y co-ordinate of the rectangle to clip (modified by the function).
widthThe width of the rectangle to clip (modified by the function).
heightThe height of the rectangle to clip (modified by the function).
bool WoopsiUI::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.

Parameters:
x1The top-left x co-ordinate.
y1The top-left y co-ordinate.
x2The bottom-right x co-ordinate.
y2The bottom-right y co-ordinate.
clipRectA rect to clip to.
void WoopsiUI::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.

Parameters:
sourceXSource x co-ord.
sourceYSource y co-ord.
destXDestination x co-ord.
destYDestination y co-ord.
widthWidth of the rectangle to copy.
heightHeight of the rectangle to copy.
void WoopsiUI::Graphics::dim ( s16  x,
s16  y,
u16  width,
u16  height 
)

Halve the brightness of a specified region.

Parameters:
xX co-ord of the region to dim.
yY co-ord of the region to dim.
widthWidth of the region to dim.
heightHeight of the region to dim.
void WoopsiUI::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.

Parameters:
xThe x co-ordinate of the string.
yThe y co-ordinate of the string.
fontThe font to draw with.
stringThe string to output.
startIndexThe start index within the string from which drawing will commence.
lengthThe number of characters to draw.
colourThe colour of the string. If this is not specified the font's default colour will be used.
virtual void WoopsiUI::Graphics::drawBevelledRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  shineColour,
u16  shadowColour 
) [virtual]

Draw a bevelled rectangle to the bitmap.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
shineColourThe colour of the top/left sides.
shadowColourThe colour of the bottom/right sides.
virtual void WoopsiUI::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.

Parameters:
xThe x co-ordinate to draw the bitmap to.
yThe y co-ordinate to draw the bitmap to.
widthThe width of the bitmap to draw.
heightThe height of the bitmap to draw.
bitmapPointer to the bitmap to draw.
bitmapXThe x co-ordinate within the supplied bitmap to use as the origin.
bitmapYThe y co-ordinate within the supplied bitmap to use as the origin.
virtual void WoopsiUI::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.

Parameters:
xThe x co-ordinate to draw the bitmap to.
yThe y co-ordinate to draw the bitmap to.
widthThe width of the bitmap to draw.
heightThe height of the bitmap to draw.
bitmapPointer to the bitmap to draw.
bitmapXThe x co-ordinate within the supplied bitmap to use as the origin.
bitmapYThe y co-ordinate within the supplied bitmap to use as the origin.
transparentColourThe transparent colour used in the bitmap.
virtual void WoopsiUI::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.

Parameters:
xThe x co-ordinate to draw the bitmap to.
yThe y co-ordinate to draw the bitmap to.
widthThe width of the bitmap to draw.
heightThe height of the bitmap to draw.
bitmapPointer to the bitmap to draw.
bitmapXThe x co-ordinate within the supplied bitmap to use as the origin.
bitmapYThe y co-ordinate within the supplied bitmap to use as the origin.
virtual void WoopsiUI::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.

Parameters:
x0The x co-ordinate of the circle.
y0The y co-ordinate of the circle.
radiusThe radius of the circle.
colourThe colour of the circle.
void WoopsiUI::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.

Parameters:
xThe x co-ordinate to draw the bitmap to.
yThe y co-ordinate to draw the bitmap to.
widthThe width of the bitmap to draw.
heightThe height of the bitmap to draw.
bitmapPointer to the bitmap to draw.
bitmapXThe x co-ordinate within the supplied bitmap to use as the origin.
bitmapYThe y co-ordinate within the supplied bitmap to use as the origin.
void WoopsiUI::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.

Parameters:
x1The x co-ord of the start of the line.
y1The y co-ord of the start of the line.
x2The x co-ord of the end of the line.
y2The y co-ord of the end of the line.
colourThe colour of the line.
virtual void WoopsiUI::Graphics::drawEllipse ( s16  xCentre,
s16  yCentre,
s16  horizRadius,
s16  vertRadius,
u16  colour 
) [virtual]

Draw an unfilled ellipse to the bitmap.

Parameters:
xCentreThe x co-ordinate of the ellipse's centre.
yCentreThe y co-ordinate of the ellipse's centre.
horizRadiusThe size of the ellipse's horizontal radius.
vertRadiusThe size of the ellipse's vertical radius.
colourThe colour of the ellipse.
virtual void WoopsiUI::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.

Parameters:
x0The x co-ordinate of the circle.
y0The y co-ordinate of the circle.
radiusThe radius of the circle.
colourThe colour of the circle.
virtual void WoopsiUI::Graphics::drawFilledEllipse ( s16  xCentre,
s16  yCentre,
s16  horizRadius,
s16  vertRadius,
u16  colour 
) [virtual]

Draw a filled ellipse to the bitmap.

Parameters:
xCentreThe x co-ordinate of the ellipse's centre.
yCentreThe y co-ordinate of the ellipse's centre.
horizRadiusThe size of the ellipse's horizontal radius.
vertRadiusThe size of the ellipse's vertical radius.
colourThe colour of the ellipse.
virtual void WoopsiUI::Graphics::drawFilledRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  colour 
) [virtual]

Draw a filled rectangle to the internal bitmap.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
colourThe colour of the rectangle.
virtual void WoopsiUI::Graphics::drawFilledXORRect ( s16  x,
s16  y,
u16  width,
u16  height 
) [virtual]

Invert the colour of a filled rectangle of pixels.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
virtual void WoopsiUI::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.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
colourThe colour to XOR against.
virtual void WoopsiUI::Graphics::drawHorizLine ( s16  x,
s16  y,
u16  width,
u16  colour 
) [protected, virtual]

Draw a horizontal line to the internal bitmap.

Parameters:
xThe x co-ordinate of the line.
yThe y co-ordinate of the line.
widthThe width of the line.
colourThe colour of the line.
virtual void WoopsiUI::Graphics::drawLine ( s16  x1,
s16  y1,
s16  x2,
s16  y2,
u16  colour 
) [virtual]

Draw a line to the internal bitmap.

Parameters:
x1The x co-ordinate of the start point of the line.
y1The y co-ordinate of the start point of the line.
x2The x co-ordinate of the end point of the line.
y2The y co-ordinate of the end point of the line.
colourThe colour of the line.
virtual void WoopsiUI::Graphics::drawPixel ( s16  x,
s16  y,
u16  colour 
) [virtual]

Draw a pixel to the internal bitmap.

Parameters:
xThe x co-ordinate of the pixel.
yThe y co-ordinate of the pixel.
colourThe colour of the pixel.
virtual void WoopsiUI::Graphics::drawRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  colour 
) [virtual]

Draw an unfilled rectangle to the internal bitmap.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
colourThe colour of the rectangle.
virtual void WoopsiUI::Graphics::drawText ( s16  x,
s16  y,
FontBase font,
const WoopsiString string 
) [virtual]

Draw a string to the internal bitmap.

Parameters:
xThe x co-ordinate of the string.
yThe y co-ordinate of the string.
fontThe font to draw with.
stringThe string to output.
virtual void WoopsiUI::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.

Parameters:
xThe x co-ordinate of the string.
yThe y co-ordinate of the string.
fontThe font to draw with.
stringThe string to output.
startIndexThe start index within the string from which drawing will commence.
lengthThe number of characters to draw.
colourThe colour of the string. If this is not specified the font's default colour will be used.
virtual void WoopsiUI::Graphics::drawVertLine ( s16  x,
s16  y,
u16  height,
u16  colour 
) [protected, virtual]

Draw a vertical line to the internal bitmap.

Parameters:
xThe x co-ordinate of the line.
yThe y co-ordinate of the line.
heightThe height of the line.
colourThe colour of the line.
virtual void WoopsiUI::Graphics::drawXORHorizLine ( s16  x,
s16  y,
u16  width,
u16  colour 
) [virtual]

XOR the colour of a horizontal line of pixels against the supplied colour.

Parameters:
xThe x co-ordinate of the line.
yThe y co-ordinate of the line.
widthThe width of the line.
colourThe colour to XOR against.
virtual void WoopsiUI::Graphics::drawXORHorizLine ( s16  x,
s16  y,
u16  width 
) [virtual]

Invert the colour of a horizontal line of pixels.

Parameters:
xThe x co-ordinate of the line.
yThe y co-ordinate of the line.
widthThe width of the line.
virtual void WoopsiUI::Graphics::drawXORPixel ( s16  x,
s16  y 
) [virtual]

Invert the colour of the pixel at the specified co-ordinates.

Parameters:
xThe x co-ordinate of the pixel.
yThe y co-ordinate of the pixel.
virtual void WoopsiUI::Graphics::drawXORPixel ( s16  x,
s16  y,
u16  colour 
) [virtual]

XOR the colour of the pixel at the specified co-ordinates against the supplied colour.

Parameters:
xThe x co-ordinate of the pixel.
yThe y co-ordinate of the pixel.
colourThe colour to XOR against.
virtual void WoopsiUI::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.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
colourThe colour to XOR against.
virtual void WoopsiUI::Graphics::drawXORRect ( s16  x,
s16  y,
u16  width,
u16  height 
) [virtual]

Invert the colour of an unfilled rectangle of pixels.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
virtual void WoopsiUI::Graphics::drawXORVertLine ( s16  x,
s16  y,
u16  height 
) [virtual]

Invert the colour of a vertical line of pixels.

Parameters:
xThe x co-ordinate of the line.
yThe y co-ordinate of the line.
heightThe height of the line.
virtual void WoopsiUI::Graphics::drawXORVertLine ( s16  x,
s16  y,
u16  height,
u16  colour 
) [virtual]

XOR the colour of a vertical line of pixels against the supplied colour.

Parameters:
xThe x co-ordinate of the line.
yThe y co-ordinate of the line.
heightThe height of the line.
colourThe colour to XOR against.
virtual void WoopsiUI::Graphics::floodFill ( s16  x,
s16  y,
u16  newColour 
) [virtual]

Fill a region of the internal bitmap with the specified colour.

Parameters:
xThe x co-ordinate to use as the starting point of the fill.
yThe y co-ordinate to use as the starting point of the fill.
newColourThe colour to fill with.
u8 WoopsiUI::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.

Parameters:
xX co-ordinate to clip.
yY co-ordinate to clip.
xMinMinimum x value.
yMinMinimum y value.
xMaxMaximum x value.
yMaxMaximum y value.
void WoopsiUI::Graphics::getClipRect ( Rect rect) const

Get the current clipping region.

Parameters:
rectA rect that will be populated with the current clipping region.
const u16 WoopsiUI::Graphics::getPixel ( s16  x,
s16  y 
) const

Get the colour of the pixel at the specified co-ordinates

Parameters:
xThe x co-ordinate of the pixel.
yThe y co-ordinate of the pixel.
Returns:
The colour of the pixel.
void WoopsiUI::Graphics::greyScale ( s16  x,
s16  y,
u16  width,
u16  height 
)

Convert the region to greyscale.

Parameters:
xX co-ord of the region to change.
yY co-ord of the region to change.
widthWidth of the region to change.
heightHeight of the region to change.
bool WoopsiUI::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.

Parameters:
xThe x co-ordinate of the pixel from the stack (output by the function).
yThe y co-ordinate of the pixel from the stack (output by the function).
stackThe stack to pop from.
void WoopsiUI::Graphics::pushStack ( s16  x,
s16  y,
WoopsiArray< s32 > &  stack 
) [protected]

Push new co-ordinates onto the stack.

Parameters:
xThe x co-ordinate of the pixel to add to the stack.
yThe y co-ordinate of the pixel to add to the stack.
stackThe stack to add a new value to.
virtual void WoopsiUI::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.

Parameters:
xX co-ord of the area to scroll.
yY co-ord of the area to scroll.
xDistanceHorizontal distance to scroll.
yDistanceVertical distance to scroll.
widthWidth of the area to scroll.
heightHeight of the area to scroll.
revealedRectsPopulated 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 WoopsiUI::Graphics::setClipRect ( const Rect clipRect)

Sets the clip rect. Attempts to draw outside of this region will be clipped out.

Parameters:
clipRectThe new clipping region.

Member Data Documentation

Clipping rect that the object must draw within.

u16 WoopsiUI::Graphics::_height [protected]

Bitmap height

u16 WoopsiUI::Graphics::_width [protected]

Bitmap width


The documentation for this class was generated from the following file:
 All Classes Functions Variables Enumerations Enumerator