aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-sinus-wave.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-07-03 14:30:44 +0200
committerMattias Andrée <maandree@kth.se>2017-07-03 14:30:44 +0200
commit56ed14063c8b2c82d5ea0652028f47f76cb710f0 (patch)
tree7a156516993dfed31a6356e36d5c5e692605963c /src/blind-sinus-wave.c
parentblind-spiral-gradient: add support for superelliptic sprials (diff)
downloadblind-56ed14063c8b2c82d5ea0652028f47f76cb710f0.tar.gz
blind-56ed14063c8b2c82d5ea0652028f47f76cb710f0.tar.bz2
blind-56ed14063c8b2c82d5ea0652028f47f76cb710f0.tar.xz
Document blind-coordinate-field, blind-*-gradient, and blind-*-wave (sinc still pending), and sinus => sine
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-sinus-wave.c')
-rw-r--r--src/blind-sinus-wave.c94
1 files changed, 0 insertions, 94 deletions
diff --git a/src/blind-sinus-wave.c b/src/blind-sinus-wave.c
deleted file mode 100644
index 7e3cc5a..0000000
--- a/src/blind-sinus-wave.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#include "common.h"
-
-USAGE("[-e]")
-
-static int equal = 0;
-
-
-#define PROCESS(TYPE, SUFFIX)\
- static void\
- process_##SUFFIX(struct stream *stream)\
- {\
- size_t i, n;\
- TYPE x, y, z, a;\
- do {\
- n = stream->ptr / stream->pixel_size;\
- if (equal) {\
- for (i = 0; i < n; i++) {\
- a = ((TYPE *)(stream->buf))[4 * i + 3];\
- a = posmod(a, (TYPE)2);\
- a = a > 1 ? 2 - a : a;\
- a = 1 - (cos(a * (TYPE)M_PI) + 1) / 2;\
- ((TYPE *)(stream->buf))[4 * i + 0] = a;\
- ((TYPE *)(stream->buf))[4 * i + 1] = a;\
- ((TYPE *)(stream->buf))[4 * i + 2] = a;\
- ((TYPE *)(stream->buf))[4 * i + 3] = a;\
- }\
- } else {\
- for (i = 0; i < n; i++) {\
- x = ((TYPE *)(stream->buf))[4 * i + 0];\
- y = ((TYPE *)(stream->buf))[4 * i + 1];\
- z = ((TYPE *)(stream->buf))[4 * i + 2];\
- a = ((TYPE *)(stream->buf))[4 * i + 3];\
- x = posmod(x, (TYPE)1);\
- y = posmod(y, (TYPE)1);\
- z = posmod(z, (TYPE)1);\
- a = posmod(a, (TYPE)1);\
- x = x > 1 ? 2 - x : x;\
- y = y > 1 ? 2 - y : y;\
- z = z > 1 ? 2 - z : z;\
- a = a > 1 ? 2 - a : a;\
- x = 1 - (cos(x * (TYPE)M_PI) + 1) / 2;\
- y = 1 - (cos(y * (TYPE)M_PI) + 1) / 2;\
- z = 1 - (cos(z * (TYPE)M_PI) + 1) / 2;\
- a = 1 - (cos(a * (TYPE)M_PI) + 1) / 2;\
- ((TYPE *)(stream->buf))[4 * i + 0] = x;\
- ((TYPE *)(stream->buf))[4 * i + 1] = y;\
- ((TYPE *)(stream->buf))[4 * i + 2] = z;\
- ((TYPE *)(stream->buf))[4 * i + 3] = a;\
- }\
- }\
- n *= stream->pixel_size;\
- ewriteall(STDOUT_FILENO, stream->buf, n, "<stdout>");\
- memmove(stream->buf, stream->buf + n, stream->ptr -= n);\
- } while (eread_stream(stream, SIZE_MAX));\
- if (stream->ptr)\
- eprintf("%s: incomplete frame\n", stream->file);\
- }
-
-PROCESS(double, lf)
-PROCESS(float, f)
-
-
-int
-main(int argc, char *argv[])
-{
- struct stream stream;
- void (*process)(struct stream *stream);
-
- ARGBEGIN {
- case 'e':
- equal = 1;
- break;
- default:
- usage();
- } ARGEND;
-
- if (argc)
- usage();
-
- eopen_stream(&stream, NULL);
-
- if (!strcmp(stream.pixfmt, "xyza"))
- process = process_lf;
- else if (!strcmp(stream.pixfmt, "xyza f"))
- process = process_f;
- else
- eprintf("pixel format %s is not supported, try xyza\n", stream.pixfmt);
-
- fprint_stream_head(stdout, &stream);
- efflush(stdout, "<stdout>");
- process(&stream);
- return 0;
-}