Simple Graphics Library  0.9.5
SGL API
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sgl::SevenSegmentDigit Class Reference

#include <sgl.h>

Collaboration diagram for sgl::SevenSegmentDigit:
Collaboration graph
[legend]

Public Member Functions

 SevenSegmentDigit (Color color, double x, double y, double height)
 
double get_x () const
 
double get_y () const
 
double get_height () const
 
void paint () const
 
void set_value (int value)
 
int get_value () const
 
void increment ()
 
void decrement ()
 
void resize (double inc)
 
void move_to (double x, double y)
 

Protected Member Functions

void update_segment_locations ()
 

Protected Attributes

int current_value
 
Color color
 
double x
 
double y
 
double height
 
Point segment_a [4]
 
Point segment_b [4]
 
Point segment_c [4]
 
Point segment_d [4]
 
Point segment_e [4]
 
Point segment_f [4]
 
Point segment_g [6]
 

Detailed Description

Used to draw decimal digits that look like LED/LCD seven-segment displays

Constructor & Destructor Documentation

◆ SevenSegmentDigit()

sgl::SevenSegmentDigit::SevenSegmentDigit ( Color  color,
double  x,
double  y,
double  height 
)

The constructor sets the digit's color, position, and size.

Parameters
colorthe color of the digit
xthe x coordinate of the digit's lower-left corner
ythe y coordinate of the digit's lower-left corner
heightthe height of the digit

Member Function Documentation

◆ decrement()

void sgl::SevenSegmentDigit::decrement ( )

Decreases the digit's value by 1, modulo 10.

Returns
nothing

◆ get_height()

double sgl::SevenSegmentDigit::get_height ( ) const

Returns the digit's height.

Returns
the digit's height.

◆ get_value()

int sgl::SevenSegmentDigit::get_value ( ) const

Returns the digit's current value.

Returns
the digit's current value.

◆ get_x()

double sgl::SevenSegmentDigit::get_x ( ) const

Returns the x coordinate of the digit's lower-left corner.

Returns
the x coordinate of the digit's lower-left corner.

◆ get_y()

double sgl::SevenSegmentDigit::get_y ( ) const

Returns the y coordinate of the digit's lower-left corner.

Returns
the y coordinate of the digit's lower-left corner.

◆ increment()

void sgl::SevenSegmentDigit::increment ( )

Increases the digit's value by 1, modulo 10.

Returns
nothing

◆ move_to()

void sgl::SevenSegmentDigit::move_to ( double  x,
double  y 
)

Moves the digit to a new location. The digit's size is unaffected.

Parameters
xthe new x coordinate of the digit's lower-left corner.
ythe new y coordinate of the digit's lower-left corner.
Returns
nothing

◆ paint()

void sgl::SevenSegmentDigit::paint ( ) const

Draws the digit.

◆ resize()

void sgl::SevenSegmentDigit::resize ( double  inc)

Changes the height of the digit by a given amount. The digit's width changes proportionally.

Parameters
thechange in the height of the digit
Returns
nothing

◆ set_value()

void sgl::SevenSegmentDigit::set_value ( int  value)

Set's the value of the digit. The assigned value is modulo ten.

Parameters
valuevalue to assign, modulo 10
Returns
nothing

◆ update_segment_locations()

void sgl::SevenSegmentDigit::update_segment_locations ( )
protected

This helper method updates the vertices of the individual segments relative to the position of the digit. This method is called when the digit is repositioned.

Returns
nothing

Member Data Documentation

◆ color

Color sgl::SevenSegmentDigit::color
protected

The color of the displayed digit.

◆ current_value

int sgl::SevenSegmentDigit::current_value
protected

The current digit's value.

◆ height

double sgl::SevenSegmentDigit::height
protected

The height of the LED.

◆ x

double sgl::SevenSegmentDigit::x
protected

(x,y) coordinates of lower-left corner of the LED.


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