diff options
Diffstat (limited to 'src/background.c')
-rw-r--r-- | src/background.c | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/src/background.c b/src/background.c index 4d17af3..c3b7e62 100644 --- a/src/background.c +++ b/src/background.c @@ -1,45 +1,13 @@ #include "lzy.h" #include "cfg.h" -#include <math.h> +#include "rotrect.h" static long tick = 0; static void -rotate(double *x, double *y, double angle) +draw_square(double size, double angle) { - const double s = sin(angle); - const double c = cos(angle); - const double ox = *x; - const double oy = *y; - - *x = ox * c - oy * s; - *y = ox * s + oy * c; -} - -static void -draw_square(int size, double angle) -{ - double x[4] = { - size / 2.0, - size / 2.0, - -size / 2.0, - -size / 2.0, - }; - double y[4] = { - -size / 2.0, - size / 2.0, - size / 2.0, - -size / 2.0, - }; - for (int i = 0; i < 4; i++) { - rotate(&x[i], &y[i], angle); - x[i] += DISPLAY_WIDTH / 2.0; - y[i] += DISPLAY_HEIGHT / 2.0; - } - LZY_DrawLine(x[0], y[0], x[1], y[1]); - LZY_DrawLine(x[1], y[1], x[2], y[2]); - LZY_DrawLine(x[2], y[2], x[3], y[3]); - LZY_DrawLine(x[3], y[3], x[0], y[0]); + rotrect(DISPLAY_WIDTH / 2.0, DISPLAY_HEIGHT / 2.0, size, size, angle); } void |