aboutsummaryrefslogtreecommitdiff
path: root/src/cubeit.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2010-09-19 02:49:07 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:58 +0100
commitccbfa3fe4053b703ea959d4a2ad16323dea50218 (patch)
tree2e89a471af7bdb3dbd2a639fae6192089aeb0188 /src/cubeit.c
parent2192bf3147635ab13cb4ffefdbbba759211fb8ae (diff)
cubeit: Improve output
Diffstat (limited to 'src/cubeit.c')
-rw-r--r--src/cubeit.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/cubeit.c b/src/cubeit.c
index d5949848..407c4b56 100644
--- a/src/cubeit.c
+++ b/src/cubeit.c
@@ -322,6 +322,7 @@ static void write_slice(const char *filename, double *vals, int z,
cairo_surface_t *surface;
cairo_t *c;
int w, h;
+ double xl, yl, xli;
w = xs; h = ys;
@@ -336,13 +337,24 @@ static void write_slice(const char *filename, double *vals, int z,
}
max /= boost;
- STATUS("%f %f\n", s*(xs*as+ys*bs*cos(ang)), s*(ys*bs*sin(ang)));
+ xl = s*as;
+ yl = s*bs*sin(ang);
+ xli = s*bs*cos(ang);
+
+ STATUS("%f %f\n", xs*xl + ys*xli, ys*yl);
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
- s*(xs*as+ys*bs*cos(ang)),
- s*(ys*bs*sin(ang)));
+ xs*xl + ys*xli, ys*yl);
c = cairo_create(surface);
+
+ cairo_scale(c, 1.0, -1.0);
+ cairo_translate(c, 0.0, ys*yl);
+
+ cairo_rectangle(c, 0.0, 0.0, xs*xl + ys*xli, ys*yl);
+ cairo_set_source_rgb(c, 1.0, 1.0, 1.0);
+ cairo_fill(c);
+
for ( y=0; y<h; y++ ) {
for ( x=0; x<w; x++ ) {
@@ -354,13 +366,13 @@ static void write_slice(const char *filename, double *vals, int z,
render_scale(val, max, SCALE_COLOUR, &r, &g, &b);
cairo_new_path(c);
- cairo_move_to(c, s*(as*x+bs*y*cos(ang)), s*(y*bs*sin(ang)));
- cairo_line_to(c, s*(as*(x+1)+bs*y*cos(ang)), s*(y*bs*sin(ang)));
- cairo_line_to(c, s*(as*(x+1)+bs*y*cos(ang)),
- s*((y+1)*bs*sin(ang)));
- cairo_line_to(c, s*(as*x+bs*y*cos(ang)), s*((y+1)*bs*sin(ang)));
+ cairo_move_to(c, x*xl+y*xli, y*yl);
+ cairo_line_to(c, (x+1)*xl+y*xli, y*yl);
+ cairo_line_to(c, (x+1)*xl+(y+1)*xli, (y+1)*yl);
+ cairo_line_to(c, x*xl+(y+1)*xli, (y+1)*yl);
cairo_set_source_rgb(c, r, g, b);
cairo_fill(c);
+ cairo_stroke(c);
}
}