當前位置: 首頁>>代碼示例>>C#>>正文


C# Ellipse.Reposition方法代碼示例

本文整理匯總了C#中System.Windows.Shapes.Ellipse.Reposition方法的典型用法代碼示例。如果您正苦於以下問題:C# Ellipse.Reposition方法的具體用法?C# Ellipse.Reposition怎麽用?C# Ellipse.Reposition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Shapes.Ellipse的用法示例。


在下文中一共展示了Ellipse.Reposition方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SetupDrawBallsAsControls

        ///<summary>Handles making ellipse controls for each ball in the game, as while as showing their death animations.</summary>
        public static void SetupDrawBallsAsControls(this Game game, PerishableCollection<UIElement> controls, TimeSpan deathFadeOutDuration, double deathFinalRadiusFactor) {
            game.Balls.CurrentAndFutureItems().Subscribe(
                e => {
                    // create an ellipse control to visually represent the ball
                    var ball = e.Value;
                    var color = ball.Hue.HueToApproximateColor(period: 3);
                    var ellipseControl = new Ellipse {
                        Width = ball.Radius * 2,
                        Height = ball.Radius * 2,
                        VerticalAlignment = VerticalAlignment.Top,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Fill = new SolidColorBrush(color)
                    };

                    // 'root' balls have a black border
                    if (ball.Generation == 1) {
                        ellipseControl.StrokeThickness = 3;
                        ellipseControl.Stroke = new SolidColorBrush(Colors.Black);
                    }

                    // reposition ellipse control during each game loop, until ball is dead
                    game.LoopActions.Add(
                        step => ellipseControl.Reposition(ball.Pos, ball.Radius),
                        e.Lifetime);

                    // once ball is dead, expand and fade out the ellipse
                    var controlLifetime = e.Lifetime.ThenResurrect(() =>
                        game.AnimateWith(
                            deathFadeOutDuration,
                            (step, portion, dt) => {
                                // fade out
                                ellipseControl.Fill = new SolidColorBrush(color.LerpToTransparent(portion));
                                // expand
                                var radius = ball.Radius * 1.LerpTo(deathFinalRadiusFactor, portion);
                                ellipseControl.Reposition(ball.Pos, radius);
                            }));

                    controls.Add(ellipseControl, controlLifetime);
                },
                game.Life);
        }
開發者ID:NotYours180,項目名稱:PerishableCollection,代碼行數:42,代碼來源:GameDrawAsControlsUtilities.cs


注:本文中的System.Windows.Shapes.Ellipse.Reposition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。