-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This is a wiki for my Terminal Graphics library
Folder Structure
Renderer Ascii
../
├── assets
├── Camera
├── dependencies
├── Engine
├── Examples
├── l_gebra
├── window
├── README.md
├── renderer2D
├── sprite_engine.cpp
├── time
└── Makefile
This library has a very simple folder structure
assets folder contains all the assets required in demos and during development & some default assets that you can use during your development too, like some sprites and obj files etc..
Camera folder a simple 2D camera implementation.
dependencies folder contains external (only **stb_image (special thanks to nothings)) & in library implementations of dependencies like color, font, image, gradient, font etc. that you can use without importing them as they're already imported in Ascii class.
Engine contains implementation of 3D renderer Engine3D and related classes like Mesh and Triangle3D
Examples contains, well Examples
l_gebra folder contains l_gebra a linear algebra header only library written by me again
time folder contains implementations of utilities that deal with time like Fps engine and all.
Window folder contains implementations of window management which mostly deals with i/o, drawing and keyboard and mouse events.
renderer2D contains implementation of 2D renderer ascii and related implementations
A simple main interface needed for most graphics and most of the general work
The Renderer class provides a set of functions for drawing various shapes, text, and UI elements onto a buffer in a terminal-based environment. It supports rendering points, lines, circles, rectangles, triangles, polygons, and various UI components like buttons and sliders. Additionally, the class includes functionality for anti-aliasing and gradient fills.
This library uses double the width of given provided width to tackle rectangular pixels in terminal
so it appears square, you will notice it's odd effects in many places, so please bear with it. :)
-
Renderer()
: Default constructor. Initializes an emptyRenderer
object. -
Renderer(size_t width, size_t height)
: Initializes aRenderer
with the specified width and height. -
Renderer(std::shared_ptr<Buffer> buffer)
: Initializes aRenderer
using an existingBuffer
object. -
Renderer(size_t width, size_t height, Color bg_color)
: Initializes aRenderer
with the specified width, height, and background color. -
~Renderer()
: Destructor. Cleans up any resources used by theRenderer
.
-
const Buffer &get_buffer() const
: Returns a reference to the internal buffer used by theRenderer
. -
size_t get_width() const
: Returns the width of the rendering buffer. -
size_t get_height() const
: Returns the height of the rendering buffer. -
void Init()
: Initializes the rendering process. -
void end()
: Ends the rendering process, potentially finalizing any drawing operations.
-
bool draw_point(utl::Vec<int, 2> point, char c, Color color = Color(WHITE))
: Draws a single point at the specified location with the given character and color. -
bool draw_point2(utl::Vec<int, 2> point, char c, char c2, Color color = Color(WHITE))
: Draws a single point with two characters at the specified location with the given color. -
bool draw_point(const Point &point)
: Draws aPoint
object at its specified location. -
bool draw_half_point(utl::Vec<int, 2> point, char c, bool left, Color color = Color(WHITE))
: Draws a half-point character, either left or right half, at the specified location. -
bool draw_half_point(const half_point &point)
: Draws ahalf_point
object at its specified location.
-
void draw_line(utl::Vec<int, 2> start, utl::Vec<int, 2> end, char c, Color color = Color(WHITE))
: Draws a line between two points using the specified character and color. -
void draw_line(const Line &line)
: Draws aLine
object with the defined properties. -
void draw_anti_aliased_line(utl::Vec<int, 2> start, utl::Vec<int, 2> end, Color color = Color(WHITE))
: Draws an anti-aliased line between two points using color blending. -
void draw_anti_aliased_line(const Line &line)
: Draws an anti-aliasedLine
object.
-
void draw_circle(utl::Vec<int, 2> center, int radius, char ch, Color color = WHITE)
: Draws an outline of a circle centered at the specified point with the given radius, character, and color. -
void draw_circle(const Circle &circle)
: Draws aCircle
object with the defined properties. -
void draw_fill_circle(utl::Vec<int, 2> center, int radius, char ch, Color color = WHITE)
: Draws a filled circle at the specified center with the given radius, character, and color. -
void draw_fill_circle(const Circle &circle)
: Draws a filledCircle
object.
-
void draw_rectangle(utl::Vec<int, 2> start, int width, int height, char ch, char char2 = '@', Color color = WHITE)
: Draws an outline of a rectangle starting at the specified point with the given width, height, characters, and color. -
void draw_rectangle(const Rectangle &rectangle)
: Draws aRectangle
object with the defined properties. -
void draw_fill_rectangle(utl::Vec<int, 2> start, int width, int height, char ch, Color color = WHITE)
: Draws a filled rectangle starting at the specified point with the given width, height, character, and color. -
void draw_fill_rectangle(const Rectangle &rectangle)
: Draws a filledRectangle
object. -
void draw_rect_linear_gradient(utl::Vec<int, 2> start, int width, int height, char ch, Gradient &gradient, bool horizontal = true)
: Draws a rectangle filled with a linear gradient, either horizontally or vertically. -
std::pair<float, float> rotate_point(float x, float y, float angle)
: Rotates a point around the origin by a specified angle. -
void draw_rect_rotated_gradient(utl::Vec<int, 2> start, int width, int height, char ch, Gradient &gradient, float angle)
: Draws a rectangle filled with a rotated linear gradient. -
void draw_rect_radial_gradient(utl::Vec<int, 2> start, int width, int height, char ch, Gradient &gradient)
: Draws a rectangle filled with a radial gradient.
-
void draw_triangle(utl::Vec<int, 2> a, utl::Vec<int, 2> b, utl::Vec<int, 2> c, char ch, Color color = WHITE)
: Draws an outline of a triangle using the specified vertices, character, and color. -
void draw_triangle(const Triangle &triangle)
: Draws aTriangle
object with the defined properties. -
void draw_antialiased_triangle(utl::Vec<int, 2> a, utl::Vec<int, 2> b, utl::Vec<int, 2> c, Color color = WHITE)
: Draws an anti-aliased triangle using color blending. -
void draw_antialiased_triangle(const Triangle &triangle)
: Draws an anti-aliasedTriangle
object. -
void draw_fill_triangle(utl::Vec<int, 2> a, utl::Vec<int, 2> b, utl::Vec<int, 2> c, char ch, Color color = WHITE)
: Draws a filled triangle using the specified vertices, character, and color. -
void draw_fill_triangle(const Triangle &triangle)
: Draws a filledTriangle
object. -
void draw_fill_antialias_triangle(utl::Vec<int, 2> a, utl::Vec<int, 2> b, utl::Vec<int, 2> c, char ch, Color color = WHITE)
: Draws a filled anti-aliased triangle using the specified vertices, character, and color. -
void draw_fill_antialias_triangle(const Triangle &triangle)
: Draws a filled anti-aliasedTriangle
object.
-
void draw_polygon(std::vector<utl::Vec<int, 2>> vertices, char ch, Color color = WHITE)
: Draws a polygon defined by a list of vertices using the specified character and color. -
void draw_polygon(const Polygon &polygon)
: Draws aPolygon
object with the defined properties. -
void draw_arc(utl::Vec<int, 2> center, int radius, char ch, float end_angle, float start_angle = 0.0f, Color color = WHITE)
: Draws an arc (portion of a circle) centered at the specified point with the given radius, character, color, and angles.
-
void draw_text(utl::Vec<int, 2> start, const std::string &text, Color color = WHITE)
: Draws text starting at the specified point with the given color. -
void draw_text_constrained(utl::Vec<int, 2> start, const std::string &text, size_t width, Color color = WHITE)
: Draws text within a constrained width starting at the specified point with the given color.