This email list is read-only. Emails sent to this list will be discarded
----------------------------------
apple/apple.c | 611 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 611 insertions(+), 0 deletions(-)
New commits:
commit 83c0c98bd58880fe6771d1b7468bdf68760b5e86
Author: Bob Spencer <[EMAIL PROTECTED]>
Date: Wed Aug 13 10:51:23 2008 -0700
Added apple.c
Diff in this email is a maximum of 400 lines.
diff --git a/apple/apple.c b/apple/apple.c
new file mode 100644
index 0000000..0409a4d
--- /dev/null
+++ b/apple/apple.c
@@ -0,0 +1,611 @@
+#include <clutter/clutter.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+
+/**
+ Rings start from the top-inner ring of the
+ apple, moving out towards the top curve
+ and following down to the bottom-inside
+ ring.
+ */
+ClutterActor *ring1 [9];
+ClutterActor *ring2 [15];
+ClutterActor *ring3 [18];
+ClutterActor *ring4 [24];
+ClutterActor *ring5 [24];
+ClutterActor *ring6 [36];
+ClutterActor *ring7 [36];
+ClutterActor *ring8 [36];
+ClutterActor *ring9 [36];
+ClutterActor *ring10[36];
+ClutterActor *ring11[36];
+ClutterActor *ring12[36];
+ClutterActor *ring13[36];
+ClutterActor *ring14[36];
+ClutterActor *ring15[36];
+ClutterActor *ring16[18];
+ClutterActor *ring17[18];
+ClutterActor *ring18[9];
+
+#define RING1 1
+#define RING2 2
+#define RING3 3
+#define RING4 4
+#define RING5 5
+#define RING6 6
+#define RING7 7
+#define RING8 8
+#define RING9 9
+#define RING10 10
+#define RING11 11
+#define RING12 12
+#define RING13 13
+#define RING14 14
+#define RING15 15
+#define RING16 16
+#define RING17 17
+#define RING18 18
+#define STEM 19
+
+#define ELLIPSE_X 640
+#define NUM_PATH_KNOTS 70
+
+ClutterActor *stage;
+
+/* space between apple square pieces */
+int angle_step = 10;
+
+/* For rotating all images around an ellipse: */
+ClutterTimeline *timeline_rotation = NULL;
+
+
+
+
+/**
+ Adds each actor (apple piece = square) to it's respective
+ ring/ellipse of the apple. Each ellipse's x coord of the
+ center is ELLIPSE_X; this makes it easier to move the entire
+ apple to the left or right. (The stem and leaf must be changed
+ individually.)
+ ELLIPSE_X, y_coord_of_center, width of ellipse, height of ellipse
+ */
+void add_to_ellipse_behaviour(ClutterTimeline *timeline_rotation,
+ gdouble start_angle,
+ ClutterActor *actor, int line)
+{
+ g_return_if_fail(timeline_rotation);
+ ClutterAlpha *alpha = clutter_alpha_new_full(timeline_rotation,
+ CLUTTER_ALPHA_RAMP_INC,
+ NULL, NULL);
+ ClutterBehaviour *behaviour;
+ switch(line)
+ {
+ case RING1:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 170, 135, 20, CLUTTER_ROTATE_CW, start_angle,
+ start_angle);
+ break;
+ case RING2:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 160, 220, 50, CLUTTER_ROTATE_CW, start_angle,
+ start_angle);
+ break;
+ case RING3:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 140, 305, 50, CLUTTER_ROTATE_CW, start_angle,
+ start_angle);
+ break;
+ case RING4:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 120, 370, 50, CLUTTER_ROTATE_CW, start_angle,
+ start_angle);
+ break;
+ case RING5:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 125, 450, 50, CLUTTER_ROTATE_CW, start_angle,
+ start_angle);
+ break;
+ case RING6:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 140, 540, 100, CLUTTER_ROTATE_CW, start_angle,
+ start_angle);
+ break;
+ case RING7:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 180, 580, 100, CLUTTER_ROTATE_CW, start_angle,
+ start_angle);
+ break;
+ case RING8:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 220, 605, 100, CLUTTER_ROTATE_CW, start_angle,
+ start_angle);
+ break;
+ case RING9:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 260, 605, 100, CLUTTER_ROTATE_CW, start_angle,
+ start_angle);
+ break;
+ case RING10:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 300, 585, 100, CLUTTER_ROTATE_CW, start_angle,
+ start_angle);
+ break;
+ case RING11:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 340, 565, 100, CLUTTER_ROTATE_CW, start_angle,
start_angle);
+ break;
+ case RING12:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 380, 540, 100, CLUTTER_ROTATE_CW, start_angle,
start_angle);
+ break;
+ case RING13:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 420, 500, 100, CLUTTER_ROTATE_CW, start_angle,
start_angle);
+ break;
+ case RING14:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 460, 440, 100, CLUTTER_ROTATE_CW, start_angle,
start_angle);
+ break;
+ case RING15:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 500, 370, 100, CLUTTER_ROTATE_CW, start_angle,
start_angle);
+ break;
+ case RING16:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 500, 300, 50, CLUTTER_ROTATE_CW, start_angle,
start_angle);
+ break;
+ case RING17:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 500, 210, 50, CLUTTER_ROTATE_CW, start_angle,
start_angle);
+ break;
+ case RING18:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 480, 110, 30, CLUTTER_ROTATE_CW, start_angle,
start_angle);
+ break;
+ case STEM:
+ behaviour = clutter_behaviour_rotate_new(alpha, CLUTTER_Y_AXIS,
CLUTTER_ROTATE_CW, start_angle, start_angle);
+ break;
+ default:
+ behaviour = clutter_behaviour_ellipse_new(
+ alpha, ELLIPSE_X, 480, 110, 30, CLUTTER_ROTATE_CW, start_angle,
start_angle);
+ }
+ clutter_behaviour_apply(behaviour, actor);
+
+}
+
+/**
+ Sets up a zigzag path for the caterpillar to follow.
+ Also scales the caterpillar to start out small and
+ grow as it reaches the end of the path to make it
+ appear as if the caterpillar is travelling down
+ the path towards the viewer.
+ */
+void setup_path(ClutterActor *actor, ClutterTimeline *timeline)
+{
+ ClutterAlpha *alpha;
+ ClutterBehaviour *behaviour, *behaviour1;
+
+ ClutterKnot knot[NUM_PATH_KNOTS];
+
+ knot[0].x = 258; knot[0].y = 136;
+ knot[1].x = 246; knot[1].y = 137;
+ knot[2].x = 236; knot[2].y = 139;
+ knot[3].x = 230; knot[3].y = 142;
+ knot[4].x = 229; knot[4].y = 145; //5
+
+ knot[5].x = 231; knot[5].y = 148;
+ knot[6].x = 242; knot[6].y = 153;
+ knot[7].x = 255; knot[7].y = 159;
+ knot[8].x = 261; knot[8].y = 163;
+ knot[9].x = 263; knot[9].y = 166; //10
+
+ knot[10].x = 260; knot[10].y = 168;
+ knot[11].x = 252; knot[11].y = 169;
+ knot[12].x = 235; knot[12].y = 169;
+ knot[13].x = 209; knot[13].y = 169;
+ knot[14].x = 174; knot[14].y = 170; //15
+
+ knot[15].x = 123; knot[15].y = 171;
+ knot[16].x = 101; knot[16].y = 173;
+ knot[17].x = 93; knot[17].y = 175;
+ knot[18].x = 88; knot[18].y = 178;
+ knot[19].x = 86; knot[19].y = 182; //20
+
+ knot[20].x = 86; knot[20].y = 186;
+ knot[21].x = 89; knot[21].y = 189;
+ knot[22].x = 96; knot[22].y = 190;
+ knot[23].x = 106; knot[23].y = 191;
+ knot[24].x = 121; knot[24].y = 194; //25
+
+ knot[25].x = 143; knot[25].y = 198;
+ knot[26].x = 175; knot[26].y = 207;
+ knot[27].x = 215; knot[27].y = 221;
+ knot[28].x = 235; knot[28].y = 234;
+ knot[29].x = 241; knot[29].y = 241; //30
+
+ knot[30].x = 244; knot[30].y = 248;
+ knot[31].x = 244; knot[31].y = 253;
+ knot[32].x = 244; knot[32].y = 258;
+ knot[33].x = 241; knot[33].y = 262;
+ knot[34].x = 237; knot[34].y = 265; //35
+
+ knot[35].x = 230; knot[35].y = 269;
+ knot[36].x = 218; knot[36].y = 274;
+ knot[37].x = 201; knot[37].y = 280;
+ knot[38].x = 174; knot[38].y = 288;
+ knot[39].x = 140; knot[39].y = 294; //40
+
+ knot[40].x = 93; knot[40].y = 300;
+ knot[41].x = 57; knot[41].y = 310;
+ knot[42].x = 34; knot[42].y = 318;
+ knot[43].x = 27; knot[43].y = 323;
+ knot[44].x = 22; knot[44].y = 328; //45
+
+ knot[45].x = 17; knot[45].y = 333;
+ knot[46].x = 14; knot[46].y = 338;
+ knot[47].x = 12; knot[47].y = 343;
+ knot[48].x = 10; knot[48].y = 348;
+ knot[49].x = 9; knot[49].y = 352; //50
+
+ knot[50].x = 8; knot[50].y = 358;
+ knot[51].x = 8; knot[51].y = 365;
+ knot[52].x = 11; knot[52].y = 371;
+ knot[53].x = 14; knot[53].y = 378;
+ knot[54].x = 21; knot[54].y = 386; //55
+
+ knot[55].x = 27; knot[55].y = 391;
+ knot[56].x = 35; knot[56].y = 398;
+ knot[57].x = 44; knot[57].y = 405;
+ knot[58].x = 65; knot[58].y = 416;
+ knot[59].x = 102; knot[59].y = 434; //60
+
+ knot[60].x = 149; knot[60].y = 459;
+ knot[61].x = 155; knot[61].y = 465;
+ knot[62].x = 159; knot[62].y = 472;
+ knot[63].x = 160; knot[63].y = 482;
+ knot[64].x = 157; knot[64].y = 506; //65
+
+ knot[65].x = 153; knot[65].y = 524;
+ knot[66].x = 152; knot[66].y = 528;
+ knot[67].x = 149; knot[67].y = 531;
+ knot[68].x = 144; knot[68].y = 536;
+ knot[69].x = 114; knot[69].y = 556; //70
+
+ alpha = clutter_alpha_new_full(timeline,
+ CLUTTER_ALPHA_SMOOTHSTEP_INC,
+ NULL, NULL);
+ behaviour = clutter_behaviour_path_new(alpha,
+ knot,
+ sizeof(knot)/sizeof(ClutterKnot));
+ clutter_behaviour_apply(behaviour, actor);
+ behaviour1 = clutter_behaviour_scale_new(alpha, .05, .05, 1, 1);
+ clutter_behaviour_apply(behaviour1, actor);
+}
+
+
+/**
+ Initializes each apple piece/square to the correct color, size,
+ and opacity. The actor is added to the stage and added to a
+ specific ellipse behaviour.
+ The opacity of the 3 rings at the very bottom-inside of the apple
+ are set at a lower opacity.
+ */
+void init_apple_piece(ClutterActor *apple_piece, int line, gdouble angle)
+{
+ ClutterColor apple_red = { 0xEE, 0x63, 0x63, 0xff };
+ apple_piece = clutter_rectangle_new_with_color(&apple_red);
+ clutter_actor_set_size(apple_piece, 30, 30);
+ clutter_actor_set_opacity(apple_piece, 80);
+ if (line == RING16 || line == RING17 || line == RING18) {
+ clutter_actor_set_opacity(apple_piece, 40);
+ }
+ clutter_container_add_actor(CLUTTER_CONTAINER(stage), apple_piece);
+ add_to_ellipse_behaviour(timeline_rotation, angle, apple_piece, line);
+ clutter_actor_show(apple_piece);
+}
+
+
+/**
+ Makes the call to initialize each actor and
+ specifies the angle to separate each actor
+ by.
+*/
+void init_apples()
+{
+ int i;
+ gdouble angle = 0;
+
+ /* ring1 */
+ angle = 0;
+ angle_step = 40;
+ for (i = 0; i < 9; i++) {
+ init_apple_piece(ring1[i], RING1, angle);
+ angle += angle_step;
+ }
+
+ /* ring2 */
+ angle = 0;
+ angle_step = 25;
+ for (i = 0; i < 15; i++) {
+ init_apple_piece(ring2[i], RING2, angle);
+ angle += angle_step;
+ }
+
+ /* ring3 */
+ angle = 0;
+ angle_step = 20;
+ for (i = 0; i < 18; i++) {
+ init_apple_piece(ring3[i], RING3, angle);
+ angle += angle_step;
+ }
+
+ /* ring4 */
+ angle = 0;
+ angle_step = 15;
+ for (i = 0; i < 24; i++) {
+ init_apple_piece(ring4[i], RING4, angle);
+ angle += angle_step;
+ }
+
+
+ /* ring5 */
+ angle = 0;
+ angle_step = 15;
+ for (i = 0; i < 24; i++) {
+ init_apple_piece(ring5[i], RING5, angle);
+ angle += angle_step;
+ }
+
+ /* ring6 */
+ angle = 0;
+ angle_step = 10;
+ for (i = 0; i < 36; i++) {
+ init_apple_piece(ring6[i], RING6, angle);
+ angle += angle_step;
+ }
+
+ /* ring7 */
+ angle = 0;
+ for (i = 0; i < 36; i++) {
+ init_apple_piece(ring7[i], RING7, angle);
+ angle += angle_step;
+ }
+
+ /* ring8 */
+ angle = 0;
+ for (i = 0; i < 36; i++) {
+ init_apple_piece(ring8[i], RING8, angle);
+ angle += angle_step;
+ }
+
+ /* ring9 */
+ angle = 0;
+ for (i = 0; i < 36; i++) {
+ init_apple_piece(ring9[i], RING9, angle);
+ angle += angle_step;
+ }
+
+ /* ring10 */
+ angle = 0;
+ angle_step = 10;
+ for (i = 0; i < 36; i++) {
+ init_apple_piece(ring10[i], RING10, angle);
+ angle += angle_step;
+ }
_______________________________________________
Commits mailing list
[email protected]
https://www.moblin.org/mailman/listinfo/commits