SGL
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GDrawingSurface Class Referenceabstract

GDrawingSurface is an abstract superclass for types that allow drawing shapes and pixels onto themselves as a pixel background layer. More...

#include "gdrawingsurface.h"

Inheritance diagram for GDrawingSurface:
GCanvas

Public Member Functions

void clear()=0
 Erases any pixel data from the drawing surface. More...
 
void conditionalRepaint()
 Repaints the interactor only if its contents have changed. More...
 
void conditionalRepaintRegion(int x, int y, int width, int height)
 Repaints the given region of the interactor only if its contents have changed. More...
 
void conditionalRepaintRegion(const GRectangle &bounds)
 Repaints the given region of the interactor only if its contents have changed. More...
 
void draw(GObject *gobj)=0
 Draws the given graphical object onto the background pixel layer of this interactor. More...
 
void draw(GObject *gobj, double x, double y)
 Draws the given graphical object onto the background pixel layer of this interactor, moving it to the given x/y location first. More...
 
void draw(GObject &gobj)
 Draws the given graphical object onto the background pixel layer of this interactor. More...
 
void draw(GObject &gobj, double x, double y)
 Draws the given graphical object onto the background pixel layer of this interactor, moving it to the given x/y location first. More...
 
void drawArc(double x, double y, double width, double height, double start, double sweep)
 Draws an unfilled arc with the given attributes onto the background pixel layer of this interactor in the current color. More...
 
void drawImage(string filename, double x=0, double y=0)
 Draws an image loaded from the given file name onto the background pixel layer of this interactor at the given x/y location. More...
 
void drawLine(const GPoint &p0, const GPoint &p1)
 Draws a line between the given two points onto the background pixel layer of this interactor at the given x/y location in the current color. More...
 
void drawLine(double x0, double y0, double x1, double y1)
 Draws a line between the given two points onto the background pixel layer of this interactor at the given x/y location in the current color. More...
 
void drawOval(const GRectangle &bounds)
 Draws an unfilled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color. More...
 
void drawOval(double x, double y, double width, double height)
 Draws an unfilled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color. More...
 
void drawPixel(double x, double y)
 Colors the given x/y pixel of the background layer of this interactor using the interactor's current color. More...
 
void drawPixel(double x, double y, int color)
 Colors the given x/y pixel of the background layer of this interactor using the given color. More...
 
void drawPixel(double x, double y, string color)
 Colors the given x/y pixel of the background layer of this interactor using the given color. More...
 
GPoint drawPolarLine(const GPoint &p0, double r, double theta)
 Draws a line using polar coordinates onto the background pixel layer of this interactor in the current color. More...
 
GPoint drawPolarLine(double x0, double y0, double r, double theta)
 Draws a line using polar coordinates onto the background pixel layer of this interactor in the current color. More...
 
void drawPolygon(std::initializer_list< double > coords)
 Draws an unfilled polygon containing the given points onto the background pixel layer of this interactor in the current color. More...
 
void drawPolygon(std::initializer_list< GPoint > points)
 Draws an unfilled polygon containing the given points onto the background pixel layer of this interactor in the current color. More...
 
void drawRect(const GRectangle &bounds)
 Draws an unfilled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color. More...
 
void drawRect(double x, double y, double width, double height)
 Draws an unfilled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color. More...
 
void drawString(string text, double x, double y)
 Draws a text string onto the background pixel layer of this interactor at the given x/y location in the current font and color. More...
 
void fillArc(double x, double y, double width, double height, double start, double sweep)
 Draws a filled arc with the given attributes onto the background pixel layer of this interactor in the current color and fill color. More...
 
void fillOval(const GRectangle &bounds)
 Draws a filled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color and fill color. More...
 
void fillOval(double x, double y, double width, double height)
 Draws a filled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color and fill color. More...
 
void fillPolygon(std::initializer_list< double > coords)
 Draws a filled polygon containing the given points onto the background pixel layer of this interactor in the current color and fill color. More...
 
void fillPolygon(std::initializer_list< GPoint > coords)
 Draws a filled polygon containing the given points onto the background pixel layer of this interactor in the current color and fill color. More...
 
void fillRect(const GRectangle &bounds)
 Draws a filled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color and fill color. More...
 
void fillRect(double x, double y, double width, double height)
 Draws a filled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color and fill color. More...
 
int getARGB(double x, double y) const
 Returns the pixel color data at the given x/y location, retaining alpha-channel transparency in the top 8 bits. More...
 
