Canvas Manager - Horizon-NTH/HorizonGUI GitHub Wiki

CanvasManager

Overview

The CanvasManager class, located in the hgui namespace, is a versatile tool for managing Canvas creation in your graphical application. The class can be found inside the header file CanavasManager.h.

Member Functions

  • std::shared_ptr<hgui::kernel::Canvas> create(const std::shared_ptr<kernel::Shader>& shader, const size& size, const point& position, const color& color = HGUI_COLOR_WHITE): Creates a new canvas with the specified parameters.

Note: The shader parameter let you choose if you want to use the default canvas shader by passing nullptr or creating you own shader. If you want to know how work the default shader, please take a look at the source code.

Example Usage

#include <hgui/header/CanvasManager.h>

{ // Example Usage of CanvasManager
    std::shared_ptr<hgui::kernel::Shader> shader = /* initialize shader */;
    hgui::size canvasSize(800, 600);
    hgui::point canvasPosition(200, 200);

    // Create a canvas
    std::shared_ptr<hgui::kernel::Canvas> myCanvas = hgui::CanvasManager::create(shader, canvasSize, canvasPosition, HGUI_COLOR_WHITE);

    myCanvas->draw();
    // (Apply canvas effects here)
} // Here the destructor of myCanvas is called

Note: In the "Example Usage" section, we demonstrate how to create a canvas with the CanvasManager class.