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

The State class relates a shape and related properties to a measure of how close it brings the working image to the target image. More...

#include <state.h>

Public Member Functions

 State ()
 
 State (const std::shared_ptr< geometrize::Shape > &shape, std::uint8_t alpha)
 Creates a new state. More...
 
 ~State ()=default
 
 State (const State &other)
 
Stateoperator= (const State &other)
 
geometrize::State mutate ()
 mutate Modifies the current state in a random fashion. More...
 

Public Attributes

double m_score
 The score of the state, a measure of the improvement applying the state to the current bitmap will have. More...
 
std::uint8_t m_alpha
 The alpha of the shape. More...
 
std::shared_ptr< geometrize::Shapem_shape
 The geometric primitive owned by the state. More...
 

Detailed Description

The State class relates a shape and related properties to a measure of how close it brings the working image to the target image.

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

Constructor & Destructor Documentation

◆ State() [1/3]

geometrize::State::State ( )
11: m_score{-1.0}, m_alpha{0}, m_shape{nullptr} {}
std::uint8_t m_alpha
The alpha of the shape.
Definition: state.h:42
double m_score
The score of the state, a measure of the improvement applying the state to the current bitmap will ha...
Definition: state.h:41
std::shared_ptr< geometrize::Shape > m_shape
The geometric primitive owned by the state.
Definition: state.h:43

◆ State() [2/3]

geometrize::State::State ( const std::shared_ptr< geometrize::Shape > &  shape,
std::uint8_t  alpha 
)

Creates a new state.

Parameters
shapeThe shape.
alphaThe color alpha of the geometric shape.
13 :
14 m_score{-1.0}, m_alpha{alpha}, m_shape{shape}
15{
16 m_shape->setup(*m_shape);
17}

◆ ~State()

geometrize::State::~State ( )
default

◆ State() [3/3]

geometrize::State::State ( const State other)
29 : m_score{other.m_score}, m_alpha{other.m_alpha}, m_shape{other.m_shape->clone()}
30{
31}

Member Function Documentation

◆ mutate()

geometrize::State geometrize::State::mutate ( )

mutate Modifies the current state in a random fashion.

Returns
The old state, useful for undoing the mutation or keeping track of previous states.
34{
35 geometrize::State oldState(*this);
36 m_shape->mutate(*m_shape);
37 m_score = -1;
38 return oldState;
39}
The State class relates a shape and related properties to a measure of how close it brings the workin...
Definition: state.h:21

◆ operator=()

State & geometrize::State::operator= ( const State other)
20{
21 if(this != &other) {
22 m_score = other.m_score;
23 m_alpha = other.m_alpha;
24 m_shape = other.m_shape->clone();
25 }
26 return *this;
27}

Member Data Documentation

◆ m_alpha

std::uint8_t geometrize::State::m_alpha

The alpha of the shape.

◆ m_score

double geometrize::State::m_score

The score of the state, a measure of the improvement applying the state to the current bitmap will have.

◆ m_shape

std::shared_ptr<geometrize::Shape> geometrize::State::m_shape

The geometric primitive owned by the state.


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