-/* gcc -Wall -g $(pkg-config --cflags --libs gtk+-2.0 cairo) olpc-boot.c -o olpc-boot */
+/* xoboot - A simple demonstration of what might be an XO boot animation
+ *
+ * gcc -Wall -g $(pkg-config --cflags --libs gtk+-2.0 cairo) xoboot.c -o xboot
+ *
+ * Copyright © 2007 Carl Worth
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
+ */
+
+/* This is simply a proof-of-concept for using cairo to implement a
+ * design idea for an OLPC boot-time animation. The animation here is
+ * implemented to mimic an animation originally provided as a
+ * Quicktime movie by Rebecca Allen <rallen@arts.ucla.edu>.
+ *
+ * So far, this animation has been developed exclusively on an x86
+ * laptop with GTK+ targeting the X Window System. No guarantees are
+ * provided as to how this might perform on an OLPC XO machine. What's
+ * likely desired is to write the application to use cairo image
+ * surfaces, and augment cairo to support targeting the XO's 565 image
+ * format directly.
+ *
+ * And obviously, to serve as a real boot-time animation, code will
+ * have to be written to advance the animation according to various
+ * system events, instead of using the hard-coded timeline below.
+ */
#include <gtk/gtk.h>
#include <cairo.h>
static void
draw_body (cairo_t *cr, double extra, double spin_transition)
{
+ double angle, x, y;
+
cairo_save (cr);
cairo_move_to (cr,
cairo_rel_line_to (cr, XO_BODY_DELTA, XO_BODY_DELTA);
cairo_translate (cr, XO_HEAD_CENTER_X, XO_HEAD_CENTER_Y);
- cairo_rotate (cr, 2 * M_PI * spin_transition);
+
+ angle = 2 * M_PI * spin_transition;
+ y = cos (angle) * XO_DOTS_POSITION_RADIUS;
+ x = sin (angle) * XO_DOTS_POSITION_RADIUS;
+ angle = atan2 (x, y + XO_BODY_CENTER_Y - XO_HEAD_CENTER_Y);
+
+ cairo_rotate (cr, angle);
cairo_translate (cr, -XO_HEAD_CENTER_X, -XO_HEAD_CENTER_Y);
cairo_move_to (cr,
cairo_translate (cr, XO_DOTS_CENTER_X, XO_DOTS_CENTER_Y);
cairo_rotate (cr, - 1.5 * M_PI);
- for (i = 0; i < num_dots; i++) {
+ for (i = 0; i <= num_dots; i++) {
if (i != 0) {
cairo_arc (cr,
XO_DOTS_POSITION_RADIUS, 0,
goto DONE;
if (anim_stage < ANIM_FADE) {
- draw_dots (cr, (XO_DOTS_NUM_DOTS + 1) * spin_transition);
+ draw_dots (cr, (XO_DOTS_NUM_DOTS) * spin_transition);
} else {
draw_ring (cr);
}