aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-hexagon-tessellation.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-07-16 15:29:43 +0200
committerMattias Andrée <maandree@kth.se>2017-07-16 15:29:43 +0200
commitd05d162cb81664f292834fa5d48d623d2b6147a7 (patch)
tree9d4252fcdfa2210613188d5c965514cfab6a8ec2 /src/blind-hexagon-tessellation.c
parentUse #include instead of #define (diff)
downloadblind-d05d162cb81664f292834fa5d48d623d2b6147a7.tar.gz
blind-d05d162cb81664f292834fa5d48d623d2b6147a7.tar.bz2
blind-d05d162cb81664f292834fa5d48d623d2b6147a7.tar.xz
Misc code improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-hexagon-tessellation.c')
-rw-r--r--src/blind-hexagon-tessellation.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/blind-hexagon-tessellation.c b/src/blind-hexagon-tessellation.c
index e282218..abb5c7a 100644
--- a/src/blind-hexagon-tessellation.c
+++ b/src/blind-hexagon-tessellation.c
@@ -4,8 +4,7 @@
USAGE("[-F pixel-format] block-diameter")
#define SET_XYZA(TYPE)\
- (pixwidth *= sizeof(double),\
- colours = alloca(4 * pixwidth),\
+ (colours = alloca(4 * stream.pixel_size),\
((TYPE *)colours)[ 0] = (TYPE)0.412457445582367600,\
((TYPE *)colours)[ 1] = (TYPE)0.212673370378408280,\
((TYPE *)colours)[ 2] = (TYPE)0.019333942761673460,\
@@ -30,7 +29,6 @@ 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;
@@ -48,15 +46,12 @@ main(int argc, char *argv[])
diameter = etozu_arg("block-diameter", argv[0], 1, SIZE_MAX);
- pixfmt = get_pixel_format(pixfmt, "xyza");
- if (!strcmp(pixfmt, "xyza"))
+ eset_pixel_format(&stream, pixfmt);
+ if (stream.encoding == DOUBLE)
SET_XYZA(double);
- else if (!strcmp(pixfmt, "xyza f"))
- SET_XYZA(float);
else
- eprintf("pixel format %s is not supported, try xyza\n", pixfmt);
+ SET_XYZA(float);
- strcpy(stream.pixfmt, pixfmt);
stream.width = (size_t)((double)diameter * sqrt(3.));
stream.height = diameter * 3 / 2;
fprint_stream_head(stdout, &stream);
@@ -100,7 +95,7 @@ main(int argc, char *argv[])
} else {
k = (stream.width <= x * 4 && x * 4 < stream.width * 3) + 2;
}
- ewriteall(STDOUT_FILENO, colours + (size_t)k * pixwidth, pixwidth, "<stdout>");
+ ewriteall(STDOUT_FILENO, colours + (size_t)k * stream.pixel_size, stream.pixel_size, "<stdout>");
}
}