gnomemm r1907 - in cluttermm_tutorial/trunk/examples: actor actor_group actor_transformations effects score timeline
- From: daniel svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1907 - in cluttermm_tutorial/trunk/examples: actor actor_group actor_transformations effects score timeline
- Date: Mon, 22 Dec 2008 18:36:09 +0000 (UTC)
Author: daniel
Date: Mon Dec 22 18:36:09 2008
New Revision: 1907
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1907&view=rev
Log:
Translate examples: effects, actor_transformations, actor_group, timeline, actor, score.
Added:
cluttermm_tutorial/trunk/examples/actor/
cluttermm_tutorial/trunk/examples/actor/main.cc
cluttermm_tutorial/trunk/examples/actor_group/
cluttermm_tutorial/trunk/examples/actor_group/main.cc
cluttermm_tutorial/trunk/examples/actor_transformations/
cluttermm_tutorial/trunk/examples/actor_transformations/main.cc
cluttermm_tutorial/trunk/examples/effects/
cluttermm_tutorial/trunk/examples/effects/main.cc
cluttermm_tutorial/trunk/examples/score/
cluttermm_tutorial/trunk/examples/score/main.cc
cluttermm_tutorial/trunk/examples/timeline/
cluttermm_tutorial/trunk/examples/timeline/main.cc
Added: cluttermm_tutorial/trunk/examples/actor/main.cc
==============================================================================
--- (empty file)
+++ cluttermm_tutorial/trunk/examples/actor/main.cc Mon Dec 22 18:36:09 2008
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2008 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include <cluttermm.h>
+
+int main(int argc, char** argv)
+{
+ Clutter::init(&argc, &argv);
+
+ // Get the stage and set its size and color
+ const Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
+ stage->set_size(200, 200);
+ stage->set_color(Clutter::Color(0, 0, 0, 255)); // black
+
+ Clutter::Color actor_color (0xff, 0xff, 0xff, 0x99);
+
+ // Add a rectangle to the stage
+ const Glib::RefPtr<Clutter::Rectangle> rect = Clutter::Rectangle::create(actor_color);
+ rect->set_size(100, 100);
+ rect->set_position(20, 20);
+ stage->add_actor(rect);
+ rect->show();
+
+ // Add a label to the stage
+ const Glib::RefPtr<Clutter::Actor> label =
+ Clutter::Label::create("Sans 12", "Some Text", actor_color);
+ label->set_size(500, 500);
+ label->set_position(20, 150);
+ stage->add_actor(label);
+ label->show();
+
+ // Show the stage
+ stage->show();
+
+ // Start the main loop, so we can respond to events
+ Clutter::main();
+
+ return 0;
+}
Added: cluttermm_tutorial/trunk/examples/actor_group/main.cc
==============================================================================
--- (empty file)
+++ cluttermm_tutorial/trunk/examples/actor_group/main.cc Mon Dec 22 18:36:09 2008
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2008 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include <cluttermm.h>
+
+int main(int argc, char** argv)
+{
+ Clutter::init(&argc, &argv);
+
+ // Get the stage and set its size and color
+ const Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
+ stage->set_size(200, 200);
+ stage->set_color(Clutter::Color(0, 0, 0, 0xFF)); // black
+
+ // Add a group to the stage
+ const Glib::RefPtr<Clutter::Group> group = Clutter::Group::create();
+ group->set_position(40, 40);
+ stage->add_actor(group);
+ group->show();
+
+ const Clutter::Color actor_color (0xFF, 0xFF, 0xFF, 0x99);
+
+ // Add a rectangle to the group
+ const Glib::RefPtr<Clutter::Rectangle>
+ rect = Clutter::Rectangle::create(actor_color);
+ rect->set_size(50, 50);
+ rect->set_position(0, 0);
+ group->add_actor(rect);
+ rect->show();
+
+ // Add a label to the group
+ const Glib::RefPtr<Clutter::Label>
+ label = Clutter::Label::create("Sans 9", "Some Text", actor_color);
+ label->set_position(0, 60);
+ group->add_actor (label);
+ label->show();
+
+ // Scale the group 120% along the x axis
+ group->set_scale(3.00, 1.0);
+
+ // Rotate it around the z axis
+ group->set_rotation(Clutter::Z_AXIS, 10, 0, 0, 0);
+
+ // Show the stage
+ stage->show();
+
+ // Start the main loop, so we can respond to events
+ Clutter::main();
+
+ return 0;
+}
Added: cluttermm_tutorial/trunk/examples/actor_transformations/main.cc
==============================================================================
--- (empty file)
+++ cluttermm_tutorial/trunk/examples/actor_transformations/main.cc Mon Dec 22 18:36:09 2008
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2008 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include <cluttermm.h>
+
+int main(int argc, char** argv)
+{
+ Clutter::init(&argc, &argv);
+
+ // Get the stage and set its size and color
+ const Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
+ stage->set_size(200, 200);
+ stage->set_color(Clutter::Color(0, 0, 0, 0xFF)); // black
+
+ const Clutter::Color actor_color (0xff, 0xff, 0xff, 0x99);
+
+ // Add a rectangle to the stage
+ const Glib::RefPtr<Clutter::Rectangle> rect = Clutter::Rectangle::create(actor_color);
+ rect->set_size(100, 100);
+ rect->set_position(20, 20);
+ stage->add_actor(rect);
+ rect->show();
+
+ // Rotate it 20 degrees away from us around the x axis
+ // (around its top edge)
+ rect->set_rotation(Clutter::X_AXIS, -20, 0, 0, 0);
+
+ // Add a label to the stage
+ const Glib::RefPtr<Clutter::Label> label =
+ Clutter::Label::create("Sans 12", "Some Text", actor_color);
+ label->set_size(500, 500);
+ label->set_position(20, 150);
+ stage->add_actor(label);
+ label->show();
+
+ // Scale it 300% along the x axis
+ label->set_scale(3.0, 1.0);
+
+ // Move it up and to the right
+ label->move_by(10, -10);
+
+ // Move it along the z axis, further from the viewer
+ label->set_depth(-20);
+
+ // Show the stage
+ stage->show();
+
+ // Start the main loop, so we can respond to events
+ Clutter::main();
+
+ return 0;
+}
Added: cluttermm_tutorial/trunk/examples/effects/main.cc
==============================================================================
--- (empty file)
+++ cluttermm_tutorial/trunk/examples/effects/main.cc Mon Dec 22 18:36:09 2008
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2008 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include <cluttermm.h>
+#include <vector>
+
+namespace
+{
+
+Glib::RefPtr<Clutter::Rectangle> rect;
+
+/*
+ * This must return a value between 0 and Clutter::Alpha::MAX_ALPHA,
+ * where 0 means the start of the path, and Clutter::Alpha::MAX_ALPHA
+ * is the end of the path.
+ *
+ * This will be called as many times per seconds as specified in our
+ * call to Clutter::Timeline::create().
+ *
+ * See also, for instance Clutter::Alpha::sine_half_func for a useful
+ * built-in callback.
+ */
+static guint32 on_alpha(const Glib::RefPtr<Clutter::Alpha>& alpha)
+{
+ // Get the position in the timeline, so we can base our value upon it
+ const Glib::RefPtr<Clutter::Timeline> timeline = alpha->get_timeline();
+ const int current_frame_num = timeline->get_current_frame();
+ const int n_frames = timeline->get_n_frames();
+
+ // Return a value that is simply proportional to the frame position
+ return Clutter::Alpha::MAX_ALPHA * current_frame_num / n_frames;
+}
+
+} // anonymous namespace
+
+int main(int argc, char** argv)
+{
+ Clutter::init(&argc, &argv);
+
+ // Get the stage and set its size and color
+ const Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
+ stage->set_size(200, 200);
+ stage->set_color(Clutter::Color(0x00, 0x00, 0x00, 0xFF));
+
+ // Add a rectangle to the stage
+ rect = Clutter::Rectangle::create(Clutter::Color(0xFF, 0xFF, 0xFF, 0x99));
+ rect->set_size(40, 40);
+ rect->set_position(10, 10);
+ stage->add_actor(rect);
+ rect->show();
+
+ // Show the stage
+ stage->show();
+
+ {
+ const Glib::RefPtr<Clutter::Timeline>
+ timeline = Clutter::Timeline::create(100 /*frames*/, 30 /*fps*/);
+ timeline->set_loop(true);
+ timeline->start();
+
+ // Instead of our custom callback, we could use a standard callback.
+ // For instance, Clutter::Alpha::sine_inc_func.
+ const Glib::RefPtr<Clutter::EffectTemplate>
+ effect = Clutter::EffectTemplate::create(timeline, &on_alpha);
+
+ std::vector<Clutter::Knot> knots (2);
+ knots[0].set_xy(10, 10);
+ knots[1].set_xy(150, 150);
+
+ // Move the actor along the path
+ effect->path(rect, knots);
+
+ // Also change the actor's opacity while moving it along the path:
+ // (You would probably want to use a different ClutterEffectTemplate,
+ // so you could use a different alpha callback for this.)
+ effect->fade(rect, 50);
+ }
+
+ // Start the main loop, so we can respond to events
+ Clutter::main();
+
+ return 0;
+}
Added: cluttermm_tutorial/trunk/examples/score/main.cc
==============================================================================
--- (empty file)
+++ cluttermm_tutorial/trunk/examples/score/main.cc Mon Dec 22 18:36:09 2008
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2008 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include <cluttermm.h>
+
+namespace
+{
+
+static Glib::RefPtr<Clutter::Rectangle> rect;
+
+static int rotation_angle = 0;
+static int color_change_count = 0;
+
+/*
+ * Rotate the rectangle and alternate its color.
+ */
+static void on_timeline_rotation_new_frame(int frame_num,
+ Glib::RefPtr<Clutter::Timeline> timeline)
+{
+ if (++rotation_angle >= 360)
+ rotation_angle = 0;
+
+ // Rotate the rectangle clockwise around the z axis, around
+ // it's top-left corner
+ rect->set_rotation(Clutter::X_AXIS, rotation_angle, 0, 0, 0);
+
+ // Change the color
+ // (This is a silly example, making the rectangle flash)
+ if (++color_change_count > 100)
+ color_change_count = 0;
+
+ if (color_change_count == 0)
+ rect->set_color(Clutter::Color(0xFF, 0xFF, 0xFF, 0x99));
+ else if (color_change_count == 50)
+ rect->set_color(Clutter::Color(0x10, 0x40, 0x90, 0xFF));
+}
+
+/*
+ * Move the rectangle.
+ */
+static void on_timeline_move_new_frame(int frame_num,
+ Glib::RefPtr<Clutter::Timeline> timeline)
+{
+ int x_position = rect->get_x();
+
+ if (++x_position >= 150)
+ x_position = 0;
+
+ rect->set_x(x_position);
+}
+
+} // anonymous namespace
+
+int main(int argc, char** argv)
+{
+ Clutter::init(&argc, &argv);
+
+ // Get the stage and set its size and color
+ const Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
+ stage->set_size(200, 200);
+ stage->set_color(Clutter::Color(0x00, 0x00, 0x00, 0xFF));
+
+ // Add a rectangle to the stage
+ rect = Clutter::Rectangle::create(Clutter::Color(0xFF, 0xFF, 0xFF, 0x99));
+ rect->set_size(70, 70);
+ rect->set_position(50, 100);
+ stage->add_actor(rect);
+ rect->show();
+
+ // Show the stage
+ stage->show();
+
+ // Create a score and add two timelines to it,
+ // so the second timeline starts when the first one stops
+ const Glib::RefPtr<Clutter::Score> score = Clutter::Score::create();
+ score->set_loop(true);
+
+ const Glib::RefPtr<Clutter::Timeline>
+ timeline_rotation = Clutter::Timeline::create(200 /*frames*/, 120 /*fps*/);
+ timeline_rotation->signal_new_frame()
+ .connect(sigc::bind(&on_timeline_rotation_new_frame, timeline_rotation));
+ score->append(timeline_rotation);
+
+ const Glib::RefPtr<Clutter::Timeline>
+ timeline_move = Clutter::Timeline::create(200 /*frames*/, 120 /*fps*/);
+ timeline_move->signal_new_frame()
+ .connect(sigc::bind(&on_timeline_move_new_frame, timeline_move));
+ score->append(timeline_rotation, timeline_move);
+
+ score->start();
+
+ // Start the main loop, so we can respond to events
+ Clutter::main();
+
+ return 0;
+}
Added: cluttermm_tutorial/trunk/examples/timeline/main.cc
==============================================================================
--- (empty file)
+++ cluttermm_tutorial/trunk/examples/timeline/main.cc Mon Dec 22 18:36:09 2008
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2008 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include <cluttermm.h>
+
+namespace
+{
+
+static Glib::RefPtr<Clutter::Rectangle> rect;
+
+static int rotation_angle = 0;
+static int color_change_count = 0;
+
+static void on_timeline_new_frame(int frame_num,
+ Glib::RefPtr<Clutter::Timeline> timeline)
+{
+ if (++rotation_angle >= 360)
+ rotation_angle = 0;
+
+ // Rotate the rectangle clockwise around the z axis, around
+ // it's top-left corner
+ rect->set_rotation(Clutter::X_AXIS, rotation_angle, 0, 0, 0);
+
+ // Change the color
+ // (This is a silly example, making the rectangle flash)
+ if (++color_change_count > 100)
+ color_change_count = 0;
+
+ if (color_change_count == 0)
+ rect->set_color(Clutter::Color(0xFF, 0xFF, 0xFF, 0x99));
+ else if (color_change_count == 50)
+ rect->set_color(Clutter::Color(0x10, 0x40, 0x90, 0xFF));
+}
+
+} // anonymous namespace
+
+int main(int argc, char** argv)
+{
+ Clutter::init(&argc, &argv);
+
+ // Get the stage and set its size and color
+ const Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
+ stage->set_size(200, 200);
+ stage->set_color(Clutter::Color(0x00, 0x00, 0x00, 0xFF));
+
+ // Add a rectangle to the stage
+ rect = Clutter::Rectangle::create(Clutter::Color(0xFF, 0xFF, 0xFF, 0x99));
+ rect->set_size(70, 70);
+ rect->set_position(50, 100);
+ stage->add_actor(rect);
+ rect->show();
+
+ // Show the stage
+ stage->show();
+
+ const Glib::RefPtr<Clutter::Timeline>
+ timeline = Clutter::Timeline::create(10 /*frames*/, 120 /*fps*/);
+ timeline->signal_new_frame()
+ .connect(sigc::bind(&on_timeline_new_frame, timeline));
+ timeline->set_loop(true);
+ timeline->start();
+
+ // Start the main loop, so we can respond to events
+ Clutter::main();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]