Implement documentation + A special case check on DrawArc.
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
@@ -144,12 +144,12 @@ namespace JGL {
|
||||
|
||||
/// Draws a render-target (runtime-modifiable texture) to the screen.
|
||||
/// @param render_target A RenderTarget instance to be displayed.
|
||||
/// @param position
|
||||
/// @param rad_rotation
|
||||
/// @param origin
|
||||
/// @param scale
|
||||
/// @param color
|
||||
/// @param inversion
|
||||
/// @param position The position at which to render this object from it's center-point, defined by the origin parameter.
|
||||
/// @param rad_rotation The amount of radians to rotate this render-target about it's center-point.
|
||||
/// @param origin The center-point in the image to use for rendering, rotation, and scaling. Top-left is {0,0} and bottom right is {1, 1}.
|
||||
/// @param scale The amount (in both x, and y axis) to scale the image, with {1,1} being default scaling.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param inversion @see Direction
|
||||
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 DrawRenderTarget(const RenderTarget* render_target, const Vector2& position, float rad_rotation = 0, const Vector2& origin = Vector2(0 , 0),
|
||||
@@ -159,12 +159,12 @@ namespace JGL {
|
||||
/// 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
|
||||
/// @param render_target A RenderTarget instance to be displayed.
|
||||
/// @param position
|
||||
/// @param rad_rotation
|
||||
/// @param origin
|
||||
/// @param scale
|
||||
/// @param color
|
||||
/// @param inversion
|
||||
/// @param position The position at which to render this object from it's center-point, defined by the origin parameter.
|
||||
/// @param rad_rotation The amount of radians to rotate this render-target about it's center-point.
|
||||
/// @param origin The center-point in the image to use for rendering, rotation, and scaling. Top-left is {0,0} and bottom right is {1, 1}.
|
||||
/// @param scale The amount (in both x, and y axis) to scale the image, with {1,1} being default scaling.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param inversion @see Direction
|
||||
/// @see DrawSprite
|
||||
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);
|
||||
@@ -177,8 +177,8 @@ namespace JGL {
|
||||
/// @param origin The center point around which the image should have all transformations applied to it.
|
||||
/// @param scale The scale transformation for the image. X and Y axis are independently-scalable.
|
||||
/// @param rad_rotation A float representing the rotation of the sprite where 0 is no rotation and 1 is the maximum rotation (would look the same as 0).
|
||||
/// @param color A 32-bit RGBA value represented as four unsigned 8-bit integers.
|
||||
/// @param inversion inverts the texture only.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param inversion @see Direction
|
||||
/// @see class Texture
|
||||
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);
|
||||
@@ -191,14 +191,14 @@ namespace JGL {
|
||||
const Color4& color = Colors::White, Direction inversion = Direction::None);
|
||||
|
||||
/// Draws a piece of a sprite to the screen, similar to DrawSprite.
|
||||
/// @param texture
|
||||
/// @param position
|
||||
/// @param texture A texture instance to be displayed.
|
||||
/// @param position The point at which to draw the sprite (from the top-left down).
|
||||
/// @param sub_texture_position The top left corner of the sub-texture to be drawn.
|
||||
/// @param sub_texture_size The size of the sub-texture in px.
|
||||
/// @param origin
|
||||
/// @param scale
|
||||
/// @param color
|
||||
/// @param inversion
|
||||
/// @param origin The center point around which the image should have all transformations applied to it.
|
||||
/// @param scale The scale transformation for the image. X and Y axis are independently-scalable.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param inversion @see Direction
|
||||
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, const Vector2& position, const Vector2& sub_texture_position, const Vector2& sub_texture_size, float rad_rotation = 0,
|
||||
@@ -210,79 +210,88 @@ namespace JGL {
|
||||
|
||||
/// 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.
|
||||
/// @param texture
|
||||
/// @param position
|
||||
/// @param texture A texture instance to be displayed.
|
||||
/// @param position The point at which to draw the sprite (from the top-left down).
|
||||
/// @param mirror_axis The axes to mirror across, Vertical and Horizontal or both only.
|
||||
/// @param rad_rotation The rotation of the final result.
|
||||
/// @param origin The point at which transformations are done about.
|
||||
/// @param scale
|
||||
/// @param color
|
||||
/// @param scale The scale transformation for the image. X and Y axis are independently-scalable.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
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 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);
|
||||
|
||||
/// Draws an outline of a circle on the screen.
|
||||
/// @param color
|
||||
/// @param center
|
||||
/// @param radius
|
||||
/// @param subdivisions
|
||||
/// @param thickness
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param center The point in cartesian space at which to draw the circle. This will by-definition be the centroid of this circle.
|
||||
/// @param radius The radius of the circle to be drawn. AKA Half the diameter.
|
||||
/// @param subdivisions The accuracy of the approximation of the circle, measured in iteration steps taken.
|
||||
/// @param thickness The line-width of the circle to be rendered at.
|
||||
void OutlineCircle(const Color4& color, const Vector2& center, float radius, unsigned int subdivisions = 16, float thickness = 1);
|
||||
|
||||
/// Draws a filled circle on the screen.
|
||||
/// @param color
|
||||
/// @param center
|
||||
/// @param radius
|
||||
/// @param subdivisions
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param center The point in cartesian space at which to draw the circle. This will by-definition be the centroid of this circle.
|
||||
/// @param radius The radius of the circle to be drawn. AKA Half the diameter.
|
||||
/// @param subdivisions The accuracy of the approximation of the circle, measured in iteration steps taken.
|
||||
void FillCircle(const Color4& color, const Vector2& center, float radius, unsigned int subdivisions = 8);
|
||||
|
||||
/// Draws an outline of a triangle on the screen.
|
||||
/// @param color
|
||||
/// @param tri
|
||||
/// @param thickness
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param tri The triangle structure / set of 3 points in cartesian space used to draw the triangle.
|
||||
/// @param thickness The line-width of the triangle to be rendered at.
|
||||
void OutlineTriangle(const Color4& color, const Triangle2D& tri, float thickness = 1);
|
||||
void OutlineTriangle(const Color4& color, const Vector2& triA, const Vector2& triB, const Vector2& triC, float thickness = 1);
|
||||
|
||||
/// Draws a filled triangle on the screen.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param tri The triangle structure / set of 3 points in cartesian space used to draw the triangle.
|
||||
void FillTriangle(const Color4& color, const Triangle2D& tri);
|
||||
void FIllTriangle(const Color4& color, const Vector2& triA, const Vector2& triB, const Vector2& triC);
|
||||
|
||||
/// Draws a triangle where each corner is defined by a given color, Smoothly transitioning between them.
|
||||
/// @param a_color
|
||||
/// @param b_color
|
||||
/// @param c_color
|
||||
/// @param tri
|
||||
void FillGradientTriangle(const Color4& a_color, const Color4& b_color, const Color4& c_color, const Triangle2D& tri);
|
||||
|
||||
/// Draws a smooth, curved line segment between two control points, with the curve controlled by the two inner points.
|
||||
/// @param color
|
||||
/// @param controlA
|
||||
/// @param pointA
|
||||
/// @param pointB
|
||||
/// @param controlB
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param controlA The first control point, which can be considered the start of the line.
|
||||
/// @param pointA The first inner point, which controls the contour of the curve.
|
||||
/// @param pointB The second inner point, which controls the contour of the curve.
|
||||
/// @param controlB The second control point, which can be considered the end of the line.
|
||||
/// @see J3ML::Algorithm::Bezier
|
||||
void DrawCubicBezierCurve(const Color4& color, const Vector2& controlA, const Vector2& pointA, const Vector2& pointB, const Vector2& controlB,
|
||||
int subdivisions = 10, float thickness = 1);
|
||||
|
||||
|
||||
// TODO: Implement OutlinePolygon overload which takes a std::vector of points as well.
|
||||
|
||||
/// Draws a series of points where the last point always connects to the first point.
|
||||
/// @param color
|
||||
/// @param points
|
||||
/// @param points_size
|
||||
/// @param thickness
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param points The array of vector2's to draw as a polygon.
|
||||
/// @param points_size The length of the array of vector2's.
|
||||
/// @param thickness The line-width of the polygon
|
||||
void OutlinePolygon(const Color4& color, const Vector2* points, int points_size, float thickness = 1);
|
||||
|
||||
/// Draws a text string on the screen with a given point-size and font.
|
||||
/// @param color
|
||||
/// @param text
|
||||
/// @param x
|
||||
/// @param y
|
||||
/// @param scale
|
||||
/// @param size
|
||||
/// @param font
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param text The text to be rendered.
|
||||
/// @param x The position on the screen at which to draw the text, from the top-left.
|
||||
/// @param y The position on the screen at which to draw the text, from the top-left.
|
||||
/// @param scale The value (in both axes) to scale the text by. Defaults to {1,1}.
|
||||
/// @param size The point-size at which to render the font out. Re-using the same point-size allows efficient glyph caching.
|
||||
/// @param font The font to use for rendering. @see Font.
|
||||
void DrawString(const Color4& color, const std::string& text, float x, float y, float scale, u32 size, const Font& font);
|
||||
|
||||
|
||||
/// Draws an Arc (section of a circle) to the screen.
|
||||
/// @param color
|
||||
/// @param center
|
||||
/// @param radius
|
||||
/// @param arc_begin
|
||||
/// @param arc_end
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param center The point in cartesian space at which to draw the arc. This will by-definition be the centroid of this partial circle.
|
||||
/// @param radius The radius of the partial circle to be drawn. AKA Half the diameter.
|
||||
/// @param arc_begin The point (0 - 2pi) around a unit-circle of which to start the arc.
|
||||
/// @param arc_end The point (0 - 2pi) around a unit-circle of which to start the arc.
|
||||
/// @param subdivisions
|
||||
/// @param thickness
|
||||
void DrawArc(const Color4& color, const Vector2& center, float radius, float arc_begin, float arc_end,
|
||||
|
@@ -750,6 +750,12 @@ namespace JGL {
|
||||
if (!inJ2D)
|
||||
Logger::Error("Drawing J2D element before J2D begin.");
|
||||
|
||||
if (arc_begin == arc_end)
|
||||
Logger::Error("WTF are you even drawing???");
|
||||
|
||||
if ( J3ML::Math::Mod(J3ML::Math::Abs(arc_begin-arc_end), J3ML::Math::Pi*2.f) == 0)
|
||||
Logger::Error("Use OutlineCircle instead!!");
|
||||
|
||||
float step = Math::Abs(arc_end-arc_begin) / (float) subdivisions;
|
||||
std::vector<Vector2> vertices(subdivisions);
|
||||
GLfloat angle, x, y;
|
||||
|
Reference in New Issue
Block a user