summaryrefslogtreecommitdiff
path: root/graphics.c
diff options
context:
space:
mode:
Diffstat (limited to 'graphics.c')
-rw-r--r--graphics.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/graphics.c b/graphics.c
index 3a4138c..d58f0d8 100644
--- a/graphics.c
+++ b/graphics.c
@@ -47,8 +47,6 @@ void draw_selection_cursor(u32 color, f64 x0, f64 y0, f64 width, f64 height, f64
#ifndef GRAPHICS_IMPL_GUARD_
#define GRAPHICS_IMPL_GUARD_
-#include <math.h>
-
f64 min3(f64 a, f64 b, f64 c) {
if (a < b && a < c)
return a;
@@ -157,7 +155,8 @@ i64 char_width(c32 c) {
}
i64 char_spacing(i64 num_chars, c32 *text, i64 index) {
- assert(text != NULL);
+ if (text == NULL)
+ return 0;
if (index < 0 || index + 1 >= num_chars)
return 0;
@@ -172,7 +171,8 @@ i64 char_spacing(i64 num_chars, c32 *text, i64 index) {
}
i64 text_cursor(i64 num_chars, c32 *text) {
- assert(text != NULL);
+ if (text == NULL)
+ return 0;
i64 cursor = 0;
@@ -195,7 +195,8 @@ i64 text_cursor(i64 num_chars, c32 *text) {
}
i64 enum_text_columns(i64 num_chars, c32 *text) {
- assert(text != NULL);
+ if (text == NULL)
+ return 0;
i64 cols = 0;
i64 n = 0;
@@ -228,7 +229,8 @@ i64 enum_text_columns(i64 num_chars, c32 *text) {
}
i64 enum_text_rows(i64 num_chars, c32 *text) {
- assert(text != NULL);
+ if (text == NULL)
+ return 0;
i64 rows = 0;
@@ -243,7 +245,8 @@ i64 enum_text_rows(i64 num_chars, c32 *text) {
}
void draw_text(u32 color, f64 x0, f64 y0, f64 scale_x, f64 scale_y, i64 num_chars, c32 *text) {
- assert(text != NULL);
+ if (text == NULL)
+ return;
f64 x = x0;
f64 y = y0;
@@ -436,8 +439,8 @@ void fill_line(u32 op, u32 color, f64 x0, f64 y0, f64 x1, f64 y1, f64 width) {
}
void draw_text_area(u32 color, f64 x0, f64 y0, f64 width, f64 height, f64 max_scale_x, f64 max_scale_y, i64 num_chars, c32 *text) {
- assert(max_scale_x > 1e-6);
- assert(max_scale_y > 1e-6);
+ if (max_scale_x < 1e-6 || max_scale_y < 1e-6)
+ return;
i64 num_columns = enum_text_columns(num_chars, text);
i64 num_rows = enum_text_rows(num_chars, text);
@@ -457,8 +460,8 @@ void draw_text_area(u32 color, f64 x0, f64 y0, f64 width, f64 height, f64 max_sc
}
void draw_selection_cursor(u32 color, f64 x0, f64 y0, f64 width, f64 height, f64 max_scale_x, f64 max_scale_y, i64 cursor, i64 selection, i64 num_chars, c32 *text) {
- assert(max_scale_x > 1e-6);
- assert(max_scale_y > 1e-6);
+ if (max_scale_x < 1e-6 || max_scale_y < 1e-6)
+ return;
i64 num_columns = enum_text_columns(num_chars, text);
i64 num_rows = enum_text_rows(num_chars, text);