Simple Graphics Library
0.9.5
SGL API
|
#include <sgl.h>
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] |
Used to draw decimal digits that look like LED/LCD seven-segment displays
sgl::SevenSegmentDigit::SevenSegmentDigit | ( | Color | color, |
double | x, | ||
double | y, | ||
double | height | ||
) |
The constructor sets the digit's color, position, and size.
color | the color of the digit |
x | the x coordinate of the digit's lower-left corner |
y | the y coordinate of the digit's lower-left corner |
height | the height of the digit |
void sgl::SevenSegmentDigit::decrement | ( | ) |
Decreases the digit's value by 1, modulo 10.
double sgl::SevenSegmentDigit::get_height | ( | ) | const |
Returns the digit's height.
int sgl::SevenSegmentDigit::get_value | ( | ) | const |
Returns the digit's current value.
double sgl::SevenSegmentDigit::get_x | ( | ) | const |
Returns the x coordinate of the digit's lower-left corner.
double sgl::SevenSegmentDigit::get_y | ( | ) | const |
Returns the y coordinate of the digit's lower-left corner.
void sgl::SevenSegmentDigit::increment | ( | ) |
Increases the digit's value by 1, modulo 10.
void sgl::SevenSegmentDigit::move_to | ( | double | x, |
double | y | ||
) |
Moves the digit to a new location. The digit's size is unaffected.
x | the new x coordinate of the digit's lower-left corner. |
y | the new y coordinate of the digit's lower-left corner. |
void sgl::SevenSegmentDigit::paint | ( | ) | const |
Draws the digit.
void sgl::SevenSegmentDigit::resize | ( | double | inc | ) |
Changes the height of the digit by a given amount. The digit's width changes proportionally.
the | change in the height of the digit |
void sgl::SevenSegmentDigit::set_value | ( | int | value | ) |
Set's the value of the digit. The assigned value is modulo ten.
value | value to assign, modulo 10 |
|
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.
|
protected |
The color of the displayed digit.
|
protected |
The current digit's value.
|
protected |
The height of the LED.
|
protected |
(x,y) coordinates of lower-left corner of the LED.