string getBackground() const
 Returns the current background color of the interactor as a string. More...
 
int getBackgroundInt() const
 Returns the current background color of the interactor as an RGB integer. More...
 
string getColor() const
 Returns the current foreground outline color of the interactor as a string. More...
 
int getColorInt() const
 Returns the current foreground outline color of the interactor as an RGB integer. More...
 
string getFillColor() const
 Returns the current fill color of the interactor as a string. More...
 
int getFillColorInt() const
 Returns the current fill color of the interactor as an RGB integer. More...
 
string getFont() const
 Returns the current text font of the interactor as a font string. More...
 
string getForeground() const
 Returns the current foreground outline color of the interactor as a string. More...
 
int getForegroundInt() const
 Returns the current foreground outline color of the interactor as an RGB integer. More...
 
GObject::LineStyle getLineStyle() const
 Returns the current line style which will be used to draw outlines of shapes and lines. More...
 
double getLineWidth() const
 Returns the thickness used when drawing outlines of shapes and lines. More...
 
int getPixel(double x, double y) const =0
 Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as an integer such as 0xff00cc. More...
 
int getPixelARGB(double x, double y) const =0
 Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as an integer such as 0xffff00cc. More...
 
std::vector< std::vector< int > > getPixels() const =0
 Returns all pixels of the surface as a nested STL vector of vectors, where the first index represents the x value and the second index represents the y value. More...
 
std::vector< std::vector< int > > getPixelsARGB() const =0
 Returns all pixels of the background layer of the surface as a nested STL vector of vectors, where the first index represents the x value and the second index represents the y value. More...
 
int ** getPixelsArray() const =0
 Returns all pixels of the surface as a heap-allocated 2D array, where the first index represents the x value and the second index represents the y value. More...
 
int ** getPixelsArrayARGB() const =0
 Returns all pixels of the background layer of the surface as a heap-allocated 2D array, where the first index represents the x value and the second index represents the y value. More...
 
string getPixelString(double x, double y) const
 Returns the color of the pixel at the given x/y coordinates of the image as a string such as "#ff00cc". More...
 
int getRGB(double x, double y) const
 Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as an integer such as 0xff00cc. More...
 
string getRGBString(double x, double y) const
 Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as a color string such as "#ff00cc". More...
 
bool isAutoRepaint() const
 Returns true if the interactor should repaint itself automatically whenever any change is made to its graphical data. More...
 
bool isRepaintImmediately() const
 Returns true if the interactor should repaint itself automatically whenever any change is made to its graphical data. More...
 
void repaint()=0
 Instructs the interactor to redraw itself on the screen. More...
 
void repaintRegion(int x, int y, int width, int height)=0
 Instructs the interactor to repaint the given region of pixel data. More...
 
void repaintRegion(const GRectangle &bounds)
 Instructs the interactor to repaint the given region of pixel data. More...
 
void setAutoRepaint(bool autoRepaint)
 Sets whether the interactor should repaint itself automatically whenever any change is made to its graphical data. More...
 
void setBackground(int color)
 Sets the current background color of the interactor as an RGB integer. More...
 
void setBackground(string color)
 Sets the current background color of the interactor as a string. More...
 
void setColor(int color)
 Sets the current foreground outline color of the interactor as as RGB integer. More...
 
void setColor(string color)
 Sets the current foreground outline color of the interactor as a string. More...
 
void setFillColor(int color)
 Sets the current fill color of the interactor as an RGB integer. More...
 
void setFillColor(string color)
 Returns the current fill color of the interactor as a string. More...
 
void setFont(string font)
 Sets the current text font of the interactor as a font string. More...
 
void setForeground(int color)
 Sets the current foreground outline color of the interactor as an RGB integer. More...
 
void setForeground(string color)
 Sets the current foreground outline color of the interactor as a string. More...
 
void setLineStyle(GObject::LineStyle lineStyle)
 Sets the current line style which will be used to draw outlines of shapes and lines. More...
 
void setLineWidth(double lineWidth)
 Sets the thickness used when drawing outlines of shapes and lines. More...
 
void setPixel(double x, double y, int rgb)=0
 Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values. More...
 
void setPixel(double x, double y, int r, int g, int b)
 Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values. More...
 
void setPixel(double x, double y, string color)
 Sets the color of the given x/y pixel in the background layer of the interactor to the given color. More...
 
void setPixelARGB(double x, double y, int argb)=0
 Sets the color of the given x/y pixel in the background layer of the interactor to the given ARGB value. More...
 
