Josh's Graphics Library
JGL::J2D Namespace Reference

Drawing functions for primitive 2D Shapes. More...

Functions

void Begin (RenderTarget *render_target=nullptr, bool clear_buffers=false)
 Open a 2-D rendering context with the underlying graphics system (In this case& by default OpenGL). More...
 
void End ()
 Closes a 2-D rendering context with the underlying graphics system (In this case& by default OpenGL). More...
 
void LightArray (Light *, size_t size)
 Provide a list of lights to be used in 2D space. More...
 
void LightArray (std::vector< Light > lights)
 
void DrawPoint (const Color4 &color, const Vector2 &coordinates, float radius=1.f)
 Plots a single pixel on the screen. More...
 
void DrawPoint (const Color4 &color, float x, float y, float radius=1.f)
 
void DrawPoints (const Color4 &color, const Vector2 *points, int num_points, float radius=1.f)
 Plots a series of pixel-points on the screen, in a batch. More...
 
void DrawLine (const Color4 &color, const Vector2 &A, const Vector2 &B, float thickness=1)
 Plots a line (segment) on the screen. More...
 
void DrawLine (const Color4 &color, float x1, float y1, float x2, float y2, float thickness=1)
 
void DrawGradientLine (const Color4 &color_a, const Color4 &color_b, const Vector2 &A, const Vector2 &B, float thickness=1)
 Draws a line with a color gradient that transitions across it. More...
 
void DrawGradientLine (const Color4 &color_a, const Color4 &color_b, float x, float y, float w, float h, float thickness=1)
 
void OutlineRect (const Color4 &color, const Vector2 &pos, const Vector2 &size, float thickness=1)
 Draws an outline of a rectangle on the screen. More...
 
void OutlineRoundedRect (const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius=5, float thickness=1)
 Draws an outline of a rectangle with rounded corners onto the screen. More...
 
void OutlineChamferRect (const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius=5, float thickness=1)
 Draws an outline of a rectangle with chamfered corners onto the screen. More...
 
void FillRect (const Color4 &color, const Vector2 &pos, const Vector2 &size)
 Draws a filled rectangle on the screen. More...
 
void FillGradientRect (const Color4 &color1, const Color4 &color2, const Direction &gradient, const Vector2 &pos, const Vector2 &size)
 Draws a filled rectangle where the color transitions across it. More...
 
void FillRoundedRect (const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius=5, unsigned int subdivisions=8)
 Draws a filled rectangle with rounded corners on the screen. More...
 
void FillChamferRect (const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius=5)
 Draws a filled rectangle with chamfered (beveled) corners on the screen. More...
 
