From ca3c22aeceaa62e95405171595aed649521f4028 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sat, 16 Aug 2008 13:55:40 -0300 Subject: [PATCH] Zooms in and out of the faces --- gdk.c | 2 +- movie.c | 26 +++++++++++++++++++++++--- point.h | 3 ++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gdk.c b/gdk.c index 3bb6ca9..8fc579c 100644 --- a/gdk.c +++ b/gdk.c @@ -99,7 +99,7 @@ main (int argc, char **argv) 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); diff --git a/movie.c b/movie.c index d348869..b7c04cc 100644 --- a/movie.c +++ b/movie.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "point.h" @@ -141,16 +142,35 @@ drop_dup_frames (GArray *points, int n) 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; } diff --git a/point.h b/point.h index 0fd54ce..24a3f78 100644 --- a/point.h +++ b/point.h @@ -30,7 +30,8 @@ typedef struct } Point; GArray * ReadPoints (char *); -void rescale_points (GArray *); +void rescale_points (GArray *, GArray *); GArray * drop_dup_frames (GArray *, int); +GArray *get_scales (int); #endif -- 2.20.1