void setPixelARGB(double x, double y, int a, int r, int g, int b)
 Sets the color of the given x/y pixel in the background layer of the interactor to the given ARGB value. More...
 
void setPixels(int **pixels, int width=-1, int height=-1)=0
 Sets the color of the all pixels in the background layer of the interactor to the given RGB values, where the first index represents the x-coordinate and the second index represents the y-coordinate. More...
 
void setPixels(const std::vector< std::vector< int >> &pixels)=0
 Sets the color of the all pixels in the background layer of the interactor to the given RGB values, where the first index represents the x-coordinate and the second index represents the y-coordinate. More...
 
void setPixelsARGB(int **pixelsARGB, int width=-1, int height=-1)=0
 Sets the color of the all pixels in the background layer of the interactor to the given ARGB values, where the first index represents the x-coordinate and the second index represents the y-coordinate. More...
 
void setPixelsARGB(const std::vector< std::vector< int >> &pixelsARGB)=0
 Sets the color of the all pixels in the background layer of the interactor to the given ARGB values, where the first index represents the x-coordinate and the second index represents the y-coordinate. More...
 
void setRepaintImmediately(bool autoRepaint)
 Sets whether the interactor should repaint itself automatically whenever any change is made to its graphical data. More...
 
void setRGB(double x, double y, int rgb)
 Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values. More...
 
void setRGB(double x, double y, int r, int g, int b)
 Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values. More...
 
void setRGB(double x, double y, string color)
 Sets the color of the given x/y pixel in the background layer of the interactor to the given color. More...
 

Protected Member Functions

 GDrawingSurface()
 
~GDrawingSurface()
 
void checkBounds(string member, double x, double y, double width, double height) const
 Throws an error if the given x/y values are out of bounds. More...
 
void checkColor(string member, int rgb) const
 Throws an error if the given rgb value is not a valid color. More...
 
void checkSize(string member, double width, double height) const
 Throws an error if the given width/height values are out of bounds. More...
 
void initializeGObject(GObject &obj, bool filled=false)
 Initializes a new graphical object to be drawn. More...
 
void initializeGObject(GObject *obj, bool filled=false)
 Initializes a new graphical object to be drawn. More...
 

Protected Attributes

bool _autoRepaint
 
string _backgroundColor
 
int _backgroundColorInt
 
string _color
 
int _colorInt
 
string _fillColor
 
int _fillColorInt
 
string _font
 
GDrawingSurface_forwardTarget
 
GObject::LineStyle _lineStyle
 
double _lineWidth
 

Detailed Description

GDrawingSurface is an abstract superclass for types that allow drawing shapes and pixels onto themselves as a pixel background layer.

This includes graphical canvas objects (GCanvas) as well as windows (GWindow).

Constructor & Destructor Documentation

◆ GDrawingSurface()

GDrawingSurface ( )
protected

◆ ~GDrawingSurface()

~GDrawingSurface ( )
protectedvirtual

Member Function Documentation

◆ checkBounds()

void checkBounds ( string   member,
double  x,
double  y,
double  width,
double  height 
) const
protected

Throws an error if the given x/y values are out of bounds.

◆ checkColor()

void checkColor ( string   member,
int  rgb 
) const
protected

Throws an error if the given rgb value is not a valid color.

◆ checkSize()

void checkSize ( string   member,
double  width,
double  height 
) const
protected

Throws an error if the given width/height values are out of bounds.

◆ clear()

virtual void clear ( )
pure virtual

Erases any pixel data from the drawing surface.

Implemented in GWindow, and GCanvas.

◆ conditionalRepaint()

void conditionalRepaint ( )
virtual

Repaints the interactor only if its contents have changed.

◆ conditionalRepaintRegion() [1/2]

void conditionalRepaintRegion ( int  x,
int  y,
int  width,
int  height 
)
virtual

Repaints the given region of the interactor only if its contents have changed.

◆ conditionalRepaintRegion() [2/2]

void conditionalRepaintRegion ( const GRectangle bounds)
virtual

Repaints the given region of the interactor only if its contents have changed.

◆ draw() [1/4]

virtual void draw ( GObject gobj)
pure virtual

Draws the given graphical object onto the background pixel layer of this interactor.

Exceptions
ErrorExceptionif the object is null

Implemented in GCanvas.

◆ draw() [2/4]

void draw ( GObject gobj,
double  x,
double  y 
)
virtual

Draws the given graphical object onto the background pixel layer of this interactor, moving it to the given x/y location first.

