Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes | List of all members
PaintingTool Class Reference

Utility presenting a canvas to the user, along with a brush tool to paint on it using different shapes. More...

#include <PaintingTool.hpp>

Public Member Functions

 PaintingTool (unsigned int width, unsigned int height)
 
void draw ()
 
void update ()
 
void resize (uint width, uint height)
 
const Texturetexture () const
 
const TexturevisuId () const
 

Private Types

enum class  Mode : int { DRAW = 0 , ERASE }
 The effect of a brush stroke.
 
enum class  Shape : int { CIRCLE = 0 , SQUARE , DIAMOND , COUNT }
 The shape of the brush.
 

Private Attributes

Texture _canvas
 Scene rendering buffer.
 
Texture _visu
 Scene rendering buffer.
 
Program_brushShader
 Program for the brush and its outline.
 
std::vector< Mesh_brushes
 Brush shape geometries.
 
glm::vec3 _bgColor = glm::vec3(0.0f)
 Canvas color.
 
glm::vec3 _fgColor = glm::vec3(1.0f)
 Brush color.
 
glm::vec2 _drawPos = glm::vec2(0.0f)
 Current brush position.
 
int _radius = 40
 Brush radius, in pixels.
 
Mode _mode = Mode::DRAW
 Current brush effect.
 
Shape _shape = Shape::CIRCLE
 Current brush shape.
 
bool _shouldClear = true
 Clear the canvas at the next frame.
 
bool _shouldDraw = false
 Apply the brush to the canvas at the next frame.
 
GPUAsyncTask _readbackTask = 0
 Handle for color picker task.
 

Detailed Description

Utility presenting a canvas to the user, along with a brush tool to paint on it using different shapes.

Constructor & Destructor Documentation

◆ PaintingTool()

PaintingTool::PaintingTool ( unsigned int  width,
unsigned int  height 
)

Constructor.

Parameters
widththe canvas width
heightthe canvas height

Member Function Documentation

◆ draw()

void PaintingTool::draw ( )

Draw the scene and effects

◆ resize()

void PaintingTool::resize ( uint  width,
uint  height 
)

Handle a window resize event.

Parameters
widththe new width
heightthe new height

◆ texture()

const Texture * PaintingTool::texture ( ) const
inline

Canvas content texture.

Returns
the canvas ID

◆ update()

void PaintingTool::update ( )

Perform once-per-frame update (buttons, GUI,...)

◆ visuId()

const Texture * PaintingTool::visuId ( ) const
inline

Texture containing the canvas and the brush shape outline, for visualisation.

Returns
the texture ID

The documentation for this class was generated from the following files: