VideoTools
|
A drawing surface that is embedded in a window. More...
#include <gxcanvas.h>
Public Types | |
enum | Stereo { left, right, normal } |
Public Member Functions | |
Canvas (GX::Window &, int dx=0, int dy=0, int colours=0, bool server_side=false) | |
Constructor. More... | |
~Canvas () | |
Destructor. | |
int | dx () const |
Returns the canvas width in pixels. | |
int | dy () const |
Returns the canvas height in pixels. | |
std::pair< unsigned int, unsigned int > | aspect () const |
Returns the canvas aspect ratio as a fraction (normally about 0.7). | |
int | colours () const |
Returns the number of colours, as passed in to the ctor. | |
Gr::Colour | colour (unsigned int n) const |
Returns a colour from the palette. More... | |
Gr::Colour | black () const |
Returns black. | |
Gr::Colour | white () const |
Returns white. | |
void | text (const std::string &s, int x, int y, Gr::Colour c) |
Draws a single-line text string at the given position. | |
void | point (int x, int y, Gr::Colour c) |
Draws a single pixel. | |
bool | fastable () const |
Returns true if fastpoint() can be used rather than point(). | |
void | fastpoint (int x, int y, Gr::Colour c) |
Draws a pixel quickly, assuming a client-side image and no stereo. More... | |
void | line (int x0, int y0, int x1, int y1, Gr::Colour c) |
Draws a line. | |
void | lineAcross (int y, int x_first, int x_last, const Gr::Colour &c) |
Draws a horizontal line. | |
void | lineDown (int x, int y_first, int y_last, const Gr::Colour &c) |
Draws a vertical line. | |
Gr::Colour | readPoint (int x, int y) const |
Reads a pixel. More... | |
void | clear (bool white=false) |
Clears the canvas to black (or white). | |
void | blit () |
Blits the canvas contents to the window. | |
void | stereo (Stereo mode=normal) |
Sets the left/right stereo mode for subsequent line() and point() drawing operations. More... | |
A drawing surface that is embedded in a window.
Supports server-side and client-side implementations chosen at run-time. Client-side uses a local image that is transferred to the X-server by the blit() method; server-side uses a pixmap that lives on the X-server and blit() is a copy performed within the X-server. Client-side should be preferred for efficient reading of pixels and/or for dense images; server-side might be better for sparse images.
Optionally uses a palette for ancient display hardware; either 16-value bios colours, or 256 greyscale shades. If using a palette then all colours passed to point(), line() etc. should be from colour().
The point (0,0) is in the bottom left hand corner and (dx()-1,dy()-1) is the top right.
A stereo mode can be set so that colours are modified to red or green, with (if client-side) yellow pixels on intersection.
Definition at line 61 of file gxcanvas.h.
|
explicit |
Constructor.
By default the size of the canvas is the size of the window. The colours parameter can be zero, 16 or 256.
Definition at line 36 of file gxcanvas.cpp.
Gr::Colour GX::Canvas::colour | ( | unsigned int | n | ) | const |
Returns a colour from the palette.
Precondition: n < colours
Definition at line 84 of file gxcanvas.cpp.
|
inline |
Draws a pixel quickly, assuming a client-side image and no stereo.
Precondition: fastable()
Definition at line 153 of file gxcanvas.h.
Gr::Colour GX::Canvas::readPoint | ( | int | x, |
int | y | ||
) | const |
Reads a pixel.
This method might be very slow and inefficient for a server-side canvas. If using a palette then the palette index will be in the red component.
Definition at line 205 of file gxcanvas.cpp.
void GX::Canvas::stereo | ( | Canvas::Stereo | mode = normal | ) |
Sets the left/right stereo mode for subsequent line() and point() drawing operations.
Definition at line 256 of file gxcanvas.cpp.