class
Graphics2DA class that can be used to draw things in the user interface.
It supports drawing basic shapes (rectangles, lines, triangles) as well as text and images. There are also some static methods that can help using more complex methods when drawing images, like tiling and slicing.
A Graphics2D object has a color, which is used when painting shapes and text (and it acts like a tint when painting images). Once the color is set, all subsequent operations will use that color, so it is not necessary to set it before every call.
A graphics context also supports clipping. All rendering operations modify only pixels which lie within the area bounded by the current clip. Clipping can be enabled/disabled and the area can be changed.
Public static variables
- static const int kAutoLength
-
static const char16_
t*const kDefaultFontName -
static const char16_
t*const kDefaultFont
Public static functions
-
static auto DrawTiledImage(Graphics2D* pGraphics,
const Math::
Rectangle& area, const Math:: Rectangle& texCoords, const Image* pImage, float fScaleX = 1.0f, float fScaleY = 1.0f, float fOffsetX = 0.0f, float fOffsetY = 1.0f) -> void - Draws the given image into the graphics context filling the area specified.
-
static auto DrawSlicedTiledImage(Graphics2D* pGraphics,
const Math::
Rectangle& area, const Math:: Rectangle& texCoords, const Image* pImage, const Math:: Rectangle& sliceProportions, float fScaleX = 1.0f, float fScaleY = 1.0f) -> void - Draws the given image into the graphics context filling the area specified.
-
static auto DrawSlicedStretchedImage(Graphics2D* pGraphics,
const Math::
Rectangle& area, const Math:: Rectangle& texCoords, const Image* pImage, const Math:: Rectangle& sliceProportions, float fScaleX = 1.0f, float fScaleY = 1.0f) -> void - Draws the given image into the graphics context filling the area specified.
Constructors, destructors, conversion operators
- ~Graphics2D() pure virtual
Public functions
-
auto SetColor(Math::
Color color) -> void pure virtual - Sets this graphics context current color to the color specified.
-
auto GetColor() -> Math::
Color pure virtual - Gets this Graphics2D current rendering color.
-
auto GetClipArea(Math::
Rectangle& dst) -> bool pure virtual - Gets the clip area currently used by this graphics context.
-
auto SetClipArea(bool bUseClipArea,
const Math::
Rectangle& area) -> void pure virtual - Sets the clip area or disables clipping.
-
auto IntersectClip(const Math::
Rectangle& area) -> void pure virtual - Intersects the current clip area with the specified rectangle and sets the clip area to the resulting intersection.
- auto DrawLine(float x1, float y1, float x2, float y2) -> void pure virtual
- Draws a 1-pixel thick line from the (x1, y1) coordinates to the (x2, y2) coordinates, using the graphics context current color.
- auto FillBorder(float left, float top, float right, float bottom, float thickness) -> void pure virtual
- Fills a border at the specified coordinates using the graphics context current color.
-
auto DrawStringArea(const Math::
Rectangle& area, const char16_ t* pString, int nLength = kAutoLength, const char16_ t* pFontName = kDefaultFontName, int = 0, int = 0, int = 0) -> void pure virtual - Draws the given eastl::string at the specified area.
-
auto DrawString(float x,
float y,
const char16_
t* pString, int length = kAutoLength, const char16_ t* pFontName = kDefaultFontName, void* = nullptr, int = 0) -> void pure virtual - Draws the given eastl::string at the specified position.
-
auto func28h(float,
float,
float,
float,
const char16_
t* str, int length, void*, void*, int) -> void pure virtual - auto func2Ch(void*) -> void pure virtual
-
auto func30h(const char16_
t*, int, int) -> void pure virtual - auto func34h(int, int, int) -> void pure virtual
- auto FillRectangle(float x1, float y1, float x2, float y2) -> void pure virtual
- Fills the specified rectangle using the current color.
-
auto FillQuad(Math::
Point& topRight, Math:: Point& topLeft, Math:: Point& bottomLeft, Math:: Point& bottomRight) -> void pure virtual - Fills the specified quadrilater using the current color.
-
auto FillGradientHorizontal(const Math::
Rectangle& area, Math:: Color colorLeft, Math:: Color colorRight) -> void pure virtual - Fills the specified rectangle using an horizontal color gradient.
-
auto FillGradientVertical(const Math::
Rectangle& area, Math:: Color colorTop, Math:: Color colorBottom) -> void pure virtual - Fills the specified rectangle using a vertical color gradient.
-
auto FillQuadGradient(const Math::
Point& topRight, Math:: Color topRightColor, const Math:: Point& topLeft, Math:: Color topLeftColor, const Math:: Point& bottomLeft, Math:: Color bottomLeftColor, const Math:: Point& bottomRight, Math:: Color bottomRightColor) -> void pure virtual - Fills the specified quadrilater using a gradient.
-
auto FillTriangleGradient(const Math::
Point& point1, Math:: Color color1, const Math:: Point& point2, Math:: Color color2, const Math:: Point& point3, Math:: Color color3) -> void pure virtual - Fills the specified triangle using a gradient.
-
auto func50h(size_
t nCount, int, const Image* pImage) -> void pure virtual -
auto func54h(size_
t nCount, int, const Image* pImage) -> void pure virtual -
auto DrawImageScaled(const Math::
Rectangle& area, const Image* pImage, const Math:: Rectangle& texCoords) -> void pure virtual - Draws the image provided, scaling it so it fills the entire area specified.
-
auto DrawImageWithTexCoords(float x,
float y,
const Image* pImage,
const Math::
Rectangle& texCoords) -> void pure virtual - Draws the image provided at the position specified.
- auto DrawImage(float x, float y, const Image* pImage) -> void pure virtual
- Draws the image provided at the position specified.
Function documentation
static void UTFWin:: Graphics2D:: DrawTiledImage(Graphics2D* pGraphics,
const Math:: Rectangle& area,
const Math:: Rectangle& texCoords,
const Image* pImage,
float fScaleX = 1.0f,
float fScaleY = 1.0f,
float fOffsetX = 0.0f,
float fOffsetY = 1.0f)
Draws the given image into the graphics context filling the area specified.
Parameters | |
---|---|
pGraphics | The Graphics2D context where the image will be drawn. |
area | The area of the graphics context to fill with the image. |
texCoords | The UV coordinates, in the [0, 1] range, that determines which portion of the image will be used. |
pImage | The image to draw. The width and height properties of the image will be used to repeat it. |
fScaleX | [Optional] The scale of the width of the image, 1.0f by default. |
fScaleY | [Optional] The scale of the height of the image, 1.0f by default. |
fOffsetX | [Optional] The X coordinate, relative to 'area', where the first tile will begin. |
fOffsetY | [Optional] The Y coordinate, relative to 'area', where the first tile will begin. |
The image will be tiled until the entire area specified is filled. Only the portion of the image determined by the 'texCoords' rectangle (in range [0, 1]) will be used. The scale and offset of the tiling can also be specified. The context's current color will act as a tint.
static void UTFWin:: Graphics2D:: DrawSlicedTiledImage(Graphics2D* pGraphics,
const Math:: Rectangle& area,
const Math:: Rectangle& texCoords,
const Image* pImage,
const Math:: Rectangle& sliceProportions,
float fScaleX = 1.0f,
float fScaleY = 1.0f)
Draws the given image into the graphics context filling the area specified.
Parameters | |
---|---|
pGraphics | The Graphics2D context where the image will be drawn. |
area | The area of the graphics context to fill with the image. |
texCoords | The UV coordinates, in the [0, 1] range, that determines which portion of the image will be used. |
pImage | The image to draw. The width and height properties of the image will be used to repeat it. |
sliceProportions | The UV coordinates, in the [0, 1] range, that determine where the center of the image is. The rest will be used as edges. |
fScaleX | [Optional] The scale of the width of the image, 1.0f by default. |
fScaleY | [Optional] The scale of the height of the image, 1.0f by default. |
The edges of the image will be rendered repeatedly until the width/height required (depending on the edge) is filled. The center of the area will be filled repeatedly rendering the center of the image. Only the portion of the image determined by the 'texCoords' rectangle (in range [0, 1]) will be used. The scale of the tiling can also be specified. The context's current color will act as a tint.
static void UTFWin:: Graphics2D:: DrawSlicedStretchedImage(Graphics2D* pGraphics,
const Math:: Rectangle& area,
const Math:: Rectangle& texCoords,
const Image* pImage,
const Math:: Rectangle& sliceProportions,
float fScaleX = 1.0f,
float fScaleY = 1.0f)
Draws the given image into the graphics context filling the area specified.
Parameters | |
---|---|
pGraphics | The Graphics2D context where the image will be drawn. |
area | The area of the graphics context to fill with the image. |
texCoords | The UV coordinates, in the [0, 1] range, that determines which portion of the image will be used. |
pImage | The image to draw. The width and height properties of the image will be used to repeat it. |
sliceProportions | The UV coordinates, in the [0, 1] range, that determine where the center of the image is. The rest will be used as edges. |
fScaleX | [Optional] The scale of the width of the image, 1.0f by default. |
fScaleY | [Optional] The scale of the height of the image, 1.0f by default. |
The edges of the image will be rendered stretching them until the width/height required (depending on the edge) is filled. The center of the area will be filled rendering the stretched image so it fills all the empty space. Only the portion of the image determined by the 'texCoords' rectangle (in range [0, 1]) will be used. The scale of the tiling can also be specified. The context's current color will act as a tint.
void UTFWin:: Graphics2D:: SetColor(Math:: Color color) pure virtual
Sets this graphics context current color to the color specified.
Parameters | |
---|---|
color | The new rendering color. |
All subsequent operations using this graphics context will use this color.
bool UTFWin:: Graphics2D:: GetClipArea(Math:: Rectangle& dst) pure virtual
Gets the clip area currently used by this graphics context.
Parameters | |
---|---|
dst out | The Rectangle where the clip will be output. |
Returns | Whether this context is using clipping or not. |
All rendering operations modify only pixels which lie within the area bounded by the current clip.
void UTFWin:: Graphics2D:: SetClipArea(bool bUseClipArea,
const Math:: Rectangle& area) pure virtual
Sets the clip area or disables clipping.
Parameters | |
---|---|
bUseClipArea | Whether to use clipping or not. |
area | The new clip area. |
All rendering operations modify only pixels which lie within the area bounded by the current clip
void UTFWin:: Graphics2D:: IntersectClip(const Math:: Rectangle& area) pure virtual
Intersects the current clip area with the specified rectangle and sets the clip area to the resulting intersection.
Parameters | |
---|---|
area | The rectangle to intersect the clip with. |
This method is used to make the clip area smaller; if 'area' is larger, the clip area will be set to 0. If this context doesn't use clipping, it will use it after calling this method with 'area' as the clip.
void UTFWin:: Graphics2D:: DrawLine(float x1,
float y1,
float x2,
float y2) pure virtual
Draws a 1-pixel thick line from the (x1, y1) coordinates to the (x2, y2) coordinates, using the graphics context current color.
Parameters | |
---|---|
x1 | The start point X coordinate. |
y1 | The start point Y coordinate. |
x2 | The end point X coordinate. |
y2 | The end point Y coordinate. |
void UTFWin:: Graphics2D:: FillBorder(float left,
float top,
float right,
float bottom,
float thickness) pure virtual
Fills a border at the specified coordinates using the graphics context current color.
Parameters | |
---|---|
left | The X coordinate where the left edge is. The painted region will be in the [left, left + thickness] range. |
top | The Y coordinate where the top edge is. The painted region will be in the [top, top + thickness] range. |
right | The X coordinate where the right edge is. The painted region will be in the [right, right - thickness] range. |
bottom | The Y coordinate where the bottom edge is. The painted region will be in the [bottom, bottom - thickness] range. |
thickness |
void UTFWin:: Graphics2D:: DrawStringArea(const Math:: Rectangle& area,
const char16_ t* pString,
int nLength = kAutoLength,
const char16_ t* pFontName = kDefaultFontName,
int = 0,
int = 0,
int = 0) pure virtual
Draws the given eastl::string at the specified area.
Parameters | |
---|---|
area | The rectangle where the top-left corner of the text begins. |
pString | The char16_t* eastl::string to draw. |
nLength | |
pFontName | [Optional] The name of the font that will be used to render this text, for example "Arial". |
The text will be drawn in the x1,y1 coordinates of the rectangle, the rest will be ignored.
void UTFWin:: Graphics2D:: DrawString(float x,
float y,
const char16_ t* pString,
int length = kAutoLength,
const char16_ t* pFontName = kDefaultFontName,
void* = nullptr,
int = 0) pure virtual
Draws the given eastl::string at the specified position.
Parameters | |
---|---|
x | The X coordinate where the top-left corner of the text begins. |
y | The Y coordinate where the top-left corner of the text begins. |
pString | The char16_t* eastl::string to draw. |
length | [Optional] The number of characters of the eastl::string to draw. Use Graphics2D:: |
pFontName | [Optional] The name of the font that will be used to render this text, for example "Arial". |
void UTFWin:: Graphics2D:: FillRectangle(float x1,
float y1,
float x2,
float y2) pure virtual
Fills the specified rectangle using the current color.
Parameters | |
---|---|
x1 | The top-left corner X coordinate. |
y1 | The top-left corner Y coordinate. |
x2 | The bottom-right corner X coordinate. |
y2 | The bottom-right corner Y coordinate. |
You must specify the top-left corner and the bottom-right corner that define the rectangle to be filled.
void UTFWin:: Graphics2D:: FillQuad(Math:: Point& topRight,
Math:: Point& topLeft,
Math:: Point& bottomLeft,
Math:: Point& bottomRight) pure virtual
Fills the specified quadrilater using the current color.
Parameters | |
---|---|
topRight | The coordinates of the top-right corner. |
topLeft | The coordinates of the top-left corner. |
bottomLeft | The coordinates of the bottom-left corner. |
bottomRight | The coordinates of the bottom-right corner. |
You must specify the four corners of the quadrilater.
void UTFWin:: Graphics2D:: FillGradientHorizontal(const Math:: Rectangle& area,
Math:: Color colorLeft,
Math:: Color colorRight) pure virtual
Fills the specified rectangle using an horizontal color gradient.
Parameters | |
---|---|
area | The area of the rectangle to fill. |
colorLeft | The color of the gradient beginning at the left edge of the rectangle. |
colorRight | The color of the gradient end at the right edge of the rectangle. |
The gradient will start with the 'colorLeft' color on the left edge, and will end with the 'colorRight' color on the right edge. The current graphics context color will be used as a tint, multiplying it with the colors specified.
void UTFWin:: Graphics2D:: FillGradientVertical(const Math:: Rectangle& area,
Math:: Color colorTop,
Math:: Color colorBottom) pure virtual
Fills the specified rectangle using a vertical color gradient.
Parameters | |
---|---|
area | The area of the rectangle to fill. |
colorTop | The color of the gradient beginning at the top edge of the rectangle. |
colorBottom | The color of the gradient end at the bottom edge of the rectangle. |
The gradient will start with the 'colorTop' color on the top edge, and will end with the 'colorBottom' color on the bottom edge. The current graphics context color will be used as a tint, multiplying it with the colors specified.
void UTFWin:: Graphics2D:: FillQuadGradient(const Math:: Point& topRight,
Math:: Color topRightColor,
const Math:: Point& topLeft,
Math:: Color topLeftColor,
const Math:: Point& bottomLeft,
Math:: Color bottomLeftColor,
const Math:: Point& bottomRight,
Math:: Color bottomRightColor) pure virtual
Fills the specified quadrilater using a gradient.
Parameters | |
---|---|
topRight | The coordinates of the top-right corner. |
topRightColor | The color to use on the top-right corner. |
topLeft | The coordinates of the top-left corner. |
topLeftColor | The color to use on the top-left corner. |
bottomLeft | The coordinates of the bottom-left corner. |
bottomLeftColor | The color to use on the bottom-left corner. |
bottomRight | The coordinates of the bottom-right corner. |
bottomRightColor | The color to use on the bottom-right corner. |
You must specify the four corners of the quadrilater, as well as the color used on each corner. The color of every pixel will be lineally-interpolated depending on its position.
void UTFWin:: Graphics2D:: FillTriangleGradient(const Math:: Point& point1,
Math:: Color color1,
const Math:: Point& point2,
Math:: Color color2,
const Math:: Point& point3,
Math:: Color color3) pure virtual
Fills the specified triangle using a gradient.
Parameters | |
---|---|
point1 | The coordinates of the first vertex. |
color1 | The color to use on the first vertex. |
point2 | The coordinates of the second vertex. |
color2 | The color to use on the second vertex. |
point3 | The coordinates of the third vertex. |
color3 | The color to use on the third vertex. |
You must specify the three points of the triangle, as well as the color used on each vertex. The color of every pixel will be lineally-interpolated depending on its position.
void UTFWin:: Graphics2D:: DrawImageScaled(const Math:: Rectangle& area,
const Image* pImage,
const Math:: Rectangle& texCoords) pure virtual
Draws the image provided, scaling it so it fills the entire area specified.
Parameters | |
---|---|
area | The area to fill with the image. |
pImage | The image to draw. |
texCoords | The UV coordinates, in the [0, 1] range, that determines which portion of the image will be used. |
Only the portion of the image determined by the 'texCoords' rectangle (in range [0, 1]) will be used.
void UTFWin:: Graphics2D:: DrawImageWithTexCoords(float x,
float y,
const Image* pImage,
const Math:: Rectangle& texCoords) pure virtual
Draws the image provided at the position specified.
Parameters | |
---|---|
x | The X coordinate where the top-left corner of the image will be drawn. |
y | The Y coordinate where the top-left corner of the image will be drawn. |
pImage | The image to draw. |
texCoords | The UV coordinates, in the [0, 1] range, that determines which portion of the image will be used. |
Only the portion of the image determined by the 'texCoords' rectangle (in range [0, 1]) will be used.
void UTFWin:: Graphics2D:: DrawImage(float x,
float y,
const Image* pImage) pure virtual
Draws the image provided at the position specified.
Parameters | |
---|---|
x | The X coordinate where the top-left corner of the image will be drawn. |
y | The Y coordinate where the top-left corner of the image will be drawn. |
pImage | The image to draw. |