WHY_CPP  0.1
Classes | Functions

Functions to draw something on the screen. More...

Classes

struct  RGBA
 

Functions

i32 GetDisplayWidth (const Context &context)
 
i32 GetDisplayHeight (const Context &context)
 
void SetPixel (Context &context, i32 x, i32 y, const RGBA &color)
 
const RGBA GetPixel (const Context &context, i32 x, i32 y)
 
void DrawClearScreen (Context &context, const RGBA &color={0, 0, 0, 255})
 
void DrawLine (Context &context, i32 x0, i32 y0, i32 x1, i32 y1, const RGBA &color)
 
void DrawRectFill (Context &context, i32 x, i32 y, i32 w, i32 h, const RGBA &color)
 
void DrawRect (Context &context, i32 x, i32 y, i32 w, i32 h, const RGBA &color)
 
void DrawCircle (Context &context, i32 x, i32 y, i32 radius, const RGBA &color)
 
void DrawCircleFill (Context &context, i32 x, i32 y, i32 radius, const RGBA &color)
 
void DrawSprite (Context &context, i32 sprite_id, i32 screen_x, i32 screen_y, i32 sheet_x, i32 sheet_y, i32 width, i32 height)
 

Detailed Description

Functions to draw something on the screen.

Function Documentation

void DrawCircle ( Context context,
i32  x,
i32  y,
i32  radius,
const RGBA color 
)

Draw a circle border with the color. Circle body is transparent

Parameters
context
xcoordinate of the circle's center
ycoordinate of the circle's center
radius
color
See also
DrawCircleFill()

Definition at line 58 of file drawing.cpp.

References SetPixel().

void DrawCircleFill ( Context context,
i32  x,
i32  y,
i32  radius,
const RGBA color 
)

Draw a circle border with the color. Circle body is filled with the same color as the border.

Parameters
context
xcoordinate of the circle's center
ycoordinate of the circle's center
radius
color
See also
DrawCircle()

Definition at line 74 of file drawing.cpp.

References SetPixel().

void DrawClearScreen ( Context context,
const RGBA color = {0, 0, 0, 255} 
)

Fill the screen with a solid color

Parameters
context
colorto fill the screen

Definition at line 23 of file drawing.cpp.

void DrawLine ( Context context,
i32  x0,
i32  y0,
i32  x1,
i32  y1,
const RGBA color 
)

Draw line on the screen from the [x0,y0] to the [x1,y1] with a color.

Parameters
context
x0coordinate of the first point
y0coordinate of the first point
x1coordinate of the second point
y1coordinate of the second point
colorof the line

Definition at line 26 of file drawing.cpp.

References SetPixel().

Referenced by DrawRect(), and DrawRectFill().

void DrawRect ( Context context,
i32  x,
i32  y,
i32  w,
i32  h,
const RGBA color 
)

Draw a rectangle borders with the color. Rectangle body is transparent.

To draw it you need a left-upper corner coordinates [x,y] and rectangle width and height.

Parameters
context
xcoordinate of the left-upper corner
ycoordinate of the left-upper corner
wwidth of the rectangle to draw
hwidth of the rectangle to draw
colorof the borders and filler
See also
DrawRectFill()

Definition at line 51 of file drawing.cpp.

References DrawLine().

void DrawRectFill ( Context context,
i32  x,
i32  y,
i32  w,
i32  h,
const RGBA color 
)

Draw a rectangle and fill it with color. To draw it you need a left-upper corner coordinates [x,y] and rectangle width and height.

Parameters
context
xcoordinate of the left-upper corner
ycoordinate of the left-upper corner
wwidth of the rectangle to draw
hwidth of the rectangle to draw
colorof the borders and filler
See also
DrawRect()

Definition at line 46 of file drawing.cpp.

References DrawLine().

i32 GetDisplayHeight ( const Context context)
Parameters
context
Returns
display height in pixels

Definition at line 13 of file drawing.cpp.

i32 GetDisplayWidth ( const Context context)
Parameters
context
Returns
display width in pixels

Definition at line 10 of file drawing.cpp.

const RGBA GetPixel ( const Context context,
i32  x,
i32  y 
)

Get the pixel color at the [x,y] position

Parameters
contextof the application
xcoordinate of the pixel on the screen
ycoordinate of the pixel on the screen
Returns
color of the pixel

Definition at line 20 of file drawing.cpp.

void SetPixel ( Context context,
i32  x,
i32  y,
const RGBA color 
)

Set the pixel color at the [x,y] position

Parameters
contextof the application
xcoordinate of the pixel on the screen
ycoordinate of the pixel on the screen
colorof the pixel

Definition at line 16 of file drawing.cpp.

Referenced by DrawCircle(), DrawCircleFill(), DrawLine(), and Print().