スライド トランジション

スライド トランジションの追加

理解しやすくするために、Aspose.Slides for C++を使用して、シンプルなスライドトランジションの管理方法を示します。開発者はスライドに異なるスライドトランジション効果を適用できるだけでなく、これらのトランジション効果の動作をカスタマイズすることもできます。シンプルなスライドトランジション効果を作成するには、以下の手順に従ってください。

  1. Presentation クラスのインスタンスを作成します。
  2. Aspose.Slides for C++が提供するトランジション効果のいずれかからスライドにスライドトランジションタイプを適用します。
  3. 修正されたプレゼンテーションファイルを書き込みます。
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String templatePath = u"../templates/SimpleSlideTransitions.pptx";
const String outPath = u"../out/SimpleSlideTransitions.pptx";
// Instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>(templatePath);
// Apply circle type transition on slide 1
pres->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);
// Apply comb type transition on slide 2
pres->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);
// Write the presentation to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

高度なスライド トランジションの追加

上記のセクションでは、スライドにシンプルなトランジション効果を適用しました。次に、そのシンプルなトランジション効果をさらに良くし、制御できるようにするためには、以下の手順に従ってください。

  1. Presentation クラスのインスタンスを作成します。
  2. Aspose.Slides for C++が提供するトランジション効果のいずれかからスライドにスライドトランジションタイプを適用します。
  3. トランジションを「クリックで進める」、「指定された時間後」、「またはその両方」に設定できます。
  4. スライドトランジションが「クリックで進める」に設定されている場合、トランジションはマウスがクリックされるまで進みません。さらに、Advance After Timeプロパティが設定されている場合、指定された進行時間が経過した後にトランジションが自動的に進みます。
  5. 修正されたプレゼンテーションをプレゼンテーションファイルとして書き込みます。
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String templatePath = u"../templates/SimpleSlideTransitions.pptx";
const String outPath = u"../out/BetterSlideTransitions.pptx";
// Instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>(templatePath);
// Apply circle type transition on slide 1
pres->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);
// Set the transition time of 3 seconds
pres->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_AdvanceOnClick(true);
pres->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_AdvanceAfterTime(3000);
// Apply comb type transition on slide 2
pres->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);
// Set the transition time of 5 seconds
pres->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceOnClick(true);
pres->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceAfterTime(5000);
// Write the presentation to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

モーフ トランジション

Aspose.Slides for C++は現在、モーフ トランジションをサポートしています。これは、PowerPoint 2019で導入された新しいモーフトランジションを表します。モーフトランジションを使用すると、スライドから次のスライドへの滑らかな動きをアニメーション化できます。この記事では、モーフトランジションの概念とその使用方法を説明します。モーフトランジションを効果的に使用するには、少なくとも1つの共通のオブジェクトを持つ2つのスライドが必要です。最も簡単な方法は、スライドを複製し、2番目のスライド上のオブジェクトを異なる場所に移動することです。

以下のコードスニペットは、テキストを含むスライドのクローンをプレゼンテーションに追加し、2番目のスライドにモーフタイプのトランジションを設定する方法を示しています。

const String outPath = u"../out/presentation-out.pptx";
auto presentation = System::MakeObject<Presentation>();
auto autoshape = System::DynamicCast<Aspose::Slides::AutoShape>(presentation->get_Slides()->idx_get(0)->get_Shapes()->AddAutoShape(Aspose::Slides::ShapeType::Rectangle, 100, 100, 400, 100));
autoshape->get_TextFrame()->set_Text(u"Test text");
presentation->get_Slides()->AddClone(presentation->get_Slides()->idx_get(0));
auto x = presentation->get_Slides()->idx_get(1)->get_Shapes()->idx_get(0)->get_X();
auto y = presentation->get_Slides()->idx_get(1)->get_Shapes()->idx_get(0)->get_Y();
auto width = presentation->get_Slides()->idx_get(1)->get_Shapes()->idx_get(0)->get_Width();
auto height = presentation->get_Slides()->idx_get(1)->get_Shapes()->idx_get(0)->get_Height();
presentation->get_Slides()->idx_get(1)->get_Shapes()->idx_get(0)->set_X(x + 100);
presentation->get_Slides()->idx_get(1)->get_Shapes()->idx_get(0)->set_Y(y + 50);
presentation->get_Slides()->idx_get(1)->get_Shapes()->idx_get(0)->set_Width(width + 200);
presentation->get_Slides()->idx_get(1)->get_Shapes()->idx_get(0)->set_Height(height + 10);
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Morph);
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

モーフ トランジション タイプ

新しいAspose.Slides.SlideShow.TransitionMorphType列挙型が追加されました。これは、異なるタイプのモーフスライドトランジションを表します。

TransitionMorphType列挙型には3つのメンバーがあります:

  • ByObject: モーフトランジションは、形状を不可分のオブジェクトとして考慮して実行されます。
  • ByWord: モーフトランジションは、可能な場合、単語ごとにテキストを移行します。
  • ByChar: モーフトランジションは、可能な場合、文字ごとにテキストを移行します。

以下のコードスニペットは、スライドにモーフトランジションを設定し、モーフタイプを変更する方法を示しています。

const String inputPath = u"../templates/presentation.pptx";
const String outPath = u"../out/presentation-out.pptx";
auto presentation = System::MakeObject<Presentation>(u"presentation.pptx");
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Morph);
auto morphTransition = System::DynamicCast<Aspose::Slides::SlideShow::IMorphTransition>(presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->get_Value());
morphTransition->set_MorphType(Aspose::Slides::SlideShow::TransitionMorphType::ByWord);
presentation->Save(u"presentation-out.pptx", Aspose::Slides::Export::SaveFormat::Pptx);

トランジション効果の設定

Aspose.Slides for C++は、ブラックから、左から、右からなどのトランジション効果の設定をサポートしています。トランジション効果を設定するには、以下の手順に従ってください:

  • Presentationクラスのインスタンスを作成します。
  • スライドの参照を取得します。
  • トランジション効果を設定します。
  • プレゼンテーションをPPTXファイルとして書き込みます。

以下の例では、トランジション効果を設定しています。

For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String templatePath = u"../templates/SimpleSlideTransitions.pptx";
const String outPath = u"../out/TransitionEffects.pptx";
// Instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>(templatePath);
// Apply circle type transition on slide 1
pres->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Cut);
auto transition = DynamicCast<Aspose::Slides::SlideShow::OptionalBlackTransition>(pres->get_Slides()->idx_get(0)->get_SlideShowTransition()->get_Value());
transition->set_FromBlack(true);
// Write the presentation to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);