Animation
Contents
[
Hide
]
This article demonstrates how to create simple animations and manage their sequence using Aspose.Slides for C++.
Add an Animation
Create a rectangle shape and apply a fade-in effect triggered on click.
static void AddAnimation()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 50, 100, 100);
// Fade effect.
slide->get_Timeline()->get_MainSequence()->AddEffect(
shape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
presentation->Dispose();
}
Access an Animation
Retrieve the first animation effect from the slide timeline.
static void AccessAnimation()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 50, 100, 100);
slide->get_Timeline()->get_MainSequence()->AddEffect(
shape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
// Access the first animation effect.
auto effect = slide->get_Timeline()->get_MainSequenceEffect(0);
presentation->Dispose();
}
Remove an Animation
Remove an animation effect from the sequence.
static void RemoveAnimation()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 50, 100, 100);
auto effect = slide->get_Timeline()->get_MainSequence()->AddEffect(
shape, EffectType::Fade, EffectSubtype::None, EffectTriggerType::OnClick);
// Remove the effect.
slide->get_Timeline()->get_MainSequence()->Remove(effect);
presentation->Dispose();
}
Sequence Animations
Add multiple effects and demonstrate the order in which animations occur.
static void SequenceAnimations()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shape1 = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 50, 100, 100);
auto shape2 = slide->get_Shapes()->AddAutoShape(ShapeType::Ellipse, 200, 50, 100, 100);
auto sequence = slide->get_Timeline()->get_MainSequence();
sequence->AddEffect(shape1, EffectType::Fly, EffectSubtype::Bottom, EffectTriggerType::OnClick);
sequence->AddEffect(shape2, EffectType::Fly, EffectSubtype::Bottom, EffectTriggerType::OnClick);
presentation->Dispose();
}