Geometrize 1.0
C++ library for geometrizing images into geometric primitives
Public Member Functions | Public Attributes | List of all members
geometrize::Triangle Class Reference

The Triangle class represents a triangle. More...

#include <triangle.h>

Inheritance diagram for geometrize::Triangle:
Inheritance graph
[legend]
Collaboration diagram for geometrize::Triangle:
Collaboration graph
[legend]

Public Member Functions

 Triangle ()=default
 
 Triangle (float x1, float y1, float x2, float y2, float x3, float y3)
 
virtual std::shared_ptr< geometrize::Shapeclone () const override
 clone Clones the shape, a virtual copy constructor. More...
 
virtual geometrize::ShapeTypes getType () const override
 getType Gets the ShapeType of the shape. More...
 
- Public Member Functions inherited from geometrize::Shape
 Shape ()=default
 
virtual ~Shape ()=default
 
Shapeoperator= (const geometrize::Shape &other)=default
 
 Shape (const geometrize::Shape &other)=default
 
virtual std::shared_ptr< geometrize::Shapeclone () const
 clone Clones the shape, a virtual copy constructor. More...
 
virtual geometrize::ShapeTypes getType () const
 getType Gets the ShapeType of the shape. More...
 

Public Attributes

float m_x1
 First x-coordinate. More...
 
float m_y1
 First y-coordinate. More...
 
float m_x2
 Second x-coordinate. More...
 
float m_y2
 Second y-coordinate. More...
 
float m_x3
 Third x-coordinate. More...
 
float m_y3
 Third y-coordinate. More...
 
- Public Attributes inherited from geometrize::Shape
std::function< void(geometrize::Shape &)> setup
 
std::function< void(geometrize::Shape &)> mutate
 
std::function< std::vector< geometrize::Scanline >(const geometrize::Shape &)> rasterize
 

Detailed Description

The Triangle class represents a triangle.

Author
Sam Twidale (https://samcodes.co.uk/)

Constructor & Destructor Documentation

◆ Triangle() [1/2]

geometrize::Triangle::Triangle ( )
default

◆ Triangle() [2/2]

geometrize::Triangle::Triangle ( float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3 
)
11 : Shape()
12{
13 m_x1 = x1;
14 m_y1 = y1;
15 m_x2 = x2;
16 m_y2 = y2;
17 m_x3 = x3;
18 m_y3 = y3;
19}
float m_x3
Third x-coordinate.
Definition: triangle.h:28
float m_y3
Third y-coordinate.
Definition: triangle.h:29
float m_y1
First y-coordinate.
Definition: triangle.h:25
float m_x2
Second x-coordinate.
Definition: triangle.h:26
float m_x1
First x-coordinate.
Definition: triangle.h:24
float m_y2
Second y-coordinate.
Definition: triangle.h:27

Member Function Documentation

◆ clone()

std::shared_ptr< geometrize::Shape > geometrize::Triangle::clone ( ) const
overridevirtual

clone Clones the shape, a virtual copy constructor.

Returns
A clone of the shape.

Reimplemented from geometrize::Shape.

22{
23 std::shared_ptr<geometrize::Triangle> triangle{std::make_shared<geometrize::Triangle>()};
24 triangle->m_x1 = m_x1;
25 triangle->m_y1 = m_y1;
26 triangle->m_x2 = m_x2;
27 triangle->m_y2 = m_y2;
28 triangle->m_x3 = m_x3;
29 triangle->m_y3 = m_y3;
30 triangle->setup = setup;
31 triangle->mutate = mutate;
32 triangle->rasterize = rasterize;
33 return triangle;
34}
std::function< std::vector< geometrize::Scanline >(const geometrize::Shape &)> rasterize
Definition: shape.h:27
std::function< void(geometrize::Shape &)> setup
Definition: shape.h:25
std::function< void(geometrize::Shape &)> mutate
Definition: shape.h:26

◆ getType()

geometrize::ShapeTypes geometrize::Triangle::getType ( ) const
overridevirtual

getType Gets the ShapeType of the shape.

Returns
The ShapeType of the shape.

Reimplemented from geometrize::Shape.

37{
39}
@ TRIANGLE
Definition: shapetypes.h:20

Member Data Documentation

◆ m_x1

float geometrize::Triangle::m_x1

First x-coordinate.

◆ m_x2

float geometrize::Triangle::m_x2

Second x-coordinate.

◆ m_x3

float geometrize::Triangle::m_x3

Third x-coordinate.

◆ m_y1

float geometrize::Triangle::m_y1

First y-coordinate.

◆ m_y2

float geometrize::Triangle::m_y2

Second y-coordinate.

◆ m_y3

float geometrize::Triangle::m_y3

Third y-coordinate.


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