aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-repeat-tessellation.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-07-11 23:27:46 +0200
committerMattias Andrée <maandree@kth.se>2017-07-11 23:27:46 +0200
commit6f4d55793f88540d1b1abd7410e43da83993ad6a (patch)
tree97f11c5731406d5d6b593546bba498001a2f98c6 /src/blind-repeat-tessellation.c
parentblind-spiral-gradient: add -t (diff)
downloadblind-6f4d55793f88540d1b1abd7410e43da83993ad6a.tar.gz
blind-6f4d55793f88540d1b1abd7410e43da83993ad6a.tar.bz2
blind-6f4d55793f88540d1b1abd7410e43da83993ad6a.tar.xz
Add blind-repeat-tessellation
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/blind-repeat-tessellation.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/blind-repeat-tessellation.c b/src/blind-repeat-tessellation.c
new file mode 100644
index 0000000..4e4fc60
--- /dev/null
+++ b/src/blind-repeat-tessellation.c
@@ -0,0 +1,52 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+USAGE("-w width -h height")
+
+int
+main(int argc, char *argv[])
+{
+ struct stream stream;
+ size_t width = 0;
+ size_t height = 0;
+ size_t x, y, p, w;
+ char *buf;
+
+ ARGBEGIN {
+ case 'w':
+ width = etozu_flag('w', UARGF(), 1, SIZE_MAX);
+ break;
+ case 'h':
+ height = etozu_flag('h', UARGF(), 1, SIZE_MAX);
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+ if (!width || !height || argc)
+ usage();
+
+ eopen_stream(&stream, NULL);
+ echeck_dimensions(&stream, WIDTH | HEIGHT, NULL);
+ x = stream.width, stream.width = width;
+ y = stream.height, stream.height = height;
+ fprint_stream_head(stdout, &stream);
+ efflush(stdout, "<stdout>");
+ stream.width = x;
+ stream.height = y;
+ buf = emalloc(stream.frame_size);
+
+ w = width % stream.width;
+ while (eread_frame(&stream, buf)) {
+ for (y = 0; y < height; y++) {
+ p = (y % stream.height) * stream.row_size;
+ for (x = 0; x < width / stream.width; x++)
+ ewriteall(STDOUT_FILENO, buf + p, stream.row_size, "<stdout>");
+ if (w)
+ ewriteall(STDOUT_FILENO, buf + p, w * stream.pixel_size, "<stdout>");
+ }
+ }
+
+ free(buf);
+ return 0;
+}