summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Doxyfile2
-rw-r--r--lib/hitomezashi.c2
-rw-r--r--lib/hitomezashi.h9
-rw-r--r--lib/hitomezashi_utils.c22
-rw-r--r--lib/hitomezashi_utils.h17
5 files changed, 43 insertions, 9 deletions
diff --git a/lib/Doxyfile b/lib/Doxyfile
index e370a72..834117d 100644
--- a/lib/Doxyfile
+++ b/lib/Doxyfile
@@ -477,7 +477,7 @@ NUM_PROC_THREADS = 1
# normally produced when WARNINGS is set to YES.
# The default value is: NO.
-EXTRACT_ALL = NO
+EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
# be included in the documentation.
diff --git a/lib/hitomezashi.c b/lib/hitomezashi.c
index 66f7440..c87073f 100644
--- a/lib/hitomezashi.c
+++ b/lib/hitomezashi.c
@@ -1,5 +1,5 @@
#include "hitomezashi.h"
-#include "SDL.h"
+#include "SDL2/SDL.h"
#include <assert.h>
SDL_Color HITOMEZASHI_FG_COLOUR = {.r = 0, .g = 0, .b = 0};
diff --git a/lib/hitomezashi.h b/lib/hitomezashi.h
index 4453f70..64b17af 100644
--- a/lib/hitomezashi.h
+++ b/lib/hitomezashi.h
@@ -3,14 +3,12 @@
#ifndef HITOMEZASHI_HITOMEZASHI_H
#define HITOMEZASHI_HITOMEZASHI_H
-#include "SDL.h"
+#include "SDL2/SDL.h"
/** The state of a hitomezashi pattern.
*/
struct Hitomezashi_State {
- /** The length of the x_pattern. */
int x_pattern_len;
- /** The length of the y_pattern. */
int y_pattern_len;
/** Pattern used to draw the vertical lines conceptually originating from the
@@ -25,7 +23,6 @@ struct Hitomezashi_State {
/** Gap between parallel lines. */
int gap;
- /** Thickness of each line. */
int line_thickness;
/** Width in pixels of the SDL_Surface needed to hold the pattern. This is
@@ -41,7 +38,6 @@ struct Hitomezashi_State {
/** Result of hitomezashi_state_init(). */
enum Hitomezashi_State_Init_Result {
- /** The function completed successfully. */
Hitomezashi_State_Init_Result_Success,
/** The function failed as it encountered an error initialising the
SDL_Surface in state. */
@@ -50,7 +46,6 @@ enum Hitomezashi_State_Init_Result {
/** Result of hitomezashi_draw() */
enum Hitomezashi_Draw_Result {
- /** The function completed successfully. */
Hitomezashi_Draw_Result_Success,
/** The function failed as it encountered an error "locking" the surface to
write to it. */
@@ -64,7 +59,7 @@ hitomezashi_state_init(struct Hitomezashi_State *state, int x_pattern_len,
int y_pattern_len, char *x_pattern, char *y_pattern,
int gap, int line_thickness);
-/** Draw the hitomezashi pattern to a Hitomezashi_State's surface. */
+/** Draw the hitomezashi pattern to state->surface. */
enum Hitomezashi_Draw_Result hitomezashi_draw(struct Hitomezashi_State *state);
#endif // HITOMEZASHI_HITOMEZASHI_H
diff --git a/lib/hitomezashi_utils.c b/lib/hitomezashi_utils.c
new file mode 100644
index 0000000..32832de
--- /dev/null
+++ b/lib/hitomezashi_utils.c
@@ -0,0 +1,22 @@
+#include "hitomezashi_utils.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+
+char *hitomezashi_ascii_binary_str_to_ints(char *ascii_str, size_t len) {
+ char *res = malloc(len);
+ for (int i = 0; i < len; ++i) {
+ switch (ascii_str[i]) {
+ case '0':;
+ res[i] = 0;
+ break;
+ case '1':;
+ res[i] = 1;
+ break;
+ default:;
+ free(res);
+ return NULL;
+ }
+ }
+ return res;
+}
diff --git a/lib/hitomezashi_utils.h b/lib/hitomezashi_utils.h
new file mode 100644
index 0000000..040ea00
--- /dev/null
+++ b/lib/hitomezashi_utils.h
@@ -0,0 +1,17 @@
+/** @file
+ * Utilities connected with hitomezashi patterns that may be useful to
+ * applications.
+ */
+#ifndef HITOMEZASHI_UTILS_H
+#define HITOMEZASHI_UTILS_H
+
+#include <stddef.h>
+
+/** Convert a string of ASCII digit 0s and 1s, eg. "1010", to a char array of
+ * numeric 0s and 1s. The return value is **dynamically allocated and must
+ * be freed**.
+ * @param len Length of ascii_str, not including any terminating null bytes.
+ */
+char *hitomezashi_ascii_binary_str_to_ints(char *ascii_str, size_t len);
+
+#endif // HITOMEZASHI_UTILS_H