Actors can be scaled, rotated, and moved.
Call Clutter::Actor::set_scale()
to increase or decrease the apparent
size of the actor. Note that this will not change the result of Clutter::Actor::get_width()
and Clutter::Actor::get_height()
because it only changes the size of the actor
as seen by the user. Calling Clutter::Actor::set_scale()
again will replace the
first scale rather than multiplying it.
Call Clutter::Actor::set_rotation()
to rotate the actor around an axis,
specifying either Clutter::X_AXIS
, Clutter::Y_AXIS
or
Clutter::Z_AXIS
and the desired angle. Only two of the x, y, and z coordinates
are used, depending on the specified axis. For instance, when using Clutter::X_AXIS
,
the y and z parameters specify the center of rotation on the plane of the x axis.
Like the Clutter::Actor::set_scale()
, this does not affect the position,
width, or height of the actor as returned by functions such as
Clutter::Actor::get_x()
.
Actors
may be "clipped" so that only one rectangular part of
the actor is visible, by calling Clutter::Actor::set_clip()
, providing a
position relative to the actor, along with the size. For instance, you might implement scrolling by
creating a large container actor and setting a clip rectangle so that only a small part of the whole
is visible at any one time. Scrolling up could then be implemented by moving the actor down while
moving the clip up. Clipping can be reverted by calling
Clutter::Actor::remove_clip()
.
The area outside of the clip does not consume video memory and generally does not require much processing.
Cluttermm does not have a translation method that behaves similarly to
Clutter::Actor::set_scale()
and
Clutter::Actor::set_rotation()
, but you can move the actor by calling
Clutter::Actor::move_by()
or
Clutter::Actor::set_depth
.
Unlike the scaling and rotation methods, Clutter::Actor::move_by()
does
change the result of methods such as Clutter::Actor::get_x()
.
The following example demonstrates two unmoving actors in a stage, using rotation, scaling and movement:
File: main.cc
#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; }