Exceptions
ErrorExceptionif the object is null

◆ draw() [3/4]

void draw ( GObject gobj)
virtual

Draws the given graphical object onto the background pixel layer of this interactor.

◆ draw() [4/4]

void draw ( GObject gobj,
double  x,
double  y 
)
virtual

Draws the given graphical object onto the background pixel layer of this interactor, moving it to the given x/y location first.

◆ drawArc()

void drawArc ( double  x,
double  y,
double  width,
double  height,
double  start,
double  sweep 
)
virtual

Draws an unfilled arc with the given attributes onto the background pixel layer of this interactor in the current color.

See gobjects.h for explanation of GArc parameters.

◆ drawImage()

void drawImage ( string   filename,
double  x = 0,
double  y = 0 
)
virtual

Draws an image loaded from the given file name onto the background pixel layer of this interactor at the given x/y location.

See gobjects.h for explanation of GImage parameters.

Exceptions
ErrorExceptionif the given file is not found or cannot be loaded as a valid image file

◆ drawLine() [1/2]

void drawLine ( const GPoint p0,
const GPoint p1 
)
virtual

Draws a line between the given two points onto the background pixel layer of this interactor at the given x/y location in the current color.

See gobjects.h for explanation of GLine parameters.

◆ drawLine() [2/2]

void drawLine ( double  x0,
double  y0,
double  x1,
double  y1 
)
virtual

Draws a line between the given two points onto the background pixel layer of this interactor at the given x/y location in the current color.

See gobjects.h for explanation of GLine parameters.

◆ drawOval() [1/2]

void drawOval ( const GRectangle bounds)
virtual

Draws an unfilled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color.

See gobjects.h for explanation of GOval parameters.

◆ drawOval() [2/2]

void drawOval ( double  x,
double  y,
double  width,
double  height 
)
virtual

Draws an unfilled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color.

See gobjects.h for explanation of GOval parameters.

◆ drawPixel() [1/3]

void drawPixel ( double  x,
double  y 
)
virtual

Colors the given x/y pixel of the background layer of this interactor using the interactor's current color.

◆ drawPixel() [2/3]

void drawPixel ( double  x,
double  y,
int  color 
)
virtual

Colors the given x/y pixel of the background layer of this interactor using the given color.

◆ drawPixel() [3/3]

void drawPixel ( double  x,
double  y,
string   color 
)
virtual

Colors the given x/y pixel of the background layer of this interactor using the given color.

◆ drawPolarLine() [1/2]

GPoint drawPolarLine ( const GPoint p0,
double  r,
double  theta 
)
virtual

Draws a line using polar coordinates onto the background pixel layer of this interactor in the current color.

The line begins at the given x/y point and extends from there by the given angle and radius. Returns the end point opposite p0 where the line ends. See gobjects.h for explanation of GLine parameters.

◆ drawPolarLine() [2/2]

GPoint drawPolarLine ( double  x0,
double  y0,
double  r,
double  theta 
)
virtual

Draws a line using polar coordinates onto the background pixel layer of this interactor in the current color.

The line begins at the given x/y point and extends from there by the given angle and radius. Returns the end point where the line ends. See gobjects.h for explanation of GLine parameters.

◆ drawPolygon() [1/2]

void drawPolygon ( std::initializer_list< double >  coords)
virtual

Draws an unfilled polygon containing the given points onto the background pixel layer of this interactor in the current color.

See gobjects.h for explanation of GPolygon parameters.

◆ drawPolygon() [2/2]

void drawPolygon ( std::initializer_list< GPoint points)
virtual

Draws an unfilled polygon containing the given points onto the background pixel layer of this interactor in the current color.

See gobjects.h for explanation of GPolygon parameters.

◆ drawRect() [1/2]

void drawRect ( const GRectangle bounds)
virtual

Draws an unfilled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color.

See gobjects.h for explanation of GRect parameters.

◆ drawRect() [2/2]

void drawRect ( double  x,
double  y,
double  width,
double  height 
)
virtual

Draws an unfilled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color.

See gobjects.h for explanation of GRect parameters.

◆ drawString()

void drawString ( string   text,
double  x,
double  y 
)
virtual

Draws a text string onto the background pixel layer of this interactor at the given x/y location in the current font and color.

See gobjects.h for explanation of GText parameters.

◆ fillArc()

void fillArc ( double  x,
double  y,
double  width,
double  height,
double  start,
double  sweep 
)
virtual

