Skip to content

Commit a36cf34

Browse files
author
Emmanuele Bassi
committed
circles: Minor cleanups
1 parent e65b568 commit a36cf34

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

circles/circles.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
22
#include <clutter/clutter.h>
33
#include <math.h>
44

@@ -10,7 +10,7 @@
1010
#define SCREEN_H 480
1111

1212
#ifndef CLUTTER_ANGLE_FROM_RAD
13-
#define CLUTTER_ANGLE_FROM_RAD(x) ((x) * 180.0 / M_PI)
13+
#define CLUTTER_ANGLE_FROM_RAD(x) ((x) * 180.0 / G_PI)
1414
#endif
1515

1616
static void
@@ -19,14 +19,14 @@ circle_paint_cb (ClutterActor *actor)
1919
const CoglColor fill_color = { 0xff, 0xff, 0xff, 0x80 };
2020
gint i;
2121
gdouble angle;
22-
guint radius = clutter_actor_get_width (actor)/2;
22+
guint radius = clutter_actor_get_width (actor) / 2;
2323

2424
cogl_set_source_color (&fill_color);
2525

2626
angle = *((gdouble *)g_object_get_data (G_OBJECT (actor), "angle"));
27-
for (i = 0; i < CIRCLE_S; i++, angle += (2.0*M_PI)/(gdouble)CIRCLE_S)
27+
for (i = 0; i < CIRCLE_S; i++, angle += (2.0 * G_PI) / (gdouble) CIRCLE_S)
2828
{
29-
gdouble angle2 = angle + ((2.0*M_PI)/(gdouble)CIRCLE_S)/2.0;
29+
gdouble angle2 = angle + ((2.0 * G_PI) / (gdouble)CIRCLE_S) / 2.0;
3030
cogl_path_move_to (((radius - CIRCLE_W) * cos (angle)) + radius,
3131
((radius - CIRCLE_W) * sin (angle)) + radius);
3232
cogl_path_arc (radius, radius, radius, radius,
@@ -50,13 +50,16 @@ main (int argc, char **argv)
5050
ClutterTimeline *timeline;
5151
ClutterActor *stage;
5252
gint i;
53-
54-
clutter_init (&argc, &argv);
55-
56-
stage = clutter_stage_get_default ();
57-
clutter_actor_set_size (stage, SCREEN_W, SCREEN_H);
53+
54+
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
55+
return 1;
56+
57+
stage = clutter_stage_new ();
58+
clutter_stage_set_title (CLUTTER_STAGE (stage), "Circles");
5859
clutter_stage_set_color (CLUTTER_STAGE (stage), &bg_color);
59-
60+
clutter_actor_set_size (stage, SCREEN_W, SCREEN_H);
61+
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
62+
6063
timeline = clutter_timeline_new (5000);
6164
clutter_timeline_set_loop (timeline, TRUE);
6265

@@ -70,10 +73,11 @@ main (int argc, char **argv)
7073

7174
actor = clutter_rectangle_new_with_color (&transp);
7275

73-
size = (i+1) * (CIRCLE_W + CIRCLE_G) * 2;
76+
size = (i + 1) * (CIRCLE_W + CIRCLE_G) * 2;
7477
clutter_actor_set_size (actor, size, size);
75-
clutter_actor_set_position (actor, SCREEN_W - size/2,
76-
SCREEN_H - size/2);
78+
clutter_actor_set_position (actor,
79+
SCREEN_W - size / 2.0,
80+
SCREEN_H - size / 2.0);
7781

7882
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
7983

@@ -89,7 +93,9 @@ main (int argc, char **argv)
8993
: CLUTTER_ROTATE_CCW,
9094
0.0, 0.0);
9195
clutter_behaviour_rotate_set_center (CLUTTER_BEHAVIOUR_ROTATE (behaviour),
92-
size/2, size/2, 0);
96+
size / 2,
97+
size / 2,
98+
0);
9399
clutter_behaviour_apply (behaviour, actor);
94100
}
95101

@@ -101,4 +107,3 @@ main (int argc, char **argv)
101107

102108
return 0;
103109
}
104-

0 commit comments

Comments
 (0)