Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/adi3120/Fazen2d/llms.txt

Use this file to discover all available pages before exploring further.

Shape defines the polymorphic interface that every Fazen2d drawable must satisfy. GraphicsRenderer::draw() accepts a Shape&, so any class deriving from Shape works transparently with the renderer — you can store heterogeneous primitives in a single container and draw them all through one uniform call.
#include "include/headers/Shape.h"
Shape.h is included transitively through any concrete shape header (Point.h, Line.h, etc.) and through the top-level Fazen.h umbrella header.

Interface

class Shape {
public:
    virtual void draw() = 0;
    virtual void translate(float dx, float dy) = 0;
    virtual ~Shape() = default;
};

Pure Virtual Methods

MethodDescription
draw()Writes shape characters and color attributes into the ConsoleHandler back-buffer. Called once per frame by the render loop.
translate(float dx, float dy)Moves the shape by dx columns and dy rows. Implementations are responsible for bounds checking against ConsoleHandler::GetConsoleWidth() and ConsoleHandler::GetConsoleHeight().

Built-in Implementations

Point

Single character cell at a given (x, y) position with a chosen color and Unicode character.

Line

Straight line between two endpoints, rasterized with Bresenham’s algorithm.

Box

Solid filled rectangle defined by an origin, width, height, color, and fill character.

Circle

Filled circular region drawn using a per-cell distance formula over a bounding square.

Text

Wide-character string rendered into consecutive console cells at a given position.

Custom Shapes

Derive from Shape to build your own drawable primitives that work seamlessly with the renderer.

Custom Shape Example

Derive publicly from Shape, store your geometry as member data, and implement both pure virtuals. Use ConsoleHandler to write directly into the back-buffer.
#include "include/headers/Shape.h"

class Cross : public Shape {
    float cx, cy;
    short color;
public:
    Cross(float cx, float cy, short color) : cx(cx), cy(cy), color(color) {}

    void draw() override {
        // Draw a 3x1 horizontal bar
        for (int i = -1; i <= 1; i++) {
            int px = (int)(cx + i);
            int py = (int)cy;
            if (px >= 0 && px < ConsoleHandler::GetConsoleWidth() &&
                py >= 0 && py < ConsoleHandler::GetConsoleHeight()) {
                ConsoleHandler::GetBuffScreen()[px + ConsoleHandler::GetConsoleWidth() * py]
                    .Char.UnicodeChar = 0x2588;
                ConsoleHandler::GetBuffScreen()[px + ConsoleHandler::GetConsoleWidth() * py]
                    .Attributes = color;
            }
        }
    }

    void translate(float dx, float dy) override {
        cx += dx; cy += dy;
    }
};

Build docs developers (and LLMs) love