Draws a filled arc with the given attributes onto the background pixel layer of this interactor in the current color and fill color.

See gobjects.h for explanation of GArc parameters.

◆ fillOval() [1/2]

void fillOval ( const GRectangle bounds)
virtual

Draws a filled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color and fill color.

See gobjects.h for explanation of GOval parameters.

◆ fillOval() [2/2]

void fillOval ( double  x,
double  y,
double  width,
double  height 
)
virtual

Draws a filled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color and fill color.

See gobjects.h for explanation of GOval parameters.

◆ fillPolygon() [1/2]

void fillPolygon ( std::initializer_list< double >  coords)
virtual

Draws a filled polygon containing the given points onto the background pixel layer of this interactor in the current color and fill color.

See gobjects.h for explanation of GPolygon parameters.

◆ fillPolygon() [2/2]

void fillPolygon ( std::initializer_list< GPoint coords)
virtual

Draws a filled polygon containing the given points onto the background pixel layer of this interactor in the current color and fill color.

See gobjects.h for explanation of GPolygon parameters.

◆ fillRect() [1/2]

void fillRect ( const GRectangle bounds)
virtual

Draws a filled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color and fill color.

See gobjects.h for explanation of GRect parameters.

◆ fillRect() [2/2]

void fillRect ( double  x,
double  y,
double  width,
double  height 
)
virtual

Draws a filled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color and fill color.

See gobjects.h for explanation of GRect parameters.

◆ getARGB()

int getARGB ( double  x,
double  y 
) const
virtual

Returns the pixel color data at the given x/y location, retaining alpha-channel transparency in the top 8 bits.

◆ getBackground()

string getBackground ( ) const
virtual

Returns the current background color of the interactor as a string.

See gcolor.h for more detail about color strings.

Reimplemented in GCanvas.

◆ getBackgroundInt()

int getBackgroundInt ( ) const
virtual

Returns the current background color of the interactor as an RGB integer.

See gcolor.h for more detail about colors.

Reimplemented in GCanvas.

◆ getColor()

string getColor ( ) const
virtual

Returns the current foreground outline color of the interactor as a string.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about color strings. Equivalent to getForeground.

◆ getColorInt()

int getColorInt ( ) const
virtual

Returns the current foreground outline color of the interactor as an RGB integer.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about colors. Equivalent to getForegroundInt.

◆ getFillColor()

string getFillColor ( ) const
virtual

Returns the current fill color of the interactor as a string.

This color will appear in shapes drawn using the fillXxx methods. See gcolor.h for more detail about color strings.

◆ getFillColorInt()

int getFillColorInt ( ) const
virtual

Returns the current fill color of the interactor as an RGB integer.

This color will appear in shapes drawn using the fillXxx methods. See gcolor.h for more detail about color strings.

◆ getFont()

string getFont ( ) const
virtual

Returns the current text font of the interactor as a font string.

This font will be used when drawing text strings using drawString. See gfont.h for more detail about font strings.

Reimplemented in GCanvas.

◆ getForeground()

string getForeground ( ) const
virtual

Returns the current foreground outline color of the interactor as a string.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about color strings. Equivalent to getColor.

◆ getForegroundInt()

int getForegroundInt ( ) const
virtual

Returns the current foreground outline color of the interactor as an RGB integer.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about colors. Equivalent to getColor.

◆ getLineStyle()

GObject::LineStyle getLineStyle ( ) const
virtual

Returns the current line style which will be used to draw outlines of shapes and lines.

The default line style is a solid line (GObject::LINE_SOLID).

◆ getLineWidth()

double getLineWidth ( ) const
virtual

Returns the thickness used when drawing outlines of shapes and lines.

The default thickness is 1.

◆ getPixel()

virtual int getPixel ( double  x,
double  y 
) const
pure virtual

Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as an integer such as 0xff00cc.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a Grid, then manipulate all desired pixels in that Grid, then call setPixels to submit all of your changes.

Equivalent to getRGB.

Exceptions
ErrorExceptionif the given x/y values are out of bounds.

Implemented in GCanvas.

◆ getPixelARGB()

virtual int getPixelARGB ( double  x,
double  y 
) const
pure virtual

Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as an integer such as 0xffff00cc.

This differs from getPixel in that it explicitly retains and returns the alpha channel of the pixel in the top 8 bits, allowing for transparency effects.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a Grid, then manipulate all desired pixels in that Grid, then call setPixels to submit all of your changes.

Exceptions
ErrorExceptionif the given x/y values are out of bounds.

