Browse Source

* Documented flip/flop/rotate as being involutive.

* Updated text test.
tags/v0.99.beta14
Sam Hocevar sam 18 years ago
parent
commit
1cdaa755ae
2 changed files with 28 additions and 13 deletions
  1. +10
    -3
      cucul/transform.c
  2. +18
    -10
      test/text.c

+ 10
- 3
cucul/transform.c View File

@@ -55,7 +55,9 @@ int cucul_invert(cucul_canvas_t *cv)
/** \brief Flip a canvas horizontally. /** \brief Flip a canvas horizontally.
* *
* Flip a canvas horizontally, choosing characters that look like the * Flip a canvas horizontally, choosing characters that look like the
* mirrored version wherever possible.
* mirrored version wherever possible. Some characters will stay
* unchanged by the process, but the operation is guaranteed to be
* involutive: performing it again gives back the original canvas.
* *
* This function never fails. * This function never fails.
* *
@@ -112,7 +114,9 @@ int cucul_flip(cucul_canvas_t *cv)
/** \brief Flip a canvas vertically. /** \brief Flip a canvas vertically.
* *
* Flip a canvas vertically, choosing characters that look like the * Flip a canvas vertically, choosing characters that look like the
* mirrored version wherever possible.
* mirrored version wherever possible. Some characters will stay
* unchanged by the process, but the operation is guaranteed to be
* involutive: performing it again gives back the original canvas.
* *
* This function never fails. * This function never fails.
* *
@@ -155,7 +159,10 @@ int cucul_flop(cucul_canvas_t *cv)
/** \brief Rotate a canvas. /** \brief Rotate a canvas.
* *
* Apply a 180-degree transformation to a canvas, choosing characters * Apply a 180-degree transformation to a canvas, choosing characters
* that look like the upside-down version wherever possible.
* that look like the upside-down version wherever possible. Some
* characters will stay unchanged by the process, but the operation is
* guaranteed to be involutive: performing it again gives back the
* original canvas.
* *
* This function never fails. * This function never fails.
* *


+ 18
- 10
test/text.c View File

@@ -24,33 +24,41 @@
#include "cucul.h" #include "cucul.h"


#define STRING \ #define STRING \
"Hello world!\n" \
" _,----._ \n" \ " _,----._ \n" \
" (/ @ @ \\) \n" \ " (/ @ @ \\) \n" \
" | OO | \n" \ " | OO | \n" \
" \\ `--' / \n" \ " \\ `--' / \n" \
" `----' \n"
" `----' \n" \
"Hello world!\n"


int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
cucul_canvas_t *cv;
cucul_canvas_t *cv, *pig;
void *buffer; void *buffer;
unsigned long int len; unsigned long int len;


cv = cucul_create_canvas(0, 0);
pig = cucul_create_canvas(0, 0);
cucul_import_memory(pig, STRING, strlen(STRING), "text");


cucul_import_memory(cv, STRING, strlen(STRING), "text");
cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2,
cucul_get_canvas_height(pig) * 2);


buffer = cucul_export_memory(cv, "utf8", &len);
fwrite(buffer, len, 1, stdout);
free(buffer);

cucul_rotate(cv);
cucul_blit(cv, 0, 0, pig, NULL);
cucul_flip(pig);
cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);
cucul_flip(pig);
cucul_flop(pig);
cucul_blit(cv, 0, cucul_get_canvas_height(pig), pig, NULL);
cucul_flop(pig);
cucul_rotate(pig);
cucul_blit(cv, cucul_get_canvas_width(pig),
cucul_get_canvas_height(pig), pig, NULL);


buffer = cucul_export_memory(cv, "utf8", &len); buffer = cucul_export_memory(cv, "utf8", &len);
fwrite(buffer, len, 1, stdout); fwrite(buffer, len, 1, stdout);
free(buffer); free(buffer);


cucul_free_canvas(pig);
cucul_free_canvas(cv); cucul_free_canvas(cv);


return 0; return 0;


Loading…
Cancel
Save