質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
WPF

Windows Presentation Foundation (WPF) は、魅力的な外観のユーザー エクスペリエンスを持つ Windows クライアント アプリケーションを作成するための次世代プレゼンテーション システムです

Q&A

1回答

3319閲覧

WPFによるパスアニメーション

hogesugi

総合スコア10

WPF

Windows Presentation Foundation (WPF) は、魅力的な外観のユーザー エクスペリエンスを持つ Windows クライアント アプリケーションを作成するための次世代プレゼンテーション システムです

0グッド

0クリップ

投稿2016/08/23 07:23

編集2016/08/23 09:04

ベジエ曲線に沿ってアニメーションさせることは出来たのですが、スプライン曲線に沿ってアニメーションさせる方法がわかりません。
そもそも可能なのでしょうか?
XAMLのコードを追記します。(ベジエ曲線に沿ったアニメーション)

<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="PresentationOptions" Margin="20" Title="howto_path_animation" Height="400" Width="400">
<Canvas Width="400" Height="400">
<Path Stroke="Red" StrokeThickness="1">
<Path.Data>
<PathGeometry Figures="M 10,200 C 35,100 135,100 160,200 180,350 285,300 310,100"/>
</Path.Data>
</Path>

<Rectangle Width="50" Height="20" Fill="LightBlue" Stroke="Blue"> <Rectangle.RenderTransform> <TransformGroup> <TranslateTransform X="-30" Y="-10"/> <MatrixTransform x:Name="rectangleTransform"> <MatrixTransform.Matrix > <Matrix /> </MatrixTransform.Matrix> </MatrixTransform> </TransformGroup> </Rectangle.RenderTransform> <Rectangle.Triggers> <EventTrigger RoutedEvent="Rectangle.Loaded"> <BeginStoryboard> <Storyboard> <MatrixAnimationUsingPath Storyboard.TargetName="rectangleTransform" Storyboard.TargetProperty="Matrix" DoesRotateWithTangent="True" Duration="0:0:3" RepeatBehavior="Forever" > <MatrixAnimationUsingPath.PathGeometry> <PathGeometry Figures="M 10,200 C 35,100 135,100 160,200 180,350 285,300 310,100" /> </MatrixAnimationUsingPath.PathGeometry> </MatrixAnimationUsingPath> </Storyboard> </BeginStoryboard> </EventTrigger> </Rectangle.Triggers> </Rectangle> </Canvas>
</Window>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2016/08/23 07:49

まずベジエ曲線でやったプログラムを書いてどんな流れでやっているかを見せたほうが回答者も回答しやすいと思いますよ。ただ文章だけというのも分かりにくいと思いますし。
hogesugi

2016/08/23 08:41

アドバイスありがとうございます。 XAMLのコードを追記します。(ベジエ曲線に沿ったアニメーション) <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="PresentationOptions" Margin="20" Title="howto_path_animation" Height="400" Width="400"> <Canvas Width="400" Height="400"> <Path Stroke="Red" StrokeThickness="1"> <Path.Data> <PathGeometry Figures="M 10,200 C 35,100 135,100 160,200 180,350 285,300 310,100"/> </Path.Data> </Path> <Rectangle Width="50" Height="20" Fill="LightBlue" Stroke="Blue"> <Rectangle.RenderTransform> <TransformGroup> <TranslateTransform X="-30" Y="-10"/> <MatrixTransform x:Name="rectangleTransform"> <MatrixTransform.Matrix > <Matrix /> </MatrixTransform.Matrix> </MatrixTransform> </TransformGroup> </Rectangle.RenderTransform> <Rectangle.Triggers> <EventTrigger RoutedEvent="Rectangle.Loaded"> <BeginStoryboard> <Storyboard> <MatrixAnimationUsingPath Storyboard.TargetName="rectangleTransform" Storyboard.TargetProperty="Matrix" DoesRotateWithTangent="True" Duration="0:0:3" RepeatBehavior="Forever" > <MatrixAnimationUsingPath.PathGeometry> <PathGeometry Figures="M 10,200 C 35,100 135,100 160,200 180,350 285,300 310,100" /> </MatrixAnimationUsingPath.PathGeometry> </MatrixAnimationUsingPath> </Storyboard> </BeginStoryboard> </EventTrigger> </Rectangle.Triggers> </Rectangle> </Canvas> </Window>
guest

回答1

0

多分簡単には出来ないと思います。

JavaFXのPathもSVGのPath仕様もどれをみても2次/3次ベジエ曲線はありますがβスプラインはないようです。

より高度なグラフィックライブラリー(OpenGLなど)はβスプライン曲線をサポートしているものもあるようですが、一般的にはベジエ曲線のみサポートというものが多いのかも知れません。

対応としては、より多くの制御点を用いてベジエ曲線で近似するしか方法はないと思います。

投稿2016/11/11 18:27

KSwordOfHaste

総合スコア18394

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問