Implemented in GCanvas.

◆ getPixels()

virtual std::vector<std::vector<int> > getPixels ( ) const
pure virtual

Returns all pixels of the surface as a nested STL vector of vectors, where the first index represents the x value and the second index represents the y value.

Implemented in GCanvas.

◆ getPixelsARGB()

virtual std::vector<std::vector<int> > getPixelsARGB ( ) const
pure virtual

Returns all pixels of the background layer of the surface as a nested STL vector of vectors, where the first index represents the x value and the second index represents the y value.

This differs from getPixels in that it explicitly retains and returns the alpha channel of each pixel in the top 8 bits, allowing for transparency effects.

Implemented in GCanvas.

◆ getPixelsArray()

virtual int** getPixelsArray ( ) const
pure virtual

Returns all pixels of the surface as a heap-allocated 2D array, where the first index represents the x value and the second index represents the y value.

The caller is responsible for freeing the memory for this array using delete[].

Implemented in GCanvas.

◆ getPixelsArrayARGB()

virtual int** getPixelsArrayARGB ( ) const
pure virtual

Returns all pixels of the background layer of the surface as a heap-allocated 2D array, where the first index represents the x value and the second index represents the y value.

This differs from getPixelsArray in that it explicitly retains and returns the alpha channel of each pixel in the top 8 bits, allowing for transparency effects. The caller is responsible for freeing the memory for this array using delete[].

Implemented in GCanvas.

◆ getPixelString()

string getPixelString ( double  x,
double  y 
) const
virtual

Returns the color of the pixel at the given x/y coordinates of the image as a string such as "#ff00cc".

The string that is returned comes from the GWindow function convertRGBToColor; see documentation of that function. Throws an error if the given x/y values are out of bounds.

◆ getRGB()

int getRGB ( double  x,
double  y 
) const
virtual

Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as an integer such as 0xff00cc.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a Grid, then manipulate all desired pixels in that Grid, then call setPixels to submit all of your changes.

Equivalent to getPixel.

Exceptions
ErrorExceptionif the given x/y values are out of bounds.

◆ getRGBString()

string getRGBString ( double  x,
double  y 
) const
virtual

Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as a color string such as "#ff00cc".

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a Grid, then manipulate all desired pixels in that Grid, then call setPixels to submit all of your changes.

Exceptions
ErrorExceptionif the given x/y values are out of bounds.

◆ initializeGObject() [1/2]

void initializeGObject ( GObject obj,
bool  filled = false 
)
protectedvirtual

Initializes a new graphical object to be drawn.

Used as a convenience method to set the color, fill color, outline style, font, and other settings of graphical objects based on the settings of the drawing surface.

◆ initializeGObject() [2/2]

void initializeGObject ( GObject obj,
bool  filled = false 
)
protectedvirtual

Initializes a new graphical object to be drawn.

Used as a convenience method to set the color, fill color, outline style, font, and other settings of graphical objects based on the settings of the drawing surface.

◆ isAutoRepaint()

bool isAutoRepaint ( ) const
virtual

Returns true if the interactor should repaint itself automatically whenever any change is made to its graphical data.

But if you call setAutoRepaint(false), you must manually repaint the interactor to see any changes. This can be desirable if you plan to make a large batch of changes and want to repaint only after all of them are done. Equivalent to isRepaintImmediately.

Reimplemented in GCanvas.

◆ isRepaintImmediately()

bool isRepaintImmediately ( ) const
virtual

Returns true if the interactor should repaint itself automatically whenever any change is made to its graphical data.

But if you call setAutoRepaint(false), you must manually repaint the interactor to see any changes. This can be desirable if you plan to make a large batch of changes and want to repaint only after all of them are done. Equivalent to isAutoRepaint.

Reimplemented in GWindow.

◆ repaint()

virtual void repaint ( )
pure virtual

Instructs the interactor to redraw itself on the screen.

By default the interactor will automatically repaint itself whenever you make any change to its graphical data. But if you call setAutoRepaint(false), you must manually repaint the interactor to see any changes. This can be desirable if you plan to make a large batch of changes and want to repaint only after all of them are done.

Implemented in GCanvas.

◆ repaintRegion() [1/2]

virtual void repaintRegion ( int  x,
int  y,
int  width,
int  height 
)
pure virtual

Instructs the interactor to repaint the given region of pixel data.

This can be preferable to repaint() for performance purposes if you have made a small change that affects only the given rectangular region of the interactor.

Implemented in GCanvas.

