19 #include "../include/tscope5/primitives.h"
20 #include "../include/tscope5/graphics.h"
21 #include "../include/tscope5/primitives_internal.h"
22 #include "../include/tscope5/system_internal.h"
23 #include "../include/tscope5/graphics_internal.h"
25 #include <allegro5/allegro_primitives.h>
46 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_pixel(%f,%f)\n", x, y);
48 if (_ts5_status.graphics.coordinate_scale
49 == TS5_RELATIVE_COORDINATES) {
54 if (_ts5_status.graphics.coordinate_system
55 == TS5_CARTESIAN_COORDINATES) {
60 if (_ts5_status.graphics.drawing_thickness <= 0.0) {
61 al_draw_pixel(x, y, _ts5_status.graphics.foreground_color);
64 al_draw_filled_circle(x, y,
65 _ts5_status.graphics.drawing_thickness,
66 _ts5_status.graphics.foreground_color);
83 ts5_log(TS5_LOGLEVEL_5,
"ts5_get_pixel_color(%f,%f)\n", x, y);
85 if (_ts5_status.graphics.coordinate_scale
86 == TS5_RELATIVE_COORDINATES) {
91 if (_ts5_status.graphics.coordinate_system
92 == TS5_CARTESIAN_COORDINATES) {
97 return (al_get_pixel(_ts5_data.target, x, y));
112 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_line(%f,%f,%f,%f)\n", x1, y1, x2, y2);
114 if (_ts5_status.graphics.coordinate_scale
115 == TS5_RELATIVE_COORDINATES) {
122 if (_ts5_status.graphics.coordinate_system
123 == TS5_CARTESIAN_COORDINATES) {
130 al_draw_line(x1, y1, x2, y2, _ts5_status.graphics.foreground_color,
131 _ts5_status.graphics.drawing_thickness);
146 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_rectangle(%f,%f,%f,%f)\n",
149 if (_ts5_status.graphics.coordinate_scale
150 == TS5_RELATIVE_COORDINATES) {
157 if (_ts5_status.graphics.coordinate_system
158 == TS5_CARTESIAN_COORDINATES) {
165 if (!_ts5_status.graphics.fill_mode) {
166 al_draw_rectangle(x1, y1, x2, y2,
167 _ts5_status.graphics.foreground_color,
168 _ts5_status.graphics.drawing_thickness);
171 al_draw_filled_rectangle(x1, y1, x2, y2,
172 _ts5_status.graphics.foreground_color);
188 double rx,
double ry)
191 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_rounded_rectangle(%f,%f,%f,%f,%f,%f)\n",
192 x1, y1, x2, y2, rx, ry);
194 if (_ts5_status.graphics.coordinate_scale
195 == TS5_RELATIVE_COORDINATES) {
204 if (_ts5_status.graphics.coordinate_system
205 == TS5_CARTESIAN_COORDINATES) {
237 if (!_ts5_status.graphics.fill_mode) {
238 al_draw_rounded_rectangle(x1, y1, x2, y2, rx, ry,
239 _ts5_status.graphics.foreground_color,
240 _ts5_status.graphics.drawing_thickness);
243 al_draw_filled_rounded_rectangle(x1, y1, x2, y2, rx, ry,
244 _ts5_status.graphics.foreground_color);
260 double x3,
double y3)
263 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_triangle(%f,%f,%f,%f,%f,%f)\n",
264 x1, y1, x2, y2, x3, y3);
266 if (_ts5_status.graphics.coordinate_scale
267 == TS5_RELATIVE_COORDINATES) {
276 if (_ts5_status.graphics.coordinate_system
277 == TS5_CARTESIAN_COORDINATES) {
286 if (!_ts5_status.graphics.fill_mode) {
287 al_draw_triangle(x1, y1, x2, y2, x3, y3,
288 _ts5_status.graphics.foreground_color,
289 _ts5_status.graphics.drawing_thickness);
292 al_draw_filled_triangle(x1, y1, x2, y2, x3, y3,
293 _ts5_status.graphics.foreground_color);
308 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_circle(%f,%f,%f)\n", cx, cy, r);
310 if (_ts5_status.graphics.coordinate_scale
311 == TS5_RELATIVE_COORDINATES) {
317 if (_ts5_status.graphics.coordinate_system
318 == TS5_CARTESIAN_COORDINATES) {
323 if (!_ts5_status.graphics.fill_mode) {
324 al_draw_circle(cx, cy, r, _ts5_status.graphics.foreground_color,
325 _ts5_status.graphics.drawing_thickness);
328 al_draw_filled_circle(cx, cy, r,
329 _ts5_status.graphics.foreground_color);
345 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_ellipse(%f,%f,%f,%f)\n", cx, cy, rx, ry);
347 if (_ts5_status.graphics.coordinate_scale
348 == TS5_RELATIVE_COORDINATES) {
355 if (_ts5_status.graphics.coordinate_system
356 == TS5_CARTESIAN_COORDINATES) {
361 if (!_ts5_status.graphics.fill_mode) {
362 al_draw_ellipse(cx, cy, rx, ry,
363 _ts5_status.graphics.foreground_color,
364 _ts5_status.graphics.drawing_thickness);
367 al_draw_filled_ellipse(cx, cy, rx, ry,
368 _ts5_status.graphics.foreground_color);
383 void ts5_draw_arc(
double cx,
double cy,
double r,
double start,
double delta)
386 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_arc(%f,%f,%f,%f,%f)\n",
387 cx, cy, r, start, delta);
389 if (_ts5_status.graphics.coordinate_scale
390 == TS5_RELATIVE_COORDINATES) {
396 if (_ts5_status.graphics.coordinate_system
397 == TS5_CARTESIAN_COORDINATES) {
402 start = - start * TS5_PI / 180;
403 delta = - delta * TS5_PI / 180;
404 al_draw_arc(cx, cy, r, start, delta,
405 _ts5_status.graphics.foreground_color,
406 _ts5_status.graphics.drawing_thickness);
void ts5_draw_pixel(double x, double y)
Draw a pixel.
void ts5_draw_rectangle(double x1, double y1, double x2, double y2)
Draw a rectangle.
void ts5_check_primitives(char *calling_function)
Do some checks at the start of each primitives function.
void ts5_draw_rounded_rectangle(double x1, double y1, double x2, double y2, double rx, double ry)
Draw a rounded rectangle.
double ts5_relative_to_absolute_coordinate_x(const double x)
Convert a relative horizontal coordinate into an absolute horizontal coordinate.
void ts5_draw_ellipse(double cx, double cy, double rx, double ry)
Draw an ellipse.
TS5_COLOR ts5_get_pixel_color(double x, double y)
Get the color of a pixel.
void ts5_draw_circle(double cx, double cy, double r)
Draw a circle.
void ts5_log(const unsigned int level, const char *format,...)
Send info to a logging window.
double ts5_cartesian_to_display_coordinate_x(const double x)
Convert a horizontal Cartesian coordinate into a horizontal display coordinate.
double ts5_cartesian_to_display_coordinate_y(const double y)
Convert a vertical Cartesian coordinate into a vertical display coordinate.
void ts5_draw_arc(double cx, double cy, double r, double start, double delta)
Draw an arc.
void ts5_draw_triangle(double x1, double y1, double x2, double y2, double x3, double y3)
Draw a triangle.
void ts5_draw_line(double x1, double y1, double x2, double y2)
Draw a line segment.
double ts5_relative_to_absolute_coordinate_y(const double y)
Convert a relative vertical coordinate into an absolute vertical coordinate.