Marbellous
Marbellous, a WebApp to generate paper marbling patterns.
Classes | Public Member Functions | Static Public Attributes | List of all members
Polygon Class Reference

Represent polygons in 2D as a list of vertices in counter-clockwise order. More...

#include <Polygon.hpp>

Collaboration diagram for Polygon:
Collaboration graph

Public Member Functions

 Polygon ()
 
 Polygon (Point mid, float radius, GLuint colorIndex)
 
size_t getVertCount () const
 
void getDrawInfo (std::vector< WGLVertex > &vertices, GLuint z) const
 
Point const & getCreationPoint ()
 
void displace (const std::vector< Displacement > &displacements, size_t canvasSize)
 
void makeCircle (Point mid, float radius)
 

Static Public Attributes

static constexpr float MIN_R = 0.0001
 

Detailed Description

Represent polygons in 2D as a list of vertices in counter-clockwise order.

Constructor & Destructor Documentation

◆ Polygon() [1/2]

Polygon::Polygon ( )

Create an empty Polygon.

◆ Polygon() [2/2]

Polygon::Polygon ( Point  mid,
float  radius,
GLuint  colorIndex 
)

Create a circle.

Parameters
midMiddle point of the circle.
radiusRadius of the circle.
Here is the call graph for this function:

Member Function Documentation

◆ displace()

void Polygon::displace ( const std::vector< Displacement > &  displacements,
size_t  canvasSize 
)

Displace a polygon as a result of a new circle appearing. The math for this function was provided by Prof. Graham Horton.

Parameters
displacementsvector of circles with radius and diameter which causes displacement
canvasSizesize of canvas in pixel to calculate vertex insertion for smooth edges.
Here is the call graph for this function:

◆ getCreationPoint()

Point const & Polygon::getCreationPoint ( )

Return the point which was the original middle point.

Returns
middle point

◆ getDrawInfo()

void Polygon::getDrawInfo ( std::vector< WGLVertex > &  vertices,
GLuint  z 
) const

Fill vectors with infos needed for drawing. Intended to be used for glDrawElements(). Therefore 3 consecutive indices define one triangle to be drawn and refer to vertices inside the vertices vector.

Parameters
indicesVector to be filled with triangle information.
verticesVector to be filled with vertices.
Attention
Winding order is clockwise so face culling in WGL needs to be disabled. This is no performance limitation as each triangle is allways visible.

◆ getVertCount()

size_t Polygon::getVertCount ( ) const
Returns
Number of vertices of a polygon.
Here is the caller graph for this function:

◆ makeCircle()

void Polygon::makeCircle ( Point  mid,
float  radius 
)

Redraw Polygon as a new circle. This is intended to be used for making the circle larger.

Parameters
midMiddle point of the circle.
radiusRadius of the circle.
Attention
Will throw an error if used on a polygon that is no longer a circle.
Here is the caller graph for this function:

Member Data Documentation

◆ MIN_R

constexpr float Polygon::MIN_R = 0.0001
staticconstexpr

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