(wrong string) ée

From: <git_AT_suckless.org>
Date: Thu, 13 Jul 2017 15:28:26 +0200 (CEST)

commit ab3fc0fa703bc112938360c77200bd4ecb6bd503
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Thu Jul 13 04:50:57 2017 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Thu Jul 13 04:50:57 2017 +0200

    Add blind-rectangle-tessellation, blind-triangle-tessellation, and blind-hexagon-tessellation
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/Makefile b/Makefile
index 8c5bc2f..4f2155a 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -36,6 +36,7 @@ BIN =\
         blind-from-video\
         blind-gauss-blur\
         blind-get-colours\
+ blind-hexagon-tessellation\
         blind-interleave\
         blind-invert-luma\
         blind-linear-gradient\
_AT_@ -46,6 +47,7 @@ BIN =\
         blind-premultiply\
         blind-radial-gradient\
         blind-read-head\
+ blind-rectangle-tessellation\
         blind-repeat\
         blind-repeat-tessellation\
         blind-reverse\
_AT_@ -76,6 +78,7 @@ BIN =\
         blind-to-video\
         blind-translate\
         blind-transpose\
+ blind-triangle-tessellation\
         blind-unpremultiply\
         blind-vector-projection\
         blind-write-head\
diff --git a/src/blind-hexagon-tessellation.c b/src/blind-hexagon-tessellation.c
new file mode 100644
index 0000000..f7a4c46
--- /dev/null
+++ b/src/blind-hexagon-tessellation.c
_AT_@ -0,0 +1,108 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+USAGE("[-F pixel-format] block-diameter")
+
+#define SET_XYZA(TYPE)\
+ (pixwidth *= sizeof(double),\
+ colours = alloca(4 * pixwidth),\
+ ((TYPE *)colours)[ 0] = (TYPE)(0.0000 * D65_XYZ_X),\
+ ((TYPE *)colours)[ 1] = (TYPE)(0.0000),\
+ ((TYPE *)colours)[ 2] = (TYPE)(0.0000 * D65_XYZ_Z),\
+ ((TYPE *)colours)[ 3] = (TYPE)1,\
+ ((TYPE *)colours)[ 4] = (TYPE)(0.3333 * D65_XYZ_X),\
+ ((TYPE *)colours)[ 5] = (TYPE)(0.3333),\
+ ((TYPE *)colours)[ 6] = (TYPE)(0.3333 * D65_XYZ_Z),\
+ ((TYPE *)colours)[ 7] = (TYPE)1,\
+ ((TYPE *)colours)[ 8] = (TYPE)(0.6667 * D65_XYZ_X),\
+ ((TYPE *)colours)[ 9] = (TYPE)(0.6667),\
+ ((TYPE *)colours)[10] = (TYPE)(0.6667 * D65_XYZ_Z),\
+ ((TYPE *)colours)[11] = (TYPE)1,\
+ ((TYPE *)colours)[12] = (TYPE)(1.0000 * D65_XYZ_X),\
+ ((TYPE *)colours)[13] = (TYPE)(1.0000),\
+ ((TYPE *)colours)[14] = (TYPE)(1.0000 * D65_XYZ_Z),\
+ ((TYPE *)colours)[15] = (TYPE)1)
+
+static struct stream stream = { .width = 0, .height = 0, .frames = 1 };
+
+int
+main(int argc, char *argv[])
+{
+ size_t diameter;
+ const char *pixfmt = "xyza";
+ size_t pixwidth = 4;
+ char *colours;
+ size_t x, y, y2;
+ int k;
+
+ ARGBEGIN {
+ case 'F':
+ pixfmt = UARGF();
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc != 1)
+ usage();
+
+ diameter = etozu_arg("block-diameter", argv[0], 1, SIZE_MAX);
+
+ pixfmt = get_pixel_format(pixfmt, "xyza");
+ if (!strcmp(pixfmt, "xyza"))
+ SET_XYZA(double);
+ else if (!strcmp(pixfmt, "xyza f"))
+ SET_XYZA(float);
+ else
+ eprintf("pixel format %s is not supported, try xyza\n", pixfmt);
+
+ strcpy(stream.pixfmt, pixfmt);
+ stream.width = (size_t)(diameter * sqrt(3.));
+ stream.height = diameter * 3 / 2;
+ fprint_stream_head(stdout, &stream);
+ efflush(stdout, "<stdout>");
+
+ for (y = 0; y < stream.height; y++) {
+ for (x = 0; x < stream.width; x++) {
+ if (y * 4 < diameter) {
+ switch (x * 4 / stream.width) {
+ case 0:
+ k = 2 * (4 * x * diameter < stream.width * diameter - 4 * y * stream.width);
+ break;
+ case 1:
+ k = 3 * (4 * x * diameter - stream.width * diameter > 4 * y * stream.width);
+ break;
+ case 2:
+ k = 1 + 2 * (3 * diameter * stream.width - 4 * x * diameter > 4 * y * stream.width);
+ break;
+ default:
+ k = 1 + (4 * x * diameter - 3 * stream.width * diameter > 4 * y * stream.width);
+ break;
+ }
+ } else if (y * 4 < diameter * 3) {
+ k = (x * 2 >= stream.width);
+ } else if (y < diameter) {
+ y2 = diameter - y;
+ switch (x * 4 / stream.width) {
+ case 0:
+ k = 2 * (4 * x * diameter < stream.width * diameter - 4 * y2 * stream.width);
+ break;
+ case 1:
+ k = 3 * (4 * x * diameter - stream.width * diameter > 4 * y2 * stream.width);
+ break;
+ case 2:
+ k = 1 + 2 * (3 * diameter * stream.width - 4 * x * diameter > 4 * y2 * stream.width);
+ break;
+ default:
+ k = 1 + (4 * x * diameter - 3 * stream.width * diameter > 4 * y2 * stream.width);
+ break;
+ }
+ } else {
+ k = (stream.width <= x * 4 && x * 4 < stream.width * 3) + 2;
+ }
+ ewriteall(STDOUT_FILENO, colours + k * pixwidth, pixwidth, "<stdout>");
+ }
+ }
+
+ return 0;
+}
diff --git a/src/blind-rectangle-tessellation.c b/src/blind-rectangle-tessellation.c
new file mode 100644
index 0000000..62e335d
--- /dev/null
+++ b/src/blind-rectangle-tessellation.c
_AT_@ -0,0 +1,72 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+USAGE("[-F pixel-format] block-width block-height")
+
+#define SET_XYZA(TYPE)\
+ (pixwidth *= sizeof(double),\
+ colours = alloca(4 * pixwidth),\
+ ((TYPE *)colours)[ 0] = (TYPE)(0.0000 * D65_XYZ_X),\
+ ((TYPE *)colours)[ 1] = (TYPE)(0.0000),\
+ ((TYPE *)colours)[ 2] = (TYPE)(0.0000 * D65_XYZ_Z),\
+ ((TYPE *)colours)[ 3] = (TYPE)1,\
+ ((TYPE *)colours)[ 4] = (TYPE)(0.3333 * D65_XYZ_X),\
+ ((TYPE *)colours)[ 5] = (TYPE)(0.3333),\
+ ((TYPE *)colours)[ 6] = (TYPE)(0.3333 * D65_XYZ_Z),\
+ ((TYPE *)colours)[ 7] = (TYPE)1,\
+ ((TYPE *)colours)[ 8] = (TYPE)(0.6667 * D65_XYZ_X),\
+ ((TYPE *)colours)[ 9] = (TYPE)(0.6667),\
+ ((TYPE *)colours)[10] = (TYPE)(0.6667 * D65_XYZ_Z),\
+ ((TYPE *)colours)[11] = (TYPE)1,\
+ ((TYPE *)colours)[12] = (TYPE)(1.0000 * D65_XYZ_X),\
+ ((TYPE *)colours)[13] = (TYPE)(1.0000),\
+ ((TYPE *)colours)[14] = (TYPE)(1.0000 * D65_XYZ_Z),\
+ ((TYPE *)colours)[15] = (TYPE)1)
+
+static struct stream stream = { .width = 0, .height = 0, .frames = 1 };
+
+int
+main(int argc, char *argv[])
+{
+ size_t width, height;
+ const char *pixfmt = "xyza";
+ size_t pixwidth = 4;
+ char *colours;
+ size_t x1, y1, x2, y2;
+
+ ARGBEGIN {
+ case 'F':
+ pixfmt = UARGF();
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc != 2)
+ usage();
+
+ width = etozu_arg("block-width", argv[0], 1, SIZE_MAX);
+ height = etozu_arg("block-height", argv[1], 1, SIZE_MAX);
+
+ pixfmt = get_pixel_format(pixfmt, "xyza");
+ if (!strcmp(pixfmt, "xyza"))
+ SET_XYZA(double);
+ else if (!strcmp(pixfmt, "xyza f"))
+ SET_XYZA(float);
+ else
+ eprintf("pixel format %s is not supported, try xyza\n", pixfmt);
+
+ strcpy(stream.pixfmt, pixfmt);
+ stream.width = 2 * width;
+ stream.height = 2 * height;
+ fprint_stream_head(stdout, &stream);
+ efflush(stdout, "<stdout>");
+
+ for (y1 = 0; y1 < 2; y1++)
+ for (y2 = 0; y2 < height; y2++)
+ for (x1 = 0; x1 < 2; x1++)
+ for (x2 = 0; x2 < width; x2++)
+ ewriteall(STDOUT_FILENO, colours + (y1 * 2 + x1) * pixwidth, pixwidth, "<stdout>");
+
+ return 0;
+}
diff --git a/src/blind-triangle-tessellation.c b/src/blind-triangle-tessellation.c
new file mode 100644
index 0000000..e4eeb21
--- /dev/null
+++ b/src/blind-triangle-tessellation.c
_AT_@ -0,0 +1,93 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+USAGE("[-F pixel-format] block-width block-height")
+
+#define SET_XYZA(TYPE)\
+ (pixwidth *= sizeof(double),\
+ colours = alloca(8 * pixwidth),\
+ ((TYPE *)colours)[ 0] = (TYPE)0.412457445582367600,\
+ ((TYPE *)colours)[ 1] = (TYPE)0.212673370378408280,\
+ ((TYPE *)colours)[ 2] = (TYPE)0.019333942761673460,\
+ ((TYPE *)colours)[ 3] = (TYPE)1,\
+ ((TYPE *)colours)[ 4] = (TYPE)0.206228722791183800,\
+ ((TYPE *)colours)[ 5] = (TYPE)0.106336685189204140,\
+ ((TYPE *)colours)[ 6] = (TYPE)0.009666971380836730,\
+ ((TYPE *)colours)[ 7] = (TYPE)1,\
+ ((TYPE *)colours)[ 8] = (TYPE)0.770033310827883400,\
+ ((TYPE *)colours)[ 9] = (TYPE)0.927825100869440000,\
+ ((TYPE *)colours)[10] = (TYPE)0.138525897843512050,\
+ ((TYPE *)colours)[11] = (TYPE)1,\
+ ((TYPE *)colours)[12] = (TYPE)0.385016655413941700,\
+ ((TYPE *)colours)[13] = (TYPE)0.463912550434720000,\
+ ((TYPE *)colours)[14] = (TYPE)0.069262948921756020,\
+ ((TYPE *)colours)[15] = (TYPE)1,\
+ ((TYPE *)colours)[16] = (TYPE)0.357575865245515900,\
+ ((TYPE *)colours)[17] = (TYPE)0.715151730491031800,\
+ ((TYPE *)colours)[18] = (TYPE)0.119191955081838600,\
+ ((TYPE *)colours)[19] = (TYPE)1,\
+ ((TYPE *)colours)[20] = (TYPE)0.178787932622757940,\
+ ((TYPE *)colours)[21] = (TYPE)0.357575865245515900,\
+ ((TYPE *)colours)[22] = (TYPE)0.059595977540919300,\
+ ((TYPE *)colours)[23] = (TYPE)1,\
+ ((TYPE *)colours)[24] = (TYPE)(1.0 * D65_XYZ_X),\
+ ((TYPE *)colours)[25] = (TYPE)(1.0),\
+ ((TYPE *)colours)[26] = (TYPE)(1.0 * D65_XYZ_Z),\
+ ((TYPE *)colours)[27] = (TYPE)1,\
+ ((TYPE *)colours)[28] = (TYPE)(0.5 * D65_XYZ_X),\
+ ((TYPE *)colours)[29] = (TYPE)(0.5),\
+ ((TYPE *)colours)[30] = (TYPE)(0.5 * D65_XYZ_Z),\
+ ((TYPE *)colours)[31] = (TYPE)1)
+
+static struct stream stream = { .width = 0, .height = 0, .frames = 1 };
+
+int
+main(int argc, char *argv[])
+{
+ size_t width, height;
+ const char *pixfmt = "xyza";
+ size_t pixwidth = 4;
+ char *colours;
+ size_t x1, y1, x2, y2, k;
+
+ ARGBEGIN {
+ case 'F':
+ pixfmt = UARGF();
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc != 2)
+ usage();
+
+ width = etozu_arg("block-width", argv[0], 1, SIZE_MAX);
+ height = etozu_arg("block-height", argv[1], 1, SIZE_MAX);
+
+ pixfmt = get_pixel_format(pixfmt, "xyza");
+ if (!strcmp(pixfmt, "xyza"))
+ SET_XYZA(double);
+ else if (!strcmp(pixfmt, "xyza f"))
+ SET_XYZA(float);
+ else
+ eprintf("pixel format %s is not supported, try xyza\n", pixfmt);
+
+ strcpy(stream.pixfmt, pixfmt);
+ stream.width = 2 * width;
+ stream.height = 2 * height;
+ fprint_stream_head(stdout, &stream);
+ efflush(stdout, "<stdout>");
+
+ for (y1 = 0; y1 < 2; y1++) {
+ for (y2 = 0; y2 < height; y2++) {
+ for (x1 = 0; x1 < 2; x1++) {
+ for (x2 = 0; x2 < width; x2++) {
+ k = y1 * 4 + x1 * 2 + (x2 * height > y2 * width);
+ ewriteall(STDOUT_FILENO, colours + k * pixwidth, pixwidth, "<stdout>");
+ }
+ }
+ }
+ }
+
+ return 0;
+}
Received on Thu Jul 13 2017 - 15:28:26 CEST

This archive was generated by hypermail 2.3.0 : Thu Jul 13 2017 - 15:36:53 CEST