KolibriLib
Loading...
Searching...
No Matches
graphic.hpp
1#ifndef __GRAPHIC_H__
2#define __GRAPHIC_H__
3
4
5#include <sys/ksys.h>
6#include <stdio.h>
7#include <stdlib.h>
8#include <string.h>
9
10#include <math.h>
11
12#include "base.hpp"
13
14namespace KolibriLib
15{
16 // Графика
17 namespace graphic
18 {
22 inline void DrawLine(point a, point b, ksys_color_t color = OS::sys_color_table.work_graph)
23 {
24 _ksys_draw_line(a.x, a.y, b.x, b.y, color);
25 }
26
30 inline void DrawPixel(point position, ksys_color_t color)
31 {
32 _ksys_draw_pixel(position.x, position.y, color);
33 }
34
40 void DrawCircle(point coord, unsigned Radius, unsigned detalization = 36, ksys_color_t color = OS::sys_color_table.work_graph)
41 {
42 point buff;
43 unsigned b = Radius;
44 unsigned c = 0;
45 for (unsigned angle = 1; angle <= detalization * 10; angle += 36 / detalization)
46 {
47 buff = {coord.x + b, coord.y + c};
48 b = Radius * cos(angle);
49 c = sqrt((Radius*Radius) - (b*b));
50 point n = {coord.x + b, coord.y + c};
51 DrawLine(buff, n);
52 }
53 }
54
59 void DrawRectangleFill(point position, point size, ksys_color_t color = OS::sys_color_table.work_graph)
60 {
61 position.x *= AAANUMBER;
62 position.y *= AAANUMBER;
63
64 __asm__ __volatile__(
65 "int $0x40" ::"a"(13), "b"(position.x + size.x), "c"(position.y + size.y), "d"(color));
66 }
67
72 void DrawCircleFill(point coord, unsigned Radius, ksys_color_t color = OS::sys_color_table.work_graph)
73 {
74 DrawCircle(coord, Radius, color);
75 unsigned b = Radius * cos(90+45);
76 unsigned c = sqrt((Radius * Radius) - (b * b));
77 point n = {coord.x + b, coord.y + c};
78 DrawRectangleFill(n, {(coord.x - n.x) * 2, c * 2}, color);
79 for (unsigned i = Radius; i > (Radius -(coord.x - n.x)); i--)//Дозакрашивание пробелов между квадратом и границами груга
80 {
81 DrawCircle(coord, i, NULL, color);
82 }
83 }
84
90 void DrawPoint(point position, unsigned size, ksys_color_t color = OS::sys_color_table.work_graph, bool a = false)
91 {
92 if(size < 3)
93 {
94 a = true;
95 }
96 if (a)
97 {
98 DrawCircle(position, size, color);
99 }
100 else
101 {
102 DrawCircleFill(position, size, color);
103 }
104 }
105
106
110 void DrawRectangleLines(point a, point b, ksys_color_t color = OS::sys_color_table.work_graph)
111 {
112 DrawLine(a, {b.x, a.y}, color);
113 DrawLine(a, {a.x, b.y}, color);
114 DrawLine({b.x, a.y}, b, color);
115 DrawLine({a.x, b.y}, b, color);
116 }
117
118
119
125 inline void DrawTriangle(point a, point b, point c, ksys_color_t color = OS::sys_color_table.work_graph)
126 {
127 DrawLine(a, b, color);
128 DrawLine(a, c, color);
129 DrawLine(b, c, color);
130 }
131 }
132} // namespace KolibriLib
133
134
135#endif // __GRAPHIC_H__
ksys_colors_table_t sys_color_table
Таблица стандартных(системных) цветов
Definition base.hpp:37
Основное пространство имён
Definition base.hpp:17