diff options
author | untir_l <87096069+untir-l@users.noreply.github.com> | 2022-02-18 14:05:08 +0000 |
---|---|---|
committer | untir-l <87096069+untir-l@users.noreply.github.com> | 2022-02-25 09:56:49 +0000 |
commit | 581bc2dd768ca0af390b9abb41a5c89f1bca19e3 (patch) | |
tree | 2b8ef613b6448099852c9bf3487915c13d3ceea7 /lib/hitomezashi.h | |
parent | 1bc2a436583b0e898decf13e695a1908a894a38c (diff) | |
download | hitomezashi-581bc2dd768ca0af390b9abb41a5c89f1bca19e3.tar hitomezashi-581bc2dd768ca0af390b9abb41a5c89f1bca19e3.tar.gz hitomezashi-581bc2dd768ca0af390b9abb41a5c89f1bca19e3.zip |
Reorganise CLI and lib into separate dirs, add doc comments for Doxygen
Diffstat (limited to 'lib/hitomezashi.h')
-rw-r--r-- | lib/hitomezashi.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/hitomezashi.h b/lib/hitomezashi.h new file mode 100644 index 0000000..4453f70 --- /dev/null +++ b/lib/hitomezashi.h @@ -0,0 +1,70 @@ +/** @file */ + +#ifndef HITOMEZASHI_HITOMEZASHI_H +#define HITOMEZASHI_HITOMEZASHI_H + +#include "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 + * x axis. This is an array of 0s and 1s. + */ + char *x_pattern; + /** Pattern used to draw the horizontal lines conceptually originating from + * the y axis. This is an array of 0s and 1s. + */ + char *y_pattern; + + /** 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 + * calculated by hitomezashi_state_init(). */ + int output_width; + /** Height in pixels of the SDL_Surface needed to hold the pattern. This is + * calculated by hitomezashi_state_init(). */ + int output_height; + + /** SDL_Surface the pattern is drawn to by hitomezashi_draw(). */ + SDL_Surface *surface; +}; + +/** 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. */ + Hitomezashi_State_Init_Result_Err_Create_Surface, +}; + +/** 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. */ + Hitomezashi_Draw_Result_Err_Lock_Surface, +}; + +/** Initialise a Hitomezashi_State struct so that it is ready to be passed to + * hitomezashi_draw(). */ +enum Hitomezashi_State_Init_Result +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. */ +enum Hitomezashi_Draw_Result hitomezashi_draw(struct Hitomezashi_State *state); + +#endif // HITOMEZASHI_HITOMEZASHI_H |