◆ repaintRegion() [2/2]

void repaintRegion ( const GRectangle bounds)
virtual

Instructs the interactor to repaint the given region of pixel data.

This can be preferable to repaint() for performance purposes if you have made a small change that affects only the given rectangular region of the interactor.

◆ setAutoRepaint()

void setAutoRepaint ( bool  autoRepaint)
virtual

Sets whether the interactor should repaint itself automatically whenever any change is made to its graphical data.

By default this is true. But if you call setAutoRepaint(false), you must manually repaint the interactor to see any changes. This can be desirable if you plan to make a large batch of changes and want to repaint only after all of them are done. Equivalent to setRepaintImmediately.

Reimplemented in GCanvas.

◆ setBackground() [1/2]

void setBackground ( int  color)
virtual

Sets the current background color of the interactor as an RGB integer.

See gcolor.h for more detail about colors.

Reimplemented in GWindow, and GCanvas.

◆ setBackground() [2/2]

void setBackground ( string   color)
virtual

Sets the current background color of the interactor as a string.

See gcolor.h for more detail about color strings.

Reimplemented in GWindow, and GCanvas.

◆ setColor() [1/2]

void setColor ( int  color)
virtual

Sets the current foreground outline color of the interactor as as RGB integer.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about color strings. Equivalent to setForeground.

Reimplemented in GCanvas.

◆ setColor() [2/2]

void setColor ( string   color)
virtual

Sets the current foreground outline color of the interactor as a string.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about color strings. Equivalent to setForeground.

Reimplemented in GCanvas.

◆ setFillColor() [1/2]

void setFillColor ( int  color)
virtual

Sets the current fill color of the interactor as an RGB integer.

This color will appear in shapes drawn using the fillXxx methods. See gcolor.h for more detail about color strings.

◆ setFillColor() [2/2]

void setFillColor ( string   color)
virtual

Returns the current fill color of the interactor as a string.

This color will appear in shapes drawn using the fillXxx methods. See gcolor.h for more detail about color strings.

◆ setFont()

void setFont ( string   font)
virtual

Sets the current text font of the interactor as a font string.

This font will be used when drawing text strings using drawString. See gfont.h for more detail about font strings.

Reimplemented in GCanvas.

◆ setForeground() [1/2]

void setForeground ( int  color)
virtual

Sets the current foreground outline color of the interactor as an RGB integer.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about color strings. Equivalent to setColor.

Reimplemented in GCanvas.

◆ setForeground() [2/2]

void setForeground ( string   color)
virtual

Sets the current foreground outline color of the interactor as a string.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about color strings. Equivalent to setColor.

Reimplemented in GCanvas.

◆ setLineStyle()

void setLineStyle ( GObject::LineStyle  lineStyle)
virtual

Sets the current line style which will be used to draw outlines of shapes and lines.

The default line style is a solid line (GObject::LINE_SOLID).

◆ setLineWidth()

void setLineWidth ( double  lineWidth)
virtual

Sets the thickness used when drawing outlines of shapes and lines.

The default thickness is 1.

◆ setPixel() [1/3]

virtual void setPixel ( double  x,
double  y,
int  rgb 
)
pure virtual

Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a nested vector, then manipulate all desired pixels in that vector, then call setPixels to submit all of your changes. Equivalent to setRGB.

Exceptions
ErrorExceptionif x/y is out of range or rgb is an invalid color

Implemented in GCanvas.

◆ setPixel() [2/3]

void setPixel ( double  x,
double  y,
int  r,
int  g,
int  b 
)
virtual

Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a nested vector, then manipulate all desired pixels in that vector, then call setPixels to submit all of your changes. Equivalent to setRGB.

Exceptions
ErrorExceptionif x/y is out of range or r,g,b are not between 0-255

Reimplemented in GCanvas.

◆ setPixel() [3/3]

void setPixel ( double  x,
double  y,
string   color 
)
virtual

Sets the color of the given x/y pixel in the background layer of the interactor to the given color.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a nested vector, then manipulate all desired pixels in that vector, then call setPixels to submit all of your changes. Equivalent to setRGB.

Exceptions
ErrorExceptionif x/y is out of range

◆ setPixelARGB() [1/2]

virtual void setPixelARGB ( double  x,
double  y,
int  argb 
)
pure virtual

Sets the color of the given x/y pixel in the background layer of the interactor to the given ARGB value.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixelsARGB to extract all pixels into a nested vector, then manipulate all desired pixels in that vector, then call setPixelsARGB to submit all of your changes.

