summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-02-04 13:16:02 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-02-05 00:07:17 +0000
commit0552f44d2f37c73b8d88821423789ece84875100 (patch)
treea734e43bc2582086a704b6b63c41778fbedda13d
parentc4a4ee2a4e9c1e5c38e6ee49fbda1ed954ed52f6 (diff)
Add a zoom effect to the spinner-demo
To demonstrate handling of very large images by zooming in.
-rw-r--r--spinner-demo.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/spinner-demo.c b/spinner-demo.c
index 1194751..3f2f5da 100644
--- a/spinner-demo.c
+++ b/spinner-demo.c
@@ -180,6 +180,9 @@ int main(int argc, char **argv)
struct device *device;
struct timeval start, last_tty, last_fps, now;
int frames, n;
+ int frame = 0;
+ double factor = 1.0125;
+ double zoom = 0.75;
int show_fps = 1;
const char *version;
@@ -228,11 +231,11 @@ int main(int argc, char **argv)
cairo_t *cr;
double delta;
-
if (source->height * device->width > source->width * device->height)
delta = device->width / (double)source->width;
else
delta = device->height / (double)source->height;
+ delta *= zoom;
cr = cairo_create (fb->surface);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
@@ -248,6 +251,10 @@ int main(int argc, char **argv)
cairo_identity_matrix(cr);
cairo_paint(cr);
+ if (++frame % 512 == 0)
+ factor = 1./factor;
+ zoom *= factor;
+
gettimeofday(&now, NULL);
if (show_fps) {
if (last_fps.tv_sec)