diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2014-05-09 12:03:56 -0700 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-05-09 19:15:13 -0700 |
| commit | cea09733638d03edb68ceeac2c578705b4f78893 (patch) | |
| tree | c44a9717a1cb95b0ae87f64adcf0c37275515119 /src/cairo-tests/animation.cpp | |
| parent | 83fdc66541abebabd919ca3b772f38e16858a785 (diff) | |
Split fill test into three tests: fill, multishape, and animation
Diffstat (limited to 'src/cairo-tests/animation.cpp')
| -rw-r--r-- | src/cairo-tests/animation.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/cairo-tests/animation.cpp b/src/cairo-tests/animation.cpp new file mode 100644 index 0000000..8541ca8 --- /dev/null +++ b/src/cairo-tests/animation.cpp @@ -0,0 +1,75 @@ +/* + * Copyright 2014 © Samsung Research America, Silicon Valley + * + * Use of this source code is governed by the 3-Clause BSD license + * specified in the COPYING file included with this source code. + */ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <cairo.h> +#include <math.h> + +#include "caskbench.h" +#include "cairo-shapes.h" +#include "kinetics.h" + +static kinetics_t *particles; + +int +ca_setup_animation(caskbench_context_t *ctx) +{ + if (ctx->size < 0) + return 0; + + // Animation setup + particles = (kinetics_t *) malloc (sizeof (kinetics_t) * ctx->size); + for (int i = 0; i < ctx->size; i++) + kinetics_init(&particles[i]); + + return 1; +} + +void +ca_teardown_animation(void) +{ + free(particles); +} + +int +ca_test_animation(caskbench_context_t *ctx) +{ + // Animation / Kinematics of single or multi shape + cairo_set_source_rgb (ctx->cairo_cr, 0, 0, 0); + cairo_rectangle (ctx->cairo_cr, 0, 0, ctx->canvas_width ,ctx->canvas_height); + cairo_fill (ctx->cairo_cr); + + for (int i = 0; i < ctx->size; i++) { + shapes_t shape; + kinetics_t *particle = &particles[i]; + + kinetics_update(particle, 0.1); + + shape_copy(&ctx->shape_defaults, &shape); + shape.width = particle->width; + shape.height = particle->height; + shape.x = particle->x; + shape.y = particle->y; + + cairoDrawRandomizedShape(ctx, &shape); + } + + return 1; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : |