Tscope5
|
Definitions of graphics parameter functions. More...
Go to the source code of this file.
Functions | |
Coordinate functions | |
There are two coordinate systems and two coordinate scales available in Tscope5.
Some helper functions that (can help you) convert between the coordinate scales/systems are available, but most of the time you will only need to choose the coordinate system/scale and Tscop5 will automatically do the transormations that are necessary. | |
int | ts5_set_coordinate_system (const int coordinate_system) |
Set the coordinate system. More... | |
int | ts5_get_coordinate_system () |
Get the coordinate system. More... | |
int | ts5_set_coordinate_scale (const int coordinate_scale) |
Set the coordinate scale. More... | |
int | ts5_get_coordinate_scale () |
Get the coordinate scale. More... | |
double | ts5_relative_to_absolute_coordinate_x (const double x) |
Convert a relative horizontal coordinate into an absolute horizontal coordinate. More... | |
double | ts5_relative_to_absolute_coordinate_y (const double y) |
Convert a relative vertical coordinate into an absolute vertical coordinate. More... | |
double | ts5_absolute_to_relative_coordinate_x (const double x) |
Convert an absolute horizontal coordinate into a relative horizontal coordinate. More... | |
double | ts5_absolute_to_relative_coordinate_y (const double y) |
Convert an absolute vertical coordinate into a relative vertical coordinate. More... | |
double | ts5_cartesian_to_display_coordinate_x (const double x) |
Convert a horizontal Cartesian coordinate into a horizontal display coordinate. More... | |
double | ts5_cartesian_to_display_coordinate_y (const double y) |
Convert a vertical Cartesian coordinate into a vertical display coordinate. More... | |
double | ts5_display_to_cartesian_coordinate_x (const double x) |
Convert a horizontal display coordinate into a horizontal Cartisian coordinate. More... | |
double | ts5_display_to_cartesian_coordinate_y (const double y) |
Convert a vertical display coordinate into a vertical Cartisian coordinate. More... | |
Color definitions | |
Tscope5 describes colors in a structure (TS5_COLOR) containing red (r), green (g), blue (b) and alpha (a, transparency) values between 0.0 and 1.0. The functions below generate such a color structure using the RGB, HSL or HSV color specification or using the w3c naming system. Please note that the color structure is a structure, not a variable (they can only be assigned at the moment of declaration, not afterwards). See the examples for instructions on how to use them. | |
TS5_COLOR | ts5_make_rgb_color (const double r, const double g, const double b, const double a) |
Generate a color specification based on an RGB triplet plus an alpha channel. More... | |
TS5_COLOR | ts5_make_hsl_color (const double h, const double s, const double l, const double a) |
Generate a color specification based on an HSL triplet plus an alpha channel. More... | |
TS5_COLOR | ts5_make_hsv_color (const double h, const double s, const double v, const double a) |
Generate a color specification based on an HSV triplet plus an alpha channel. More... | |
TS5_COLOR | ts5_make_named_color (const char *name, const double a) |
Return a color that corresponds to name. More... | |
Graphics parameter functions | |
This part contains functions to change the graphics parameters of the text output and primitives drawing functions.
The text and drawing functions do not have arguments to alter the graphics parameters. This is done with the parameter functions below. They all change one parameter, e.g. the foreground color. Once a parameter value is changed, that value is used for all further drawing until it is changed again. The parameter functions all return the previous parameter setting. This can be useful when you want to change some parameters in one part of a program, do some drawing and set the previous parameters again without causing undesired parameter changes to other parts of the program. | |
TS5_COLOR | ts5_set_foreground_color (const TS5_COLOR foreground_color) |
Set the foreground color. More... | |
TS5_COLOR | ts5_get_foreground_color () |
Get the foreground color. More... | |
TS5_COLOR | ts5_set_background_color (const TS5_COLOR background_color) |
Set the background color. More... | |
TS5_COLOR | ts5_get_background_color () |
Get the background color. More... | |
double | ts5_set_drawing_thickness (double drawing_thickness) |
Set the drawing thickness. More... | |
double | ts5_get_drawing_thickness () |
Get the drawing thickness. More... | |
int | ts5_set_fill_mode (const int fill_mode) |
Set the fill mode. More... | |
int | ts5_get_fill_mode () |
Get the fill mode. More... | |
int | ts5_set_font_type (const int font_type) |
Set the font type. More... | |
int | ts5_get_font_type () |
Get the font type. More... | |
int | ts5_set_font_style (const int font_style) |
Set the font style. More... | |
int | ts5_get_font_style () |
Get the font style. More... | |
int | ts5_set_font_size (int font_size) |
Set the font size. More... | |
int | ts5_get_font_size () |
Get the font size. More... | |
int | ts5_set_font_index (const int font_index) |
Set the font index. More... | |
int | ts5_get_font_index () |
Get the font index. More... | |
int | ts5_set_text_alignment (const int text_alignment) |
Set the alignment of text. More... | |
int | ts5_get_text_alignment () |
Get the alignment of text. More... | |
Definitions of graphics parameter functions.
Definition in file graphics.c.
int ts5_set_coordinate_system | ( | const int | coordinate_system | ) |
Set the coordinate system.
coordinate_system | Coordinate system to be used. Can be TS5_CARTESIAN_COORDINATES and TS5_DISPLAY_COORDINATES. Default is TS5_CARTESIAN_COORDINATES. |
The TS5_DISPLAY_COORDINATES system has the origin (0,0) in the upper left corner of the display and increasing coordinate values to the left of and below the origin.
The TS5_CARTESIAN_COORDINATES system has the origin (0,0) in the center of the display, increasing coordinate values to the left of and above the origin and decreasing (negative) values to the right of and below the origin. This is the default coordinate system.
Definition at line 81 of file graphics.c.
int ts5_get_coordinate_system | ( | ) |
int ts5_set_coordinate_scale | ( | const int | coordinate_scale | ) |
Set the coordinate scale.
coordinate_scale | Coordinate scale to be used. Can be TS5_RELATIVE_COORDINATES and TS5_ABSOLUTE_COORDINATES. Default is TS5_ABSOLUTE_COORDINATES. |
In the TS5_ABSOLUTE_COORDINATES scale coordinates are absolute pixel values. This is the default coordinate scale.
In the TS5_RELATIVE_COORDINATES scale coordinates vary between -1.0 and 1.0 in the TS5_CARTESIAN_COORDINATES system and between 0.0 abd 1.0 in the TS5_DISPLAY_COORDINATES system.
Using the TS5_RELATIVE_COORDINATES scale has an influence on position but also on sizes:
Definition at line 147 of file graphics.c.
int ts5_get_coordinate_scale | ( | ) |
double ts5_relative_to_absolute_coordinate_x | ( | const double | x | ) |
Convert a relative horizontal coordinate into an absolute horizontal coordinate.
This function can be called using the macro ax(x)
x | Horizontal coordinate value as a proportion. |
Its behavior depends on the coordinate system used.
It is possible to call this function as a parameter to a drawing function (e.g.: when using the Cartesian coordinate system, ts5_putpixel (ts5_relative_to_absolute_coordinate_x(.5), 0); writes a pixel 80 pixels to the right of the center in the case of a 320x240 sized display, or 160 pixels to the right in the case of a 640x480 sized display).
Definition at line 208 of file graphics.c.
double ts5_relative_to_absolute_coordinate_y | ( | const double | y | ) |
Convert a relative vertical coordinate into an absolute vertical coordinate.
This function can be called using the macro ay(y)
y | Vertical coordinate value as a proportion. |
Its behaviour completely parallells that of ts5_relative_to_absolute_coordinate_x().
Definition at line 240 of file graphics.c.
double ts5_absolute_to_relative_coordinate_x | ( | const double | x | ) |
Convert an absolute horizontal coordinate into a relative horizontal coordinate.
This function can be called using the macro rx(x)
x | Horizontal coordinate value in pixels. |
Mainly for internal use by Tscope5 itself.
Definition at line 271 of file graphics.c.
double ts5_absolute_to_relative_coordinate_y | ( | const double | y | ) |
Convert an absolute vertical coordinate into a relative vertical coordinate.
This function can be called using the macro ry(y)
y | Vertical coordinate value in pixels. |
Mainly for internal use by Tscope5 itself.
Definition at line 302 of file graphics.c.
double ts5_cartesian_to_display_coordinate_x | ( | const double | x | ) |
Convert a horizontal Cartesian coordinate into a horizontal display coordinate.
This function can be called using the macro dx(x)
x | Horizontal coordinate value in the Cartesian coordinate system. |
Mainly for internal use by Tscope5 itself.
Definition at line 333 of file graphics.c.
double ts5_cartesian_to_display_coordinate_y | ( | const double | y | ) |
Convert a vertical Cartesian coordinate into a vertical display coordinate.
This function can be called using the macro dy(y)
y | Vertical coordinate value in the Cartesian coordinate system. |
Mainly for internal use by Tscope5 itself.
Definition at line 354 of file graphics.c.
double ts5_display_to_cartesian_coordinate_x | ( | const double | x | ) |
Convert a horizontal display coordinate into a horizontal Cartisian coordinate.
This function can be called using the macro cx(x)
x | Horizontal coordinate value in the display coordinate system. |
Mainly for internal use by Tscope5 itself.
Definition at line 375 of file graphics.c.
double ts5_display_to_cartesian_coordinate_y | ( | const double | y | ) |
Convert a vertical display coordinate into a vertical Cartisian coordinate.
This function can be called using the macro cy(y)
y | Vertical coordinate value in the display coordinate system. |
Mainly for internal use by Tscope5 itself.
Definition at line 396 of file graphics.c.
TS5_COLOR ts5_make_rgb_color | ( | const double | r, |
const double | g, | ||
const double | b, | ||
const double | a | ||
) |
Generate a color specification based on an RGB triplet plus an alpha channel.
r | Red. Range from 0.0 to 1.0. |
g | Green. Range from 0.0 to 1.0. |
b | Blue. Range from 0.0 to 1.0. |
a | Alpha. 0.0 is completely transparant and 1.0 is completely opaque. |
Definition at line 436 of file graphics.c.
TS5_COLOR ts5_make_hsl_color | ( | const double | h, |
const double | s, | ||
const double | l, | ||
const double | a | ||
) |
Generate a color specification based on an HSL triplet plus an alpha channel.
h | Hue. Range from 0.0 to 360.0. |
s | Saturation. Range from 0.0 to 1.0. |
l | Lightness. Range from 0.0 to 1.0. |
a | Alpha. 0.0 is completely transparant and 1.0 is completely opaque. |
Definition at line 463 of file graphics.c.
TS5_COLOR ts5_make_hsv_color | ( | const double | h, |
const double | s, | ||
const double | v, | ||
const double | a | ||
) |
Generate a color specification based on an HSV triplet plus an alpha channel.
h | Hue. Range from 0.0 to 360.0. |
s | Saturation. Range from 0.0 to 1.0. |
v | Value Range from 0.0 to 1.0. |
a | Alpha. 0.0 is completely transparant and 1.0 is completely opaque. |
Definition at line 493 of file graphics.c.
TS5_COLOR ts5_make_named_color | ( | const char * | name, |
const double | a | ||
) |
Return a color that corresponds to name.
name | Name of the color. |
a | Alpha. 0.0 is completely transparant and 1.0 is completely opaque. |
There recognized names are: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, goldenrod, gold, gray, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavenderblush, lavender, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgreen, lightgrey, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, avajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, purwablue, red, rosybrown, royalblue, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow and yellowgreen.
Colors are taken from http://www.w3.org/TR/2010/PR-css3-color-20101028/#svg-color.
If the color is not found then black is returned.
Definition at line 549 of file graphics.c.
TS5_COLOR ts5_set_foreground_color | ( | const TS5_COLOR | foreground_color | ) |
Set the foreground color.
foreground_color | TS5_COLOR color specification. |
Changes the drawing color of all subsequent drawing operations. The default color is white. Once a color is set, it remains active until another color is set.
Tscope5 represents colors in an opaque structure (TS5_COLOR). Several functions exist for generating such a color definition (see above).
Definition at line 607 of file graphics.c.
TS5_COLOR ts5_get_foreground_color | ( | ) |
TS5_COLOR ts5_set_background_color | ( | const TS5_COLOR | background_color | ) |
Set the background color.
background_color | TS5_COLOR color specification. |
Changes the background color of all new drawing targets or when a drawing target is cleared.
The default color is black. Once a color is set, it remains active until another color is set.
Definition at line 654 of file graphics.c.
TS5_COLOR ts5_get_background_color | ( | ) |
double ts5_set_drawing_thickness | ( | double | drawing_thickness | ) |
Set the drawing thickness.
drawing_thickness | Drawing thickness in pixels. |
Changes thickness of lines for all drawing operations.
The default thickness is 0 (hairline).
Definition at line 698 of file graphics.c.
double ts5_get_drawing_thickness | ( | ) |
int ts5_set_fill_mode | ( | const int | fill_mode | ) |
Set the fill mode.
fill_mode | Fill mode. Can be TS5_FILL_ON or TS5_FILL_OFF. |
Changes the fill mode for future drawing operations.
The default fill mode is TS5_FILL_OFF.
Definition at line 746 of file graphics.c.
int ts5_get_fill_mode | ( | ) |
int ts5_set_font_type | ( | const int | font_type | ) |
Set the font type.
font_type | Font type. Can be TS5_COURIER, TS5_ARIAL and TS5_TIMES. |
The default font type is TS5_COURIER.
Definition at line 790 of file graphics.c.
int ts5_get_font_type | ( | ) |
int ts5_set_font_style | ( | const int | font_style | ) |
Set the font style.
font_style | Font style. Can be TS5_REGULAR, TS5_BOLD, TS5_ITALIC or TS5_BOLD_ITALIC. |
The default font style is TS5_BOLD.
Definition at line 843 of file graphics.c.
int ts5_get_font_style | ( | ) |
int ts5_set_font_size | ( | int | font_size | ) |
Set the font size.
font_size | Font size. Can be any value between 8 and 107. |
The default font size is 20.
Definition at line 897 of file graphics.c.
int ts5_get_font_size | ( | ) |
Get the font size.
Definition at line 927 of file graphics.c.
int ts5_set_font_index | ( | const int | font_index | ) |
Set the font index.
font_index | Font index. Can be any integer between 0 and TS5_NFONTS-1. |
Sets the font type, style and width at once.
Definition at line 948 of file graphics.c.
int ts5_get_font_index | ( | ) |
int ts5_set_text_alignment | ( | const int | text_alignment | ) |
Set the alignment of text.
text_alignment | Text alignment. Can be TS5_ALIGN_LEFT, TS5_ALIGN_CENTER or TS5_ALIGN_RIGHT. |
The default aligment is TS5_ALIGN_CENTER.
Definition at line 1004 of file graphics.c.
int ts5_get_text_alignment | ( | ) |
Get the alignment of text.
Definition at line 1035 of file graphics.c.