Exceptions
ErrorExceptionif x/y is out of range or argb is an invalid color

Implemented in GCanvas.

◆ setPixelARGB() [2/2]

void setPixelARGB ( double  x,
double  y,
int  a,
int  r,
int  g,
int  b 
)
virtual

Sets the color of the given x/y pixel in the background layer of the interactor to the given ARGB value.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixelsARGB to extract all pixels into a nested vector, then manipulate all desired pixels in that vector, then call setPixelsARGB to submit all of your changes.

Exceptions
ErrorExceptionif x/y is out of range or a,r,g,b are not between 0-255

Reimplemented in GCanvas.

◆ setPixels() [1/2]

virtual void setPixels ( int **  pixels,
int  width = -1,
int  height = -1 
)
pure virtual

Sets the color of the all pixels in the background layer of the interactor to the given RGB values, where the first index represents the x-coordinate and the second index represents the y-coordinate.

Any existing background layer pixels will be replaced. If the given array is not the same size as this interactor, the interactor will be resized to match the array.

Implemented in GCanvas.

◆ setPixels() [2/2]

virtual void setPixels ( const std::vector< std::vector< int >> &  pixels)
pure virtual

Sets the color of the all pixels in the background layer of the interactor to the given RGB values, where the first index represents the x-coordinate and the second index represents the y-coordinate.

Any existing background layer pixels will be replaced. If the given vector is not the same size as this interactor, the interactor will be resized to match the vector.

Implemented in GCanvas.

◆ setPixelsARGB() [1/2]

virtual void setPixelsARGB ( int **  pixelsARGB,
int  width = -1,
int  height = -1 
)
pure virtual

Sets the color of the all pixels in the background layer of the interactor to the given ARGB values, where the first index represents the x-coordinate and the second index represents the y-coordinate.

Any existing background layer pixels will be replaced. If the given array is not the same size as this interactor, the interactor will be resized to match the array.

Implemented in GCanvas.

◆ setPixelsARGB() [2/2]

virtual void setPixelsARGB ( const std::vector< std::vector< int >> &  pixelsARGB)
pure virtual

Sets the color of the all pixels in the background layer of the interactor to the given ARGB values, where the first index represents the x-coordinate and the second index represents the y-coordinate.

Any existing background layer pixels will be replaced. If the given vector is not the same size as this interactor, the interactor will be resized to match the vector.

Implemented in GCanvas.

◆ setRepaintImmediately()

void setRepaintImmediately ( bool  autoRepaint)
virtual

Sets whether the interactor should repaint itself automatically whenever any change is made to its graphical data.

By default this is true. But if you call setAutoRepaint(false), you must manually repaint the interactor to see any changes. This can be desirable if you plan to make a large batch of changes and want to repaint only after all of them are done. Equivalent to setAutoRepaint.

◆ setRGB() [1/3]

void setRGB ( double  x,
double  y,
int  rgb 
)
virtual

Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a vector, then manipulate all desired pixels in that vector, then call setPixels to submit all of your changes. Equivalent to setPixel.

Exceptions
ErrorExceptionif x/y is out of range or rgb is an invalid color

◆ setRGB() [2/3]

void setRGB ( double  x,
double  y,
int  r,
int  g,
int  b 
)
virtual

Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a vector, then manipulate all desired pixels in that vector, then call setPixels to submit all of your changes. Equivalent to setPixel.

Exceptions
ErrorExceptionif x/y is out of range or r,g,b are not between 0-255

◆ setRGB() [3/3]

void setRGB ( double  x,
double  y,
string   color 
)
virtual

Sets the color of the given x/y pixel in the background layer of the interactor to the given color.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a vector, then manipulate all desired pixels in that vector, then call setPixels to submit all of your changes. Equivalent to setPixel.

Exceptions
ErrorExceptionif x/y is out of range

Member Data Documentation

◆ _autoRepaint

bool _autoRepaint
protected

◆ _backgroundColor

string _backgroundColor
protected

◆ _backgroundColorInt

int _backgroundColorInt
protected

◆ _color

string _color
protected

◆ _colorInt

int _colorInt
protected

◆ _fillColor

string _fillColor
protected

◆ _fillColorInt

int _fillColorInt
protected

◆ _font

string _font
protected

◆ _forwardTarget

GDrawingSurface* _forwardTarget
protected

◆ _lineStyle

GObject::LineStyle _lineStyle
protected

◆ _lineWidth

double _lineWidth
protected