aboutsummaryrefslogtreecommitdiffstats
path: root/7_2/include
diff options
context:
space:
mode:
Diffstat (limited to '7_2/include')
-rw-r--r--7_2/include/common.h32
-rw-r--r--7_2/include/drawable.h55
-rw-r--r--7_2/include/figure.h56
-rw-r--r--7_2/include/input.h24
4 files changed, 0 insertions, 167 deletions
diff --git a/7_2/include/common.h b/7_2/include/common.h
deleted file mode 100644
index 660532f..0000000
--- a/7_2/include/common.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef JAC_COMMON_H
-#define JAC_COMMON_H
-
-/* Для чтающих:
- * чтобы писать
- * `vector2 point = { 10, 20 };`
- * вместо
- * `struct vector2 point = { 10, 20 };`
- * (то есть чтобы писать struct перед vector2 было необязательно)
- * надо объявлять структуру так:
- * ```
- * typedef struct {
- * long x, y;
- * } vector2;
- * ```
- * Таким образом мы объявляем структуру без официального названия,
- * но присваиваем ей синоним. Чтобы пользоваться и тем, и тем вариантами,
- * можно сделать так:
- * ```
- * typedef struct vector2 {
- * long x, y;
- * } vector2;
- * ```
- * Так мы и даём ей название, и даём ей синоним.
- */
-
-// координаты точки в 2-мерном пространстве
-typedef struct vector2 {
- long x, y;
-} vector2;
-
-#endif // JAC_COMMON_H
diff --git a/7_2/include/drawable.h b/7_2/include/drawable.h
deleted file mode 100644
index 8986342..0000000
--- a/7_2/include/drawable.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef JCG_DRAWABLE_H
-#define JCG_DRAWABLE_H
-
-#define FILL_CHR '#'
-#define SPACE_CHR ' '
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-extern struct X11context {
- enum {CTX_NO, CTX_INIT, CTX_FAIL} init;
- Display *d;
- Window r, w;
- int s;
- GC gctx;
- XVisualInfo v;
- XImage *i;
- int* data;
-} X11;
-
-// что угодно, на чём можно ''нарисовать''
-// должно иметь размер, размер пикселей, данные
-// функция put записывает пиксель по координатам x, y на поле
-// функция show выводит данные на экран/куда угодно ещё
-struct drawable {
- long x, y, pix_s;
- void *data;
- void (*put)(struct drawable *self, long x, long y);
- void(*show)(const struct drawable *self);
-};
-
-
-// конструктор
-void drawable_init(struct drawable* self,
- void(*put_f)(struct drawable *, long, long),
- void(*show_f)(const struct drawable *),
- long width,
- long height,
- long pix_s);
-// деструктор
-void drawable_destroy(struct drawable *self);
-// конструктор для консольного поля
-struct drawable drawable_plaintxt(long width, long height);
-// конструктор для графического поля
-struct drawable drawable_X11(long width, long height);
-
-// put для консольного drawable
-void put_plaintxt(struct drawable *self, long x, long y);
-// show для консольного drawable
-void show_plaintxt(const struct drawable *self);
-// put для графического drawable
-void put_X11(struct drawable *self, long x, long y);
-// show для графического drawable
-void show_X11(const struct drawable *self);
-
-#endif // JCG_DRAWABLE_H
diff --git a/7_2/include/figure.h b/7_2/include/figure.h
deleted file mode 100644
index 393ca00..0000000
--- a/7_2/include/figure.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef JCG_FIGURE_H
-#define JCG_FIGURE_H
-
-#include "drawable.h"
-#include "common.h"
-
-// любая фигура
-// создаётся функциями figure_point, figure_line и т.д.
-// у каждой фигуры должен быть способ "нарисоваться" на
-// любое "рисовальное" поле, используя функцию drawable.put
-struct figure {
- enum {
- F_NONE, F_POINT, F_RECT, F_LINE, F_CIRCLE
- } type;
- union {
- struct {
- vector2 coords;
- } point;
- struct {
- vector2 upleft, downright;
- } rect;
- struct {
- vector2 start, end;
- } line;
- struct {
- vector2 center;
- long rad;
- } circle;
- };
- void (*draw)(const struct figure *self, struct drawable *d);
-};
-
-// массив функций по типам (lookup table)
-extern void (*const draw_lookup[])(const struct figure *, struct drawable *);
-
-// конструктор 1
-struct figure figure_point(vector2 p);
-// конструктор 2
-struct figure figure_rect(vector2 upleft, vector2 downright);
-// конструктор 3
-struct figure figure_line(vector2 start, vector2 end);
-// конструктор 4
-struct figure figure_circle(vector2 center, long radius);
-
-// draw для F_POINT
-void draw_point(const struct figure *self, struct drawable *d);
-// draw для F_RECT
-void draw_rect(const struct figure *self, struct drawable *d);
-// draw для F_LINE
-void draw_line(const struct figure *self, struct drawable *d);
-// draw для F_CIRCLE
-void draw_circle(const struct figure *self, struct drawable *f);
-
-void print_figure(const struct figure *self);
-
-#endif // JCG_FIGURE_H
diff --git a/7_2/include/input.h b/7_2/include/input.h
deleted file mode 100644
index 24285b8..0000000
--- a/7_2/include/input.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef JAC_INPUT_H
-#define JAC_INPUT_H
-
-#include "common.h"
-#include "figure.h"
-
-extern void(*settings_handler)(const char *sett_string);
-
-// пропустить пробелы
-void skipw(char const **s);
-// проспустит цифры
-void skipd(char const **s);
-// проерить наличие символа
-char chktok(char const **str, char tok);
-// прочитать число
-char parsel(char const **str, long *l);
-// прочитать вектор из 2 чисел
-char parsev(char const **str, vector2 *v);
-// прочитать одну фигуру
-struct figure read_figure(const char *str);
-// прочитать целый файл
-struct figure *read_file(const char *path);
-
-#endif // JAC_INPUT_H