annotate examples/dynamic/hello.c @ 881:a17c4e231e54 abs_n_rel_center

Transform positions of radient paints. cx, cy of radial and x1, y1, x2, y2 of linear gradient paints must be transformed with aggregated matrix of painted shapes. Pattern to user space transformation maybe used to get more precise color.
author Thinker K.F. Li <thinker@codemud.net>
date Sat, 25 Sep 2010 20:12:45 +0800
parents 26c302b47de1
children
rev   line source
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
1 /*! \file
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
2 *
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
3 * svg2code_ex is an example that show programmers how to create a
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
4 * menu with MadButterfly.
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
5 *
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
6 */
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
7 #include <stdio.h>
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
8 #include <mb.h>
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
9 #include <string.h>
387
433fa83d16f9 Corrected build dependence - able to build in Ubuntu Intrepid
Ben Lau <xbenlau@gmail.com>
parents: 247
diff changeset
10 //#include "menu.h"
456
26c302b47de1 Change name of header files.
Thinker K.F. Li <thinker@branda.to>
parents: 454
diff changeset
11 #include "mb_af.h"
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
12
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
13
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
14 mbaf_t *app;
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
15
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
16 typedef struct {
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
17 shape_t *rect;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
18 co_aix orx,ory;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
19 int start_x,start_y;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
20 observer_t *obs1,*obs2;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
21 int currentscene;
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
22 }app_data_t;
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
23
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
24
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
25 void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg)
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
26 {
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
27 app_data_t *en = MBAF_DATA((mbaf_t *)arg,app_data_t );
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
28 mb_timeval_t timer,interval;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
29
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
30
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
31 get_now(&timer);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
32 MB_TIMEVAL_SET(&interval, 1 ,0);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
33 MB_TIMEVAL_ADD(&timer, &interval);
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
34 mb_tman_timeout( mbaf_get_timer(app), &timer, switch_scene, app);
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
35
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
36 en->currentscene = (en->currentscene + 1) % 2;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
37 printf("switch to scene %d\n", en->currentscene + 1);
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
38 MB_SPRITE_GOTO_SCENE(app->rootsprite,en->currentscene + 1);
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
39 }
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
40
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
41 int main(int argc, char * const argv[]) {
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
42 subject_t *subject;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
43 mb_button_t *b;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
44 mb_obj_t *button;
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
45 app_data_t data;
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
46 mb_timeval_t tmo,interval;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
47
453
84ce2d4a8c3f Change interface of sprite loader.
Thinker K.F. Li <thinker@branda.to>
parents: 399
diff changeset
48 if (argc > 1)
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
49 app = mbaf_init(argv[1], "");
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
50 else
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
51 app = mbaf_init("scene", ".libs");
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
52 data.currentscene=0;
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
53 mbaf_set_data(app,&data);
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
54 //b = mb_button_new(app, app->rootsprite, "btn");
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
55 //mb_button_add_onClick(b, test,NULL);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
56 get_now(&tmo);
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
57 MB_TIMEVAL_SET(&interval, 1 ,0);
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
58 mb_tman_timeout( mbaf_get_timer(app), &tmo, switch_scene, app);
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
59
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
60
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
61 mbaf_loop(app);
247
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
62
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
63 return 0;
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
64 }
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
65
d9a78c859660 Seperate the frameowrk codes from the main.c.
wycc
parents:
diff changeset
66 /* vim: set ts=4 */