11 #include "../include/tscope5/primitives.h"
12 #include "../include/tscope5/graphics.h"
13 #include "../include/tscope5/primitives_internal.h"
14 #include "../include/tscope5/system_internal.h"
15 #include "../include/tscope5/graphics_internal.h"
17 #include <allegro5/allegro_primitives.h>
36 ts5_check_primitives(
"ts5_draw_pixel");
37 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_pixel(%f,%f)\n", x, y);
39 if (_ts5_status.graphics_status.coordinate_scale == TS5_RELATIVE_COORDINATES) {
44 if (_ts5_status.graphics_status.coordinate_system == TS5_CARTESIAN_COORDINATES) {
49 if (_ts5_status.graphics_status.drawing_thickness <= 0.0) {
50 al_draw_pixel(x, y, _ts5_status.graphics_status.foreground_color);
53 al_draw_filled_circle(x, y, _ts5_status.graphics_status.drawing_thickness,
54 _ts5_status.graphics_status.foreground_color);
70 ts5_check_primitives(
"ts5_get_pixel_color");
71 ts5_log(TS5_LOGLEVEL_5,
"ts5_get_pixel_color(%f,%f)\n", x, y);
73 if (_ts5_status.graphics_status.coordinate_scale == TS5_RELATIVE_COORDINATES) {
78 if (_ts5_status.graphics_status.coordinate_system == TS5_CARTESIAN_COORDINATES) {
83 return (al_get_pixel(_ts5_status.target, x, y));
97 ts5_check_primitives(
"ts5_draw_line");
98 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_line(%f,%f,%f,%f)\n", x1, y1, x2, y2);
100 if (_ts5_status.graphics_status.coordinate_scale == TS5_RELATIVE_COORDINATES) {
107 if (_ts5_status.graphics_status.coordinate_system == TS5_CARTESIAN_COORDINATES) {
114 al_draw_line(x1, y1, x2, y2, _ts5_status.graphics_status.foreground_color,
115 _ts5_status.graphics_status.drawing_thickness);
129 ts5_check_primitives(
"ts5_draw_rectangle");
130 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_rectangle(%f,%f,%f,%f)\n", x1, y1, x2, y2);
132 if (_ts5_status.graphics_status.coordinate_scale == TS5_RELATIVE_COORDINATES) {
139 if (_ts5_status.graphics_status.coordinate_system == TS5_CARTESIAN_COORDINATES) {
146 if (!_ts5_status.graphics_status.fill_mode) {
147 al_draw_rectangle(x1, y1, x2, y2, _ts5_status.graphics_status.foreground_color,
148 _ts5_status.graphics_status.drawing_thickness);
151 al_draw_filled_rectangle(x1, y1, x2, y2, _ts5_status.graphics_status.foreground_color);
168 ts5_check_primitives(
"ts5_draw_rounded_rectangle");
169 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_rounded_rectangle(%f,%f,%f,%f,%f,%f)\n", x1, y1, x2, y2, rx, ry);
171 if (_ts5_status.graphics_status.coordinate_scale == TS5_RELATIVE_COORDINATES) {
180 if (_ts5_status.graphics_status.coordinate_system == TS5_CARTESIAN_COORDINATES) {
212 if (!_ts5_status.graphics_status.fill_mode) {
213 al_draw_rounded_rectangle(x1, y1, x2, y2, rx, ry,
214 _ts5_status.graphics_status.foreground_color,
215 _ts5_status.graphics_status.drawing_thickness);
218 al_draw_filled_rounded_rectangle(x1, y1, x2, y2, rx, ry,
219 _ts5_status.graphics_status.foreground_color);
236 ts5_check_primitives(
"ts5_draw_triangle");
237 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_triangle(%f,%f,%f,%f,%f,%f)\n", x1, y1, x2, y2, x3, y3);
239 if (_ts5_status.graphics_status.coordinate_scale == TS5_RELATIVE_COORDINATES) {
248 if (_ts5_status.graphics_status.coordinate_system == TS5_CARTESIAN_COORDINATES) {
257 if (!_ts5_status.graphics_status.fill_mode) {
258 al_draw_triangle(x1, y1, x2, y2, x3, y3,
259 _ts5_status.graphics_status.foreground_color,
260 _ts5_status.graphics_status.drawing_thickness);
263 al_draw_filled_triangle(x1, y1, x2, y2, x3, y3, _ts5_status.graphics_status.foreground_color);
277 ts5_check_primitives(
"ts5_draw_circle");
278 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_circle(%f,%f,%f)\n", cx, cy, r);
280 if (_ts5_status.graphics_status.coordinate_scale == TS5_RELATIVE_COORDINATES) {
286 if (_ts5_status.graphics_status.coordinate_system == TS5_CARTESIAN_COORDINATES) {
291 if (!_ts5_status.graphics_status.fill_mode) {
292 al_draw_circle(cx, cy, r, _ts5_status.graphics_status.foreground_color,
293 _ts5_status.graphics_status.drawing_thickness);
296 al_draw_filled_circle(cx, cy, r, _ts5_status.graphics_status.foreground_color);
311 ts5_check_primitives(
"ts5_draw_ellipse");
312 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_ellipse(%f,%f,%f,%f)\n", cx, cy, rx, ry);
314 if (_ts5_status.graphics_status.coordinate_scale == TS5_RELATIVE_COORDINATES) {
321 if (_ts5_status.graphics_status.coordinate_system == TS5_CARTESIAN_COORDINATES) {
326 if (!_ts5_status.graphics_status.fill_mode) {
327 al_draw_ellipse(cx, cy, rx, ry, _ts5_status.graphics_status.foreground_color,
328 _ts5_status.graphics_status.drawing_thickness);
331 al_draw_filled_ellipse(cx, cy, rx, ry, _ts5_status.graphics_status.foreground_color);
345 void ts5_draw_arc(
double cx,
double cy,
double r,
double start,
double delta)
347 ts5_check_primitives(
"ts5_draw_arc");
348 ts5_log(TS5_LOGLEVEL_5,
"ts5_draw_arc(%f,%f,%f,%f,%f)\n", cx, cy, r, start, delta);
350 if (_ts5_status.graphics_status.coordinate_scale == TS5_RELATIVE_COORDINATES) {
356 if (_ts5_status.graphics_status.coordinate_system == TS5_CARTESIAN_COORDINATES) {
361 start = start * TS5_PI / 180;
362 delta = delta * TS5_PI / 180;
363 al_draw_arc(cx, cy, r, start, delta, _ts5_status.graphics_status.foreground_color,
364 _ts5_status.graphics_status.drawing_thickness);