filename = argv[1];
ctx.points = ReadPoints ("pro-gnu");
ctx.points = drop_dup_frames (ctx.points, 20);
- rescale_points (ctx.points);
+ rescale_points (ctx.points, get_scales (20));
ctx.picture = gdk_pixbuf_new_from_file (filename, NULL);
ctx.i = ctx.points->len;
colorspace = gdk_pixbuf_get_colorspace (ctx.picture);
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
+#include <math.h>
#include "point.h"
return frames;
}
+GArray *
+get_scales (int n)
+{
+ GArray *scales;
+ double scale;
+ double factor;
+ scales = g_array_new (FALSE, TRUE, sizeof (double));
+ factor = pow (8.0, 1.0/((double) n/2));
+ factor = 1.0/factor;
+ for (scale = 4.00; scale > 0.5 && scales->len < n/2; scale *= factor)
+ scales = g_array_append_val (scales, scale);
+ factor = 1.0/factor;
+ for (scale = 0.5; scale < 4.0 && scales->len < n; scale *= factor)
+ scales = g_array_append_val (scales, scale);
+ return scales;
+}
+
void
-rescale_points (GArray *points)
+rescale_points (GArray *points, GArray *scales)
{
Point *point;
+ double scale;
int i;
for (i = 0; i < points->len; i++)
{
point = &(g_array_index (points, Point, i));
- point->rx = 4.0;
- point->ry = 4.0;
+ scale = g_array_index (scales, double, (i % scales->len));
+ point->rx = scale;
+ point->ry = scale;
point->x *= point->rx;
point->y *= point->ry;
}
} Point;
GArray * ReadPoints (char *);
-void rescale_points (GArray *);
+void rescale_points (GArray *, GArray *);
GArray * drop_dup_frames (GArray *, int);
+GArray *get_scales (int);
#endif