Compare commits

..

No commits in common. "d73275f04ca0f8c861fa60a073f2ce69a28272d3" and "8275fce9c6834b43641b319e2ae936941036771c" have entirely different histories.

4 changed files with 7 additions and 23 deletions

View File

@ -4,11 +4,8 @@
#include "aliases/aliases.h"
#define square(x) (x * x)
#define absolute(x) (x < 0.0 ? x * -1.0 : x)
i32 min(i32 a, i32 b);
i32 max(i32 a, i32 b);
f64 radians(f64 degrees);
f64 degrees(f64 radians);
#endif // !MATH_UTILS_H

View File

@ -76,6 +76,11 @@ i32 run_main_loop(void) {
i32 toolbox_button_x = (toolbox->width - BUTTON_WIDTH) / 2;
line ln = (line){
(point){80, 100},
(point){120, 300},
};
while (comp.running) {
while (SDL_PollEvent(&(comp.event))) {
handle_ui_events(&(comp.windows[comp.active_window - 1]), &(comp.ctx),
@ -152,6 +157,8 @@ i32 run_main_loop(void) {
comp.nodes[i].colours);
}
ln = ui_noodle(main_window, &(comp.ctx), ln, op_node_colours);
for (u64 i = 0; i < MAX_WINDOWS; ++i) {
swap_buffers(&(comp.windows[i]));
}

View File

@ -1,10 +1,5 @@
#include "math_utils.h"
#include <math.h>
i32 min(i32 a, i32 b) { return a <= b ? a : b; }
i32 max(i32 a, i32 b) { return a >= b ? a : b; }
f64 radians(f64 degrees) { return degrees * M_PI / 180.0; }
f64 degrees(f64 radians) { return radians * 180.0 / M_PI; }

View File

@ -8,10 +8,8 @@
#include <stdlib.h>
#define NOODLE_HALF_WIDTH 2
#define DEFAULT_NOODLE_LENGTH 60
INTERNAL bool aabb(rect rec, i32 x, i32 y);
INTERNAL line line_from_origin(point origin, f64 angle, i32 line_length);
void init_ui_ctx(ui_ctx *ctx) {
*ctx = (ui_ctx){0};
@ -241,16 +239,3 @@ INTERNAL bool aabb(rect rec, i32 x, i32 y) {
return x > rec.topleft.x && x <= rec.topleft.x + rec.w && y > rec.topleft.y &&
y <= rec.topleft.y + rec.h;
}
INTERNAL line line_from_origin(point origin, f64 angle, i32 line_length) {
f64 rad = radians(angle);
f64 direction = angle / absolute(angle) * -1;
i32 adjacent = line_length * cos(rad) * direction; // dx
i32 opposite = line_length * sin(rad) * direction; // dy
return (line){
(point){origin.x + adjacent, origin.y + opposite},
origin,
};
}