void DrawRenderTarget (const RenderTarget &render_target, const Vector2 &position, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
 Draws a render-target (runtime-modifiable texture) to the screen. More...
 
void DrawRenderTarget (const RenderTarget *render_target, const Vector2 &position, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
 
void DrawSprite (const RenderTarget &render_target, const Vector2 &position, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
 Draws a sprite (technically, actually a render target) to the screen. More...
 
void DrawSprite (const RenderTarget *render_target, const Vector2 &position, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
 
void DrawSprite (const Texture &texture, const Vector2 &position, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
 Draws a sprite to the screen by passing a G̶L̶u̶i̶n̶t̶ JGL Texture that represents a handle to a loaded texture. More...
 
void DrawSprite (const Texture *texture, const Vector2 &position, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
 
void DrawSprite (const Texture &texture, float positionX, float positionY, float rad_rotation=0, float originX=0, float originY=0, float scaleX=1, float scaleY=1, const Color4 &color=Colors::White, Direction inversion=Direction::None)
 
void DrawSprite (const Texture *texture, float positionX, float positionY, float rad_rotation=0, float originX=0, float originY=0, float scaleX=1, float scaleY=1, const Color4 &color=Colors::White, Direction inversion=Direction::None)
 
void DrawPartialSprite (const Texture &texture, const Vector2 &position, const Vector2 &sub_texture_position, const Vector2 &sub_texture_size, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
 Draws a piece of a sprite to the screen, similar to DrawSprite. More...
 
void DrawPartialSprite (const Texture *texture, const Vector2 &position, const Vector2 &sub_texture_position, const Vector2 &sub_texture_size, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
 
void DrawPartialSprite (const Texture &texture, float positionX, float positionY, float sub_texture_positionX, float sub_texture_positionY, unsigned int sub_texture_sizeX, unsigned int sub_texture_sizeY, float rad_rotation=0, float originX=0, float originY=0, float scaleX=1, float scaleY=1, const Color4 &color=Colors::White, Direction inversion=Direction::None)
 
void DrawPartialSprite (const Texture *texture, float positionX, float positionY, float sub_texture_positionX, float sub_texture_positionY, unsigned int sub_texture_sizeX, unsigned int sub_texture_sizeY, float rad_rotation=0, float originX=0, float originY=0, float scaleX=1, float scaleY=1, const Color4 &color=Colors::White, Direction inversion=Direction::None)
 
void DrawMirrorSprite (const Texture &texture, const Vector2 &position, Direction mirror_axis=Direction::Horizontal|Direction::Vertical, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White)
 To save v-ram, Use if a sprite would be identical if mirrored horizontally, vertically, or both. More...
 
void DrawMirrorSprite (const Texture *texture, const Vector2 &position, Direction mirror_axis=Direction::Horizontal|Direction::Vertical, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White)
 
void OutlineCircle (const Color4 &color, const Vector2 &center, float radius, unsigned int subdivisions=16, float thickness=1)
 Draws an outline of a circle on the screen. More...
 
void FillCircle (const Color4 &color, const Vector2 &center, float radius, unsigned int subdivisions=8)
 Draws a filled circle on the screen. More...
 
void OutlineTriangle (const Color4 &color, const Triangle2D &tri, float thickness=1)
 Draws an outline of a triangle on the screen. More...
 
void OutlineTriangle (const Color4 &color, const Vector2 &triA, const Vector2 &triB, const Vector2 &triC, float thickness=1)
 
void FillTriangle (const Color4 &color, const Triangle2D &tri)
 Draws a filled triangle on the screen. More...
 
void FIllTriangle (const Color4 &color, const Vector2 &triA, const Vector2 &triB, const Vector2 &triC)
 
void FillGradientTriangle (const Color4 &a_color, const Color4 &b_color, const Color4 &c_color, const Triangle2D &tri)
 Fills a triangle defined by the provided vertices with a gradient that transitions smoothly between the three specified colors at each corner. More...
 
void FillGradientTriangle (const Color4 &a_color, const Color4 &b_color, const Color4 &c_color, const Vector2 &tri_a, const Vector2 &tri_b, const Vector2 &tri_c)
 
void DrawCubicBezierCurve (const Color4 &color, const Vector2 &controlA, const Vector2 &pointA, const Vector2 &pointB, const Vector2 &controlB, int subdivisions=10, float thickness=1)
 Draws a smooth, curved line segment between two control points, with the curve controlled by the two inner points. More...
 
void OutlinePolygon (const Color4 &color, const Vector2 *points, int points_size, float thickness=1)
 Draws a series of points where the last point always connects to the first point. More...
 
void DrawString (const Color4 &color, const std::string &text, float x, float y, float scale, u32 size, const Font &font)
 Draws a text string on the screen with a given point-size and font. More...
 
void DrawArc (const Color4 &color, const Vector2 &center, float radius, float arc_begin, float arc_end, unsigned int subdivisions, float thickness)
 Draws an Arc (section of a circle) to the screen. More...
 
void FillPolygon (const Color4 &color, const std::vector< Vector2 > &points)
 TODO Implement the following. These ones are going to be extremely annoying. More...
 
void OutlineEllipse (const Color4 &color, const Vector2 &position, float radius_x, float radius_y, float thickness=1, int subdivisions=8)
 
void FillEllipse (const Color4 &color, const Vector2 &position, float radius_x, float radius_y, int subdivisions=8)
 

Detailed Description

Drawing functions for primitive 2D Shapes.

Function Documentation

◆ Begin()

void JGL::J2D::Begin ( RenderTarget render_target = nullptr,
bool  clear_buffers = false 
)

Open a 2-D rendering context with the underlying graphics system (In this case& by default OpenGL).

Note
This call may not strictly be necessary on some setups, but is provided to keep the API constant. It is recommended to always open a JGL 2D context to render your content, then close when completed. This keeps our code from, say, clobbering the OpenGL rendering context driving 3D content in between our calls.
Parameters
render_target
clear_buffers
Here is the call graph for this function:

◆ DrawArc()

void JGL::J2D::DrawArc ( const Color4 &  color,
const Vector2 &  center,
float  radius,
float  arc_begin,
float  arc_end,
unsigned int  subdivisions,
float  thickness 
)

Draws an Arc (section of a circle) to the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
centerThe point in cartesian space at which to draw the arc. This will by-definition be the centroid of this partial circle.
radiusThe radius of the partial circle to be drawn. AKA Half the diameter.
arc_beginThe point (0 - 2pi) around a unit-circle of which to start the arc.
arc_endThe point (0 - 2pi) around a unit-circle of which to start the arc.
subdivisionsThe accuracy of the approximation of the circle, measured in iteration steps taken.
thicknessThe line-width to draw the arc with.
Here is the caller graph for this function:

◆ DrawCubicBezierCurve()

void JGL::J2D::DrawCubicBezierCurve ( const Color4 &  color,
const Vector2 &  controlA,
const Vector2 &  pointA,
const Vector2 &  pointB,
const Vector2 &  controlB,
int  subdivisions = 10,
float  thickness = 1 
)

Draws a smooth, curved line segment between two control points, with the curve controlled by the two inner points.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
controlAThe first control point, which can be considered the start of the line.
pointAThe first inner point, which controls the contour of the curve.
pointBThe second inner point, which controls the contour of the curve.
controlBThe second control point, which can be considered the end of the line.
subdivisionsThe accuracy of the approximation of the curve, measured in iteration steps taken.
thicknessThe line-width to draw the curve with.
See also
J3ML::Algorithm::Bezier
Here is the call graph for this function:

◆ DrawGradientLine() [1/2]

void JGL::J2D::DrawGradientLine ( const Color4 &  color_a,
const Color4 &  color_b,
const Vector2 &  A,
const Vector2 &  B,
float  thickness = 1 
)

Draws a line with a color gradient that transitions across it.

Parameters
color_aA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
color_bA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
AThe starting point of the line segment.
BThe end point of the line segment.
thicknessThe width at which to render the line.
Here is the caller graph for this function:

◆ DrawGradientLine() [2/2]

void JGL::J2D::DrawGradientLine ( const Color4 &  color_a,
const Color4 &  color_b,
float  x,
float  y,
float  w,
float  h,
float  thickness = 1 
)
Here is the call graph for this function:

◆ DrawLine() [1/2]

void JGL::J2D::DrawLine ( const Color4 &  color,
const Vector2 &  A,
const Vector2 &  B,
float  thickness = 1 
)

Plots a line (segment) on the screen.

Parameters
colorA 3-or-4 channel color value.
See also
classes Color3, Color4.
Parameters
AThe starting point of the line segment.
BThe end point of the line segment.
thicknessThe width at which to render the line.
Here is the caller graph for this function:

◆ DrawLine() [2/2]

void JGL::J2D::DrawLine ( const Color4 &  color,
float  x1,
float  y1,
float  x2,
float  y2,
float  thickness = 1 
)
Here is the call graph for this function:

◆ DrawMirrorSprite() [1/2]

void JGL::J2D::DrawMirrorSprite ( const Texture texture,
const Vector2 &  position,
Direction  mirror_axis = Direction::Horizontal | Direction::Vertical,
float  rad_rotation = 0,
const Vector2 &  origin = Vector2(0,0),
const Vector2 &  scale = Vector2(1,1),
const Color4 &  color = Colors::White 
)

To save v-ram, Use if a sprite would be identical if mirrored horizontally, vertically, or both.

For example, a circle. Assumes the input texture is the top left quadrant. You can use "SoftwareTexture" to invert it correctly so that's the case.

Parameters
textureA texture instance to be displayed.
positionThe point at which to draw the sprite (from the top-left down).
mirror_axisThe axes to mirror across, Vertical and Horizontal or both only.
rad_rotationThe rotation of the final result.
originThe point at which transformations are done about.
scaleThe scale transformation for the image. X and Y axis are independently-scalable.
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawMirrorSprite() [2/2]

void JGL::J2D::DrawMirrorSprite ( const Texture texture,
const Vector2 &  position,
Direction  mirror_axis = Direction::Horizontal | Direction::Vertical,
float  rad_rotation = 0,
const Vector2 &  origin = Vector2(0,0),
const Vector2 &  scale = Vector2(1,1),
const Color4 &  color = Colors::White 
)
Here is the call graph for this function:

◆ DrawPartialSprite() [1/4]

void JGL::J2D::DrawPartialSprite ( const Texture texture,
const Vector2 &  position,
const Vector2 &  sub_texture_position,
const Vector2 &  sub_texture_size,
float  rad_rotation = 0,
const Vector2 &  origin = Vector2(0,0),
const Vector2 &  scale = Vector2(1, 1),
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)

Draws a piece of a sprite to the screen, similar to DrawSprite.

Parameters
textureA texture instance to be displayed.
positionThe point at which to draw the sprite (from the top-left down).
sub_texture_positionThe top left corner of the sub-texture to be drawn.
sub_texture_sizeThe size of the sub-texture in px.
originThe center point around which the image should have all transformations applied to it.
scaleThe scale transformation for the image. X and Y axis are independently-scalable.
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
inversion
See also
Direction
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawPartialSprite() [2/4]

void JGL::J2D::DrawPartialSprite ( const Texture texture,
float  positionX,
float  positionY,
float  sub_texture_positionX,
float  sub_texture_positionY,
unsigned int  sub_texture_sizeX,
unsigned int  sub_texture_sizeY,
float  rad_rotation = 0,
float  originX = 0,
float  originY = 0,
float  scaleX = 1,
float  scaleY = 1,
const Color4 &  color = Colors::White,
JGL::Direction  inversion = Direction::None 
)
Here is the call graph for this function:

◆ DrawPartialSprite() [3/4]

void JGL::J2D::DrawPartialSprite ( const Texture texture,
const Vector2 &  position,
const Vector2 &  sub_texture_position,
const Vector2 &  sub_texture_size,
float  rad_rotation = 0,
const Vector2 &  origin = Vector2(0,0),
const Vector2 &  scale = Vector2(1, 1),
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)
Here is the call graph for this function:

◆ DrawPartialSprite() [4/4]

void JGL::J2D::DrawPartialSprite ( const Texture texture,
float  positionX,
float  positionY,
float  sub_texture_positionX,
float  sub_texture_positionY,
unsigned int  sub_texture_sizeX,
unsigned int  sub_texture_sizeY,
float  rad_rotation = 0,
float  originX = 0,
float  originY = 0,
float  scaleX = 1,
float  scaleY = 1,
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)
Here is the call graph for this function:

◆ DrawPoint() [1/2]

void JGL::J2D::DrawPoint ( const Color4 &  color,
const Vector2 &  coordinates,
float  radius = 1.f 
)

Plots a single pixel on the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
coordinatesThe pixel-point on-screen at which to plot the pixel.
radiusThe size of the point to plot. By default, a single pixel.
Here is the caller graph for this function:

◆ DrawPoint() [2/2]

void JGL::J2D::DrawPoint ( const Color4 &  color,
float  x,
float  y,
float  radius = 1.f 
)
Here is the call graph for this function:

◆ DrawPoints()

void JGL::J2D::DrawPoints ( const Color4 &  color,
const Vector2 *  points,
int  num_points,
float  radius = 1.f 
)

Plots a series of pixel-points on the screen, in a batch.

Note
This is more performant for multiple points than plotting them individually.
Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
pointsA set of x,y points to render.
radiusThe size of the point to plot. By default, a single pixel.

◆ DrawRenderTarget() [1/2]

void JGL::J2D::DrawRenderTarget ( const RenderTarget render_target,
const Vector2 &  position,
float  rad_rotation = 0,
const Vector2 &  origin = Vector2(0 , 0),
const Vector2 &  scale = Vector2(1, 1),
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)

Draws a render-target (runtime-modifiable texture) to the screen.

Parameters
render_targetA RenderTarget instance to be displayed.
positionThe position at which to render this object from it's center-point, defined by the origin parameter.
rad_rotationThe amount of radians to rotate this render-target about it's center-point.
originThe center-point in the image to use for rendering, rotation, and scaling. Top-left is {0,0} and bottom right is {1, 1}.
scaleThe amount (in both x, and y axis) to scale the image, with {1,1} being default scaling.
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
inversion
See also
Direction
Here is the call graph for this function:

◆ DrawRenderTarget() [2/2]

void JGL::J2D::DrawRenderTarget ( const RenderTarget render_target,
const Vector2 &  position,
float  rad_rotation = 0,
const Vector2 &  origin = Vector2(0 , 0),
const Vector2 &  scale = Vector2(1, 1),
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)
Here is the call graph for this function:

◆ DrawSprite() [1/6]

void JGL::J2D::DrawSprite ( const RenderTarget render_target,
const Vector2 &  position,
float  rad_rotation = 0,
const Vector2 &  origin = Vector2(0 , 0),
const Vector2 &  scale = Vector2(1, 1),
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)

Draws a sprite (technically, actually a render target) to the screen.

Note
This similar overload exists because we expect someone will be an idiot and turn all of their sprites into RenderTargets. ~william
Parameters
render_targetA RenderTarget instance to be displayed.
positionThe position at which to render this object from it's center-point, defined by the origin parameter.
rad_rotationThe amount of radians to rotate this render-target about it's center-point.
originThe center-point in the image to use for rendering, rotation, and scaling. Top-left is {0,0} and bottom right is {1, 1}.
scaleThe amount (in both x, and y axis) to scale the image, with {1,1} being default scaling.
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
inversion
See also
Direction
DrawSprite
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawSprite() [2/6]

void JGL::J2D::DrawSprite ( const RenderTarget render_target,
const Vector2 &  position,
float  rad_rotation = 0,
const Vector2 &  origin = Vector2(0 , 0),
const Vector2 &  scale = Vector2(1, 1),
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)
Here is the call graph for this function:

◆ DrawSprite() [3/6]

void JGL::J2D::DrawSprite ( const Texture texture,
const Vector2 &  position,
float  rad_rotation = 0,
const Vector2 &  origin = Vector2(0,0),
const Vector2 &  scale = Vector2(1,1),
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)

Draws a sprite to the screen by passing a G̶L̶u̶i̶n̶t̶ JGL Texture that represents a handle to a loaded texture.

Parameters
textureA texture instance to be displayed.
positionThe point at which to draw the sprite (from the top-left down).
originThe center point around which the image should have all transformations applied to it.
scaleThe scale transformation for the image. X and Y axis are independently-scalable.
rad_rotationA float representing the rotation of the sprite where 0 is no rotation and 1 is the maximum rotation (would look the same as 0).
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
inversion
See also
Direction
class Texture
Here is the call graph for this function:

◆ DrawSprite() [4/6]

void JGL::J2D::DrawSprite ( const Texture texture,
float  positionX,
float  positionY,
float  rad_rotation = 0,
float  originX = 0,
float  originY = 0,
float  scaleX = 1,
float  scaleY = 1,
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)
Here is the call graph for this function:

◆ DrawSprite() [5/6]

void JGL::J2D::DrawSprite ( const Texture texture,
const Vector2 &  position,
float  rad_rotation = 0,
const Vector2 &  origin = Vector2(0,0),
const Vector2 &  scale = Vector2(1,1),
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)
Here is the call graph for this function:

◆ DrawSprite() [6/6]

void JGL::J2D::DrawSprite ( const Texture texture,
float  positionX,
float  positionY,
float  rad_rotation = 0,
float  originX = 0,
float  originY = 0,
float  scaleX = 1,
float  scaleY = 1,
const Color4 &  color = Colors::White,
Direction  inversion = Direction::None 
)
Here is the call graph for this function:

◆ DrawString()

void JGL::J2D::DrawString ( const Color4 &  color,
const std::string &  text,
float  x,
float  y,
float  scale,
u32  size,
const Font font 
)

Draws a text string on the screen with a given point-size and font.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
textThe text to be rendered.
xThe position on the screen at which to draw the text, from the top-left.
yThe position on the screen at which to draw the text, from the top-left.
scaleThe value (in both axes) to scale the text by. Defaults to {1,1}.
sizeThe point-size at which to render the font out. Re-using the same point-size allows efficient glyph caching.
fontThe font to use for rendering.
See also
Font.
Here is the call graph for this function:

◆ End()

void JGL::J2D::End ( )

Closes a 2-D rendering context with the underlying graphics system (In this case& by default OpenGL).

See also
Begin().
Here is the call graph for this function:

◆ FillChamferRect()

void JGL::J2D::FillChamferRect ( const Color4 &  color,
const Vector2 &  pos,
const Vector2 &  size,
float  radius = 5 
)

Draws a filled rectangle with chamfered (beveled) corners on the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
posThe top-left corner of the rectangle.
sizeThe width and height of the rectangle.
radiusThe corner-rounding radius (in radians).
Here is the call graph for this function:

◆ FillCircle()

void JGL::J2D::FillCircle ( const Color4 &  color,
const Vector2 &  center,
float  radius,
unsigned int  subdivisions = 8 
)

Draws a filled circle on the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
centerThe point in cartesian space at which to draw the circle. This will by-definition be the centroid of this circle.
radiusThe radius of the circle to be drawn. AKA Half the diameter.
subdivisionsThe accuracy of the approximation of the circle, measured in iteration steps taken.
Here is the caller graph for this function:

◆ FillEllipse()

void JGL::J2D::FillEllipse ( const Color4 &  color,
const Vector2 &  position,
float  radius_x,
float  radius_y,
int  subdivisions = 8 
)

◆ FillGradientRect()

void JGL::J2D::FillGradientRect ( const Color4 &  color1,
const Color4 &  color2,
const Direction gradient,
const Vector2 &  pos,
const Vector2 &  size 
)

Draws a filled rectangle where the color transitions across it.

Parameters
color1A 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
color2A 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
gradientSee enum Direction
posThe top-left corner of the rectangle.
sizeThe width and height of the rectangle.

◆ FillGradientTriangle() [1/2]

void JGL::J2D::FillGradientTriangle ( const Color4 &  a_color,
const Color4 &  b_color,
const Color4 &  c_color,
const Triangle2D &  tri 
)

Fills a triangle defined by the provided vertices with a gradient that transitions smoothly between the three specified colors at each corner.

Parameters
a_colorThe color at vertex A of the triangle.
b_colorThe color at vertex B of the triangle.
c_colorThe color at vertex C of the triangle.
triThe triangle defined by its vertices (A, B, and C).
Here is the caller graph for this function:

◆ FillGradientTriangle() [2/2]

void JGL::J2D::FillGradientTriangle ( const Color4 &  a_color,
const Color4 &  b_color,
const Color4 &  c_color,
const Vector2 &  tri_a,
const Vector2 &  tri_b,
const Vector2 &  tri_c 
)
Here is the call graph for this function:

◆ FillPolygon()

void JGL::J2D::FillPolygon ( const Color4 &  color,
const std::vector< Vector2 > &  points 
)

TODO Implement the following. These ones are going to be extremely annoying.

◆ FillRect()

void JGL::J2D::FillRect ( const Color4 &  color,
const Vector2 &  pos,
const Vector2 &  size 
)

Draws a filled rectangle on the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
posThe top-left corner of the rectangle.
sizeThe width and height of the rectangle.
See also
FillRoundedRect, FillGradientRect, FillChamferRect.
Here is the caller graph for this function:

◆ FillRoundedRect()

void JGL::J2D::FillRoundedRect ( const Color4 &  color,
const Vector2 &  pos,
const Vector2 &  size,
float  radius = 5,
unsigned int  subdivisions = 8 
)

Draws a filled rectangle with rounded corners on the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
posThe top-left corner of the rectangle.
sizeThe width and height of the rectangle.
radiusThe corner-rounding radius (in radians).
subdivisionsThe amount of sub-divisions (and calculations) to be performed per-arc rounding corner.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FillTriangle()

void JGL::J2D::FillTriangle ( const Color4 &  color,
const Triangle2D &  tri 
)

Draws a filled triangle on the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
triThe triangle defined by its vertices (A, B, and C).
Here is the caller graph for this function:

◆ FIllTriangle()

void JGL::J2D::FIllTriangle ( const Color4 &  color,
const Vector2 &  triA,
const Vector2 &  triB,
const Vector2 &  triC 
)
Here is the call graph for this function:

◆ LightArray() [1/2]

void JGL::J2D::LightArray ( Light ,
size_t  size 
)

Provide a list of lights to be used in 2D space.

Typically directly after J2D::Begin(); 8 lights maximum for now. Some kind of light sorting will eventually be needed per j2d element.

◆ LightArray() [2/2]

void JGL::J2D::LightArray ( std::vector< Light lights)

◆ OutlineChamferRect()

void JGL::J2D::OutlineChamferRect ( const Color4 &  color,
const Vector2 &  pos,
const Vector2 &  size,
float  radius = 5,
float  thickness = 1 
)

Draws an outline of a rectangle with chamfered corners onto the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
posThe top-left corner of the rectangle.
sizeThe width and height of the rectangle.
radiusThe corner-rounding radius (in radians).
thicknessThe width at which to render the lines.

◆ OutlineCircle()

void JGL::J2D::OutlineCircle ( const Color4 &  color,
const Vector2 &  center,
float  radius,
unsigned int  subdivisions = 16,
float  thickness = 1 
)

Draws an outline of a circle on the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
centerThe point in cartesian space at which to draw the circle. This will by-definition be the centroid of this circle.
radiusThe radius of the circle to be drawn. AKA Half the diameter.
subdivisionsThe accuracy of the approximation of the circle, measured in iteration steps taken.
thicknessThe line-width of the circle to be rendered at.

◆ OutlineEllipse()

void JGL::J2D::OutlineEllipse ( const Color4 &  color,
const Vector2 &  position,
float  radius_x,
float  radius_y,
float  thickness = 1,
int  subdivisions = 8 
)

◆ OutlinePolygon()

void JGL::J2D::OutlinePolygon ( const Color4 &  color,
const Vector2 *  points,
int  points_size,
float  thickness = 1 
)

Draws a series of points where the last point always connects to the first point.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
pointsThe array of vector2's to draw as a polygon.
points_sizeThe length of the array of vector2's.
thicknessThe line-width of the polygon

◆ OutlineRect()

void JGL::J2D::OutlineRect ( const Color4 &  color,
const Vector2 &  pos,
const Vector2 &  size,
float  thickness = 1 
)

Draws an outline of a rectangle on the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
posThe top-left corner of the rectangle.
sizeThe width and height of the rectangle.
thicknessThe width at which to render the lines.

◆ OutlineRoundedRect()

void JGL::J2D::OutlineRoundedRect ( const Color4 &  color,
const Vector2 &  pos,
const Vector2 &  size,
float  radius = 5,
float  thickness = 1 
)

Draws an outline of a rectangle with rounded corners onto the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
posThe top-left corner of the rectangle.
sizeThe width and height of the rectangle.
radiusThe corner-rounding radius (in radians).
thicknessThe width at which to render the lines.
Here is the call graph for this function:

◆ OutlineTriangle() [1/2]

void JGL::J2D::OutlineTriangle ( const Color4 &  color,
const Triangle2D &  tri,
float  thickness = 1 
)

Draws an outline of a triangle on the screen.

Parameters
colorA 3-or-4 channel color value.
See also
class Color3, class Color4
Parameters
triThe triangle defined by its vertices (A, B, and C).
thicknessThe line-width of the triangle to be rendered at.

◆ OutlineTriangle() [2/2]

void JGL::J2D::OutlineTriangle ( const Color4 &  color,
const Vector2 &  triA,
const Vector2 &  triB,
const Vector2 &  triC,
float  thickness = 1 
)