X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;ds=sidebyside;f=xoboot.c;h=1feb5dccbcb3059b4d445821168f4ef96e6079db;hb=HEAD;hp=4daa763c14f94c0992bf9026719bcc0fab530372;hpb=fbf45e3901075ef7e42f58cbfcf55947a8278e7e;p=xoboot diff --git a/xoboot.c b/xoboot.c index 4daa763..1feb5dc 100644 --- a/xoboot.c +++ b/xoboot.c @@ -1,4 +1,40 @@ -/* 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 . + * + * 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 #include @@ -108,6 +144,8 @@ draw_head (cairo_t *cr, double extra) static void draw_body (cairo_t *cr, double extra, double spin_transition) { + double angle, x, y; + cairo_save (cr); cairo_move_to (cr, @@ -117,7 +155,13 @@ draw_body (cairo_t *cr, double extra, double spin_transition) 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, @@ -145,7 +189,7 @@ draw_dots (cairo_t *cr, double num_dots) 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, @@ -231,7 +275,7 @@ xoboot_expose_event (GtkWidget *widget, 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); }