New Cursors, Font Support, Timer to force Foreground.
This commit is contained in:
Родитель
dea891eb87
Коммит
577320e57d
|
@ -36,7 +36,7 @@
|
|||
<PublisherName>Scott Hanselman</PublisherName>
|
||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||
<WebPage>publish.htm</WebPage>
|
||||
<ApplicationRevision>36</ApplicationRevision>
|
||||
<ApplicationRevision>43</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
|
@ -117,6 +117,10 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Shapes\FunCursor1.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="Shapes\CoolCircle.xaml.cs">
|
||||
<DependentUpon>CoolCircle.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -135,6 +139,9 @@
|
|||
<Compile Include="Shapes\CoolTrapezoid.xaml.cs">
|
||||
<DependentUpon>CoolTrapezoid.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Shapes\FunCursor1.xaml.cs">
|
||||
<DependentUpon>FunCursor1.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
|
@ -161,6 +168,10 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Shapes\FunCursor2.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
|
@ -201,8 +212,14 @@
|
|||
<Compile Include="Shapes\CoolRectangle.xaml.cs">
|
||||
<DependentUpon>CoolRectangle.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Shapes\FunCursor2.xaml.cs">
|
||||
<DependentUpon>FunCursor2.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Shapes\Figure.cs" />
|
||||
<Compile Include="Shapes\FigureGenerator.cs" />
|
||||
<Compile Include="Tweening\Equations.cs" />
|
||||
<Compile Include="Tweening\TransitionType.cs" />
|
||||
<Compile Include="Tweening\Tween.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace BabySmash
|
|||
//m.Height = 600;
|
||||
//m.Left = 900;
|
||||
//m.Top = 500;
|
||||
//TODO: END - COMMENT IN for Debugging
|
||||
////TODO: END - COMMENT IN for Debugging
|
||||
|
||||
//TODO: Start - COMMENT OUT for Debugging
|
||||
m.WindowState = WindowState.Maximized;
|
||||
|
@ -233,6 +233,7 @@ namespace BabySmash
|
|||
foreach (MainWindow m in this.windows)
|
||||
{
|
||||
m.Topmost = true;
|
||||
m.ResetCanvas();
|
||||
}
|
||||
isOptionsDialogShown = false;
|
||||
}
|
||||
|
@ -288,7 +289,7 @@ namespace BabySmash
|
|||
private void MouseDraw(MainWindow main, Point p)
|
||||
{
|
||||
//sanity check
|
||||
if (main.mainCanvas.Children.Count > 300) main.mainCanvas.Children.Clear();
|
||||
if (main.mainCanvas.Children.Count > 300) ResetCanvas(main);
|
||||
|
||||
//randomize at some point?
|
||||
Shape shape = new Ellipse
|
||||
|
@ -307,6 +308,11 @@ namespace BabySmash
|
|||
audio.PlayWavResourceYield(".Resources.Sounds." + "smallbumblebee.wav");
|
||||
}
|
||||
|
||||
private static void ResetCanvas(MainWindow main)
|
||||
{
|
||||
main.ResetCanvas();
|
||||
}
|
||||
|
||||
public void LostMouseCapture(MainWindow main, MouseEventArgs e)
|
||||
{
|
||||
if (Settings.Default.MouseDraw) return;
|
||||
|
|
|
@ -4,30 +4,56 @@
|
|||
xmlns:local="clr-namespace:BabySmash"
|
||||
Title="Baby Smash by Scott Hanselman - http://www.hanselman.com/babysmash"
|
||||
Height="500" Width="500" WindowStyle="None" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
>
|
||||
>
|
||||
|
||||
<!--<Window.Triggers>
|
||||
<EventTrigger RoutedEvent="Window.Loaded">
|
||||
<EventTrigger.Actions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard RepeatBehavior="Forever">
|
||||
<ColorAnimation
|
||||
AutoReverse="True"
|
||||
Duration="0:0:9"
|
||||
From="#00822121"
|
||||
Storyboard.TargetName="GradientStop1"
|
||||
Storyboard.TargetProperty="Color"
|
||||
Timeline.DesiredFrameRate="10"
|
||||
To="#FFFFFFFF"/>
|
||||
<ColorAnimation
|
||||
AutoReverse="True"
|
||||
Duration="0:0:9"
|
||||
From="AntiqueWhite"
|
||||
Storyboard.TargetName="GradientStop2"
|
||||
Storyboard.TargetProperty="Color"
|
||||
Timeline.DesiredFrameRate="10"
|
||||
To="LightCoral"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger.Actions>
|
||||
</EventTrigger>
|
||||
</Window.Triggers>
|
||||
|
||||
<Window.Background>
|
||||
<RadialGradientBrush>
|
||||
<RadialGradientBrush.RelativeTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform
|
||||
CenterX="0.5"
|
||||
CenterY="0.5"
|
||||
ScaleX="1.15"
|
||||
ScaleY="1.15"/>
|
||||
<TranslateTransform X="-0.08" Y="-0.08"/>
|
||||
</TransformGroup>
|
||||
</RadialGradientBrush.RelativeTransform>
|
||||
<GradientStop x:Name="GradientStop1" Offset="0" Color="#0095B1FF"/>
|
||||
<GradientStop x:Name="GradientStop2" Offset="1" Color="#FF719300"/>
|
||||
</RadialGradientBrush>
|
||||
</Window.Background>-->
|
||||
|
||||
<Grid Name="mainGrid">
|
||||
<TextBlock FontSize="10">
|
||||
<TextBlock FontSize="10">
|
||||
<Bold>BabySmash!</Bold> by Scott Hanselman <Italic>with many community contributions!</Italic> - http://www.babysmash.com
|
||||
<LineBreak /><Bold>Ctrl-Shift-Alt-O</Bold> for options, <Bold>ALT-F4</Bold> to exit</TextBlock>
|
||||
<Canvas Name="mainCanvas"/>
|
||||
|
||||
<!--<ItemsControl Name="figuresControl" ItemsSource="{Binding Path=Figures}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentPresenter />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemContainerStyle>
|
||||
<Style>
|
||||
<Setter Property="Canvas.Left" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}},Path=ShapeLeft}"/>
|
||||
<Setter Property="Canvas.Top" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}},Path=ShapeTop}"/>
|
||||
</Style>
|
||||
</ItemsControl.ItemContainerStyle>
|
||||
</ItemsControl>-->
|
||||
</Grid>
|
||||
</Window>
|
|
@ -11,6 +11,7 @@ using System.Windows.Input;
|
|||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using BabySmash.Properties;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace BabySmash
|
||||
{
|
||||
|
@ -19,16 +20,23 @@ namespace BabySmash
|
|||
private readonly Controller controller;
|
||||
public Controller Controller { get { return controller; } }
|
||||
|
||||
private UserControl customCursor;
|
||||
public UserControl CustomCursor { get { return customCursor; } set { customCursor = value; } }
|
||||
|
||||
public void AddUserControl(UserControl c)
|
||||
{
|
||||
this.mainCanvas.Children.Add(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public MainWindow(Controller c)
|
||||
{
|
||||
this.controller = c;
|
||||
this.DataContext = controller;
|
||||
InitializeComponent();
|
||||
|
||||
ResetCanvas();
|
||||
}
|
||||
|
||||
protected override void OnMouseWheel(MouseWheelEventArgs e)
|
||||
|
@ -49,9 +57,31 @@ namespace BabySmash
|
|||
controller.MouseDown(this, e);
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseEnter(e);
|
||||
CustomCursor.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
CustomCursor.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
CustomCursor.Visibility = Visibility.Visible;
|
||||
Point p = e.GetPosition(mainCanvas);
|
||||
double pX = p.X;
|
||||
double pY = p.Y;
|
||||
Cursor = Cursors.None;
|
||||
Canvas.SetTop(CustomCursor, pY);
|
||||
Canvas.SetLeft(CustomCursor, pX);
|
||||
Canvas.SetZIndex(CustomCursor, int.MaxValue);
|
||||
|
||||
controller.MouseMove(this, e);
|
||||
}
|
||||
|
||||
|
@ -67,5 +97,23 @@ namespace BabySmash
|
|||
base.OnLostMouseCapture(e);
|
||||
controller.LostMouseCapture(this, e);
|
||||
}
|
||||
|
||||
internal void ResetCanvas()
|
||||
{
|
||||
try
|
||||
{
|
||||
mainCanvas.Children.Clear();
|
||||
CustomCursor = Utils.GetCursor();
|
||||
CustomCursor.RenderTransform = new ScaleTransform(0.5, 0.5);
|
||||
CustomCursor.Name = "customCursor";
|
||||
mainCanvas.Children.Insert(0, CustomCursor); //in front!
|
||||
CustomCursor.Visibility = Visibility.Hidden;
|
||||
}
|
||||
catch (System.NotSupportedException)
|
||||
{
|
||||
//we can die here if we ALT-F4 while in the Options Dialog
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
42
Options.xaml
42
Options.xaml
|
@ -4,7 +4,7 @@
|
|||
xmlns:local="clr-namespace:BabySmash.Properties"
|
||||
xmlns:l="clr-namespace:BabySmash"
|
||||
Title="Baby Smash! - Options"
|
||||
Height="261" Width="542"
|
||||
Height="348" Width="542"
|
||||
ShowInTaskbar="True"
|
||||
Topmost="True"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
|
@ -12,6 +12,7 @@
|
|||
ResizeMode="NoResize">
|
||||
<Window.Resources>
|
||||
<local:Settings x:Key="settings" />
|
||||
<CollectionViewSource Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}" x:Key="myFonts"/>
|
||||
</Window.Resources>
|
||||
<Grid DataContext="{StaticResource settings}" Width="Auto">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
@ -22,6 +23,8 @@
|
|||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" MinHeight="20" />
|
||||
<RowDefinition Height="Auto" MinHeight="43" />
|
||||
<RowDefinition Height="Auto" MinHeight="43" />
|
||||
<RowDefinition Height="Auto" MinHeight="43" />
|
||||
<RowDefinition Height="Auto" MinHeight="20" />
|
||||
<RowDefinition Height="Auto" MinHeight="20" />
|
||||
<RowDefinition Height="Auto" MinHeight="20" />
|
||||
|
@ -54,24 +57,49 @@
|
|||
<ComboBoxItem>Laughter</ComboBoxItem>
|
||||
<ComboBoxItem>Speech</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<CheckBox Grid.Row="2" Grid.ColumnSpan="2" Grid.Column="0" Margin="15,0,0,0"
|
||||
<Label Height="23" Grid.Row="2" Margin="10">Cursor</Label>
|
||||
<ComboBox
|
||||
SelectedValue="{Binding Path=Default.CursorType}"
|
||||
SelectedValuePath="Content" Grid.Row="2" Height="23" Margin="70,10,7,0" Grid.ColumnSpan="2" VerticalAlignment="Top">
|
||||
<ComboBoxItem>Hand</ComboBoxItem>
|
||||
<ComboBoxItem>Arrow</ComboBoxItem>
|
||||
</ComboBox>
|
||||
|
||||
|
||||
<Label Height="23" Grid.Row="3" Margin="10">Font</Label>
|
||||
<ComboBox MaxDropDownHeight="150" x:Name="FontChooser" Grid.Row="3" Margin="70,10,7,0"
|
||||
ItemsSource="{Binding Source={StaticResource myFonts}}"
|
||||
SelectedValue="{Binding Path=Default.FontFamily}" SelectedValuePath="Source" Height="23" VerticalAlignment="Top" Grid.ColumnSpan="2">
|
||||
<ComboBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ComboBox.ItemsPanel>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" FontFamily="{Binding}" Height="20"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<CheckBox Grid.Row="4" Grid.ColumnSpan="2" Grid.Column="0" Margin="15,0,0,0"
|
||||
IsChecked="{Binding Path=Default.ForceUppercase,Mode=TwoWay}" >
|
||||
Force Letters to UPPERCASE
|
||||
</CheckBox>
|
||||
<CheckBox Grid.Row="3" Grid.ColumnSpan="2" Grid.Column="0" Margin="15,0,0,0"
|
||||
<CheckBox Grid.Row="5" Grid.ColumnSpan="2" Grid.Column="0" Margin="15,0,0,0"
|
||||
IsChecked="{Binding Path=Default.FacesOnShapes,Mode=TwoWay}" >
|
||||
Faces on Shapes
|
||||
</CheckBox>
|
||||
<CheckBox Grid.Row="4" Grid.ColumnSpan="2" Grid.Column="0" Margin="15,0,0,0"
|
||||
<CheckBox Grid.Row="6" Grid.ColumnSpan="2" Grid.Column="0" Margin="15,0,0,0"
|
||||
IsChecked="{Binding Path=Default.BitmapEffects,Mode=TwoWay}" IsEnabled="False">
|
||||
Effects (DISABLED FOR NOW)
|
||||
</CheckBox>
|
||||
<CheckBox Grid.Row="5" Grid.ColumnSpan="2" Grid.Column="0" Margin="15,0,0,0"
|
||||
<CheckBox Grid.Row="7" Grid.ColumnSpan="2" Grid.Column="0" Margin="15,0,0,0"
|
||||
IsChecked="{Binding Path=Default.MouseDraw,Mode=TwoWay}" >
|
||||
Clickless Mouse Drawing
|
||||
</CheckBox>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Grid.Row="6" Grid.ColumnSpan="2" HorizontalAlignment="Stretch">
|
||||
Grid.Row="8" Grid.ColumnSpan="2" HorizontalAlignment="Stretch">
|
||||
<CheckBox x:Name="FadeChecked" Margin="15,0,0,0"
|
||||
IsChecked="{Binding Path=Default.FadeAway,Mode=TwoWay}" >
|
||||
Fade Shapes Away in</CheckBox>
|
||||
|
@ -82,7 +110,7 @@
|
|||
<TextBlock Margin="5,0,0,0">secs.</TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="8" Grid.ColumnSpan="2" HorizontalAlignment="Right">
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="9" Grid.ColumnSpan="2" HorizontalAlignment="Right">
|
||||
<Button Name="okButton" IsDefault="True" Margin="0,7,10,7" Padding="30,0,30,0" Click="OK_Click" >OK</Button>
|
||||
<Button IsCancel="True" Margin="5,7,7,7" Padding="15,0,15,0" Click="Cancel_Click" Width="77">Cancel</Button>
|
||||
</StackPanel>
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace BabySmash.Properties {
|
|||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("65")]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("35")]
|
||||
public int ClearAfter {
|
||||
get {
|
||||
return ((int)(this["ClearAfter"]));
|
||||
|
@ -118,5 +118,29 @@ namespace BabySmash.Properties {
|
|||
this["Sounds"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Hand")]
|
||||
public string CursorType {
|
||||
get {
|
||||
return ((string)(this["CursorType"]));
|
||||
}
|
||||
set {
|
||||
this["CursorType"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Arial")]
|
||||
public string FontFamily {
|
||||
get {
|
||||
return ((string)(this["FontFamily"]));
|
||||
}
|
||||
set {
|
||||
this["FontFamily"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="ClearAfter" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">65</Value>
|
||||
<Value Profile="(Default)">35</Value>
|
||||
</Setting>
|
||||
<Setting Name="MouseDraw" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
|
@ -26,5 +26,11 @@
|
|||
<Setting Name="Sounds" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">Speech</Value>
|
||||
</Setting>
|
||||
<Setting Name="CursorType" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">Hand</Value>
|
||||
</Setting>
|
||||
<Setting Name="FontFamily" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">Arial</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
|
@ -163,10 +163,5 @@ namespace BabySmash
|
|||
fe.RenderTransform = new ScaleTransform(1, 1);
|
||||
fe.RenderTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da);
|
||||
}
|
||||
|
||||
public static void DoZoom(FrameworkElement lastEnteredUserControl)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,14 +43,13 @@ namespace BabySmash
|
|||
CultureInfo.CurrentCulture,
|
||||
FlowDirection.LeftToRight,
|
||||
new Typeface(
|
||||
new FontFamily("Arial"),
|
||||
new FontFamily(Properties.Settings.Default.FontFamily),
|
||||
FontStyles.Normal,
|
||||
FontWeights.Heavy,
|
||||
FontStretches.Normal),
|
||||
300,
|
||||
Brushes.Black
|
||||
);
|
||||
|
||||
return fText.BuildGeometry(new Point(0, 0)).GetAsFrozen() as Geometry;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,21 +4,23 @@ using System.Windows.Controls;
|
|||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
using BrushControlFunc = System.Func<System.Windows.Media.Brush, System.Windows.Controls.UserControl>;
|
||||
using System.Windows;
|
||||
|
||||
namespace BabySmash
|
||||
{
|
||||
public class FigureTemplate
|
||||
{
|
||||
public Brush Fill { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public BrushControlFunc GeneratorFunc { get; set; }
|
||||
public BitmapEffect Effect { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Letter { get; set; }
|
||||
}
|
||||
public class FigureTemplate
|
||||
{
|
||||
public Brush Fill { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public BrushControlFunc GeneratorFunc { get; set; }
|
||||
public BitmapEffect Effect { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Letter { get; set; }
|
||||
}
|
||||
|
||||
public class FigureGenerator
|
||||
{
|
||||
private static readonly List<KeyValuePair<string, BrushControlFunc>> hashTableOfFigureGenerators = new List<KeyValuePair<string, BrushControlFunc>>
|
||||
public class FigureGenerator
|
||||
{
|
||||
private static readonly List<KeyValuePair<string, BrushControlFunc>> hashTableOfFigureGenerators = new List<KeyValuePair<string, BrushControlFunc>>
|
||||
{
|
||||
new KeyValuePair<string, BrushControlFunc>("Circle", x => new CoolCircle(x) ),
|
||||
new KeyValuePair<string, BrushControlFunc>("Rectangle", x => new CoolRectangle(x) ),
|
||||
|
@ -30,46 +32,59 @@ namespace BabySmash
|
|||
new KeyValuePair<string, BrushControlFunc>("Heart", x => new CoolHeart(x) )
|
||||
};
|
||||
|
||||
public static UserControl NewUserControlFrom(FigureTemplate template)
|
||||
{
|
||||
UserControl retVal = null;
|
||||
//We'll wait for Hardware Accelerated Shader Effects in SP1
|
||||
public static UserControl NewUserControlFrom(FigureTemplate template)
|
||||
{
|
||||
UserControl retVal = null;
|
||||
//We'll wait for Hardware Accelerated Shader Effects in SP1
|
||||
|
||||
if (template.Letter.Length == 1 && Char.IsLetterOrDigit(template.Letter[0]))
|
||||
{
|
||||
retVal = new CoolLetter(template.Fill.Clone(), template.Letter);
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = template.GeneratorFunc(template.Fill.Clone());
|
||||
}
|
||||
if (template.Letter.Length == 1 && Char.IsLetterOrDigit(template.Letter[0]))
|
||||
{
|
||||
retVal = new CoolLetter(template.Fill.Clone(), template.Letter);
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = template.GeneratorFunc(template.Fill.Clone());
|
||||
}
|
||||
|
||||
//TODO: TOO SLOW! Waiting for ShaderEffects in 3.5SP1
|
||||
//if (Settings.Default.BitmapEffects)
|
||||
//{
|
||||
// retVal.BitmapEffect = template.Effect.Clone();
|
||||
//}
|
||||
return retVal;
|
||||
}
|
||||
Tweener.TransitionType randomTransition1 = (Tweener.TransitionType)Utils.RandomBetweenTwoNumbers(1, (int)Tweener.TransitionType.EaseOutInBounce);
|
||||
var ani1 = Tweener.Tween.CreateAnimation(randomTransition1, 0, 1, new TimeSpan(0, 0, 0, 1),30);
|
||||
Tweener.TransitionType randomTransition2 = (Tweener.TransitionType)Utils.RandomBetweenTwoNumbers(1, (int)Tweener.TransitionType.EaseOutInBounce);
|
||||
var ani2 = Tweener.Tween.CreateAnimation(randomTransition2, 360, 0, new TimeSpan(0, 0, 0, 1),30);
|
||||
retVal.RenderTransformOrigin = new Point(0.5, 0.5);
|
||||
var group = new TransformGroup();
|
||||
group.Children.Add(new ScaleTransform());
|
||||
group.Children.Add(new RotateTransform());
|
||||
retVal.RenderTransform = group;
|
||||
group.Children[0].BeginAnimation(ScaleTransform.ScaleXProperty, ani1);
|
||||
group.Children[0].BeginAnimation(ScaleTransform.ScaleYProperty, ani1);
|
||||
group.Children[1].BeginAnimation(RotateTransform.AngleProperty, ani2);
|
||||
|
||||
//TODO: Should this be in XAML? Would that make it better?
|
||||
//TODO: Should I change the height, width and stroke to be relative to the screen size?
|
||||
//TODO: Where can I get REALLY complex shapes like animal vectors or custom pics? Where do I store them?
|
||||
//TODO: TOO SLOW! Waiting for ShaderEffects in 3.5SP1
|
||||
//if (Settings.Default.BitmapEffects)
|
||||
//{
|
||||
// retVal.BitmapEffect = template.Effect.Clone();
|
||||
//}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static FigureTemplate GenerateFigureTemplate(string letter)
|
||||
{
|
||||
Color c = Utils.GetRandomColor();
|
||||
//TODO: Should this be in XAML? Would that make it better?
|
||||
//TODO: Should I change the height, width and stroke to be relative to the screen size?
|
||||
//TODO: Where can I get REALLY complex shapes like animal vectors or custom pics? Where do I store them?
|
||||
|
||||
var nameFunc = hashTableOfFigureGenerators[Utils.RandomBetweenTwoNumbers(0, hashTableOfFigureGenerators.Count - 1)];
|
||||
return new FigureTemplate
|
||||
{
|
||||
Color = c,
|
||||
Name = (letter.Length == 1 && Char.IsLetterOrDigit(letter[0])) ? letter : nameFunc.Key,
|
||||
GeneratorFunc = nameFunc.Value,
|
||||
Fill = Utils.GetGradientBrush(c),
|
||||
Letter = letter,
|
||||
Effect = Animation.GetRandomBitmapEffect()
|
||||
};
|
||||
}
|
||||
}
|
||||
public static FigureTemplate GenerateFigureTemplate(string letter)
|
||||
{
|
||||
Color c = Utils.GetRandomColor();
|
||||
|
||||
var nameFunc = hashTableOfFigureGenerators[Utils.RandomBetweenTwoNumbers(0, hashTableOfFigureGenerators.Count - 1)];
|
||||
return new FigureTemplate
|
||||
{
|
||||
Color = c,
|
||||
Name = (letter.Length == 1 && Char.IsLetterOrDigit(letter[0])) ? letter : nameFunc.Key,
|
||||
GeneratorFunc = nameFunc.Value,
|
||||
Fill = Utils.GetGradientBrush(c),
|
||||
Letter = letter,
|
||||
Effect = Animation.GetRandomBitmapEffect()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<UserControl
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="BabySmash.FunCursor1"
|
||||
x:Name="UserControl">
|
||||
<Grid x:Name="LayoutRoot">
|
||||
<!-- Layer 1/<Group>/<Path> -->
|
||||
<Path StrokeThickness="10.000000" Stroke="#ff000000" StrokeMiterLimit="1.000000" Data="F1 M 124.528320,114.327637 C 128.416992,110.438477 128.416992,104.074219 124.528320,100.185059 L 85.715820,61.372070 C 81.827148,57.482910 82.737305,52.428711 87.738281,50.141113 L 104.982422,42.252441 C 109.983398,39.964844 109.790039,36.723633 104.549805,35.049805 L 11.955566,5.472656 C 6.716309,3.798828 3.798828,6.716309 5.472656,11.955566 L 35.049805,104.547852 C 36.723633,109.787109 39.964844,109.981445 42.252930,104.979980 L 50.140625,87.738281 C 52.428711,82.736816 57.483398,81.826660 61.372070,85.715820 L 100.184570,124.529297 C 104.073242,128.418945 110.437500,128.418945 114.327148,124.529297 L 124.528320,114.327637 Z">
|
||||
<Path.Fill>
|
||||
<RadialGradientBrush MappingMode="Absolute" GradientOrigin="331.500488,395.500000" Center="331.500488,395.500000" RadiusX="196.575211" RadiusY="196.575211">
|
||||
<RadialGradientBrush.GradientStops>
|
||||
<GradientStop Offset="0.000000" Color="#ff00ffff"/>
|
||||
<GradientStop Offset="1.000000" Color="#ff0000ff"/>
|
||||
</RadialGradientBrush.GradientStops>
|
||||
<RadialGradientBrush.Transform>
|
||||
<MatrixTransform Matrix="1.000000,0.000000,-0.000000,-1.000000,-301.049805,425.642578" />
|
||||
</RadialGradientBrush.Transform>
|
||||
</RadialGradientBrush>
|
||||
</Path.Fill>
|
||||
</Path>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace BabySmash
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FunCursor1.xaml
|
||||
/// </summary>
|
||||
public partial class FunCursor1
|
||||
{
|
||||
public FunCursor1()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<UserControl
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="BabySmash.FunCursor2"
|
||||
x:Name="UserControl">
|
||||
|
||||
<Grid x:Name="LayoutRoot">
|
||||
<!-- Layer 1/<Compound Path> -->
|
||||
<Path StrokeThickness="10.000000" Stroke="#ff000000" StrokeMiterLimit="1.000000" Data="F1 M 160.514648,200.903320 C 151.557617,209.861328 141.947266,216.224609 131.682617,219.984375 L 115.522461,203.824219 C 103.382813,206.287109 89.256836,205.027344 73.132813,200.036133 C 70.903320,198.375000 68.467773,196.377930 65.874023,194.064453 C 63.270508,191.768555 60.490234,189.119141 57.532227,186.151367 C 46.186523,174.805664 39.262695,166.342773 36.771484,160.735352 C 34.270508,155.136719 35.194336,150.163086 39.533203,145.833984 C 40.186523,145.180664 41.082031,144.424805 42.249023,143.557617 C 35.157227,134.450195 35.800781,125.698242 44.189453,117.319336 L 47.446289,114.063477 C 43.685547,105.833984 45.672852,97.846680 53.408203,90.111328 L 59.697266,83.822266 L 25.332031,48.161133 L 19.155273,42.189453 C 11.999023,35.032227 7.557617,28.715820 5.821289,23.219727 C 4.085938,17.724121 5.103516,13.105469 8.854492,9.345215 C 13.052734,5.155762 18.147461,3.989258 24.137695,5.874023 C 30.137695,7.749512 37.041992,12.592285 44.842773,20.401855 L 52.754883,28.314453 L 91.244141,65.067383 L 127.885742,75.686523 C 138.055664,94.142578 147.956055,117.478516 157.584961,145.721680 L 180.902344,169.039063 C 177.431641,180.161133 170.638672,190.780273 160.514648,200.903320 L 160.514648,200.903320 Z">
|
||||
<Path.Fill>
|
||||
<RadialGradientBrush MappingMode="Absolute" GradientOrigin="656.874023,246.266602" Center="656.874023,246.266602" RadiusX="98.208900" RadiusY="98.208900">
|
||||
<RadialGradientBrush.GradientStops>
|
||||
<GradientStop Offset="0.000000" Color="#ff00ffff"/>
|
||||
<GradientStop Offset="1.000000" Color="#ff0000ff"/>
|
||||
</RadialGradientBrush.GradientStops>
|
||||
<RadialGradientBrush.Transform>
|
||||
<MatrixTransform Matrix="1.000000,0.000000,-0.000000,-1.000000,-563.922852,358.758789" />
|
||||
</RadialGradientBrush.Transform>
|
||||
</RadialGradientBrush>
|
||||
</Path.Fill>
|
||||
</Path>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace BabySmash
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FunCursor2.xaml
|
||||
/// </summary>
|
||||
public partial class FunCursor2
|
||||
{
|
||||
public FunCursor2()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
|
||||
<!-- BOF Hexagon -->
|
||||
<Canvas x:Name="Hexagon" Height="10" HorizontalAlignment="Left" Width="6.666" Margin="-252.333,-139,0,0" VerticalAlignment="Top">
|
||||
<Canvas x:Name="Hexagon" Height="10" HorizontalAlignment="Left" Width="6.666" Margin="-252.333,-139,0,0" VerticalAlignment="Top" Background="{x:Null}">
|
||||
<Path StrokeThickness="10" Stroke="#ff000000" StrokeMiterLimit="1" Data="F1 M 61.853516,199.267578 L 5.773438,102.133789 L 61.853516,5 L 174.013672,5 L 230.093750,102.133789 L 174.013672,199.267578 L 61.853516,199.267578 Z">
|
||||
<Path.Fill>
|
||||
<RadialGradientBrush MappingMode="Absolute" GradientOrigin="664.333008,431.5" Center="664.333008,431.5" RadiusX="104.916328" RadiusY="104.916328">
|
||||
|
@ -152,6 +152,14 @@
|
|||
<Path Fill="#ff000000" Data="F1 M 121.578613,114.592773 C 121.578613,120.943848 116.429199,126.092773 110.078613,126.092773 C 103.727051,126.092773 98.578613,120.943848 98.578613,114.592773 C 98.578613,108.241699 103.727051,103.092773 110.078613,103.092773 C 116.429199,103.092773 121.578613,108.241699 121.578613,114.592773 Z" Canvas.Top="-31.134" d:LayoutOverrides="Width, Height, GridBox" Canvas.Left="1"/>
|
||||
<Path Fill="#ff000000" Data="F1 M 154.578613,114.592773 C 154.578613,120.943848 149.430176,126.092773 143.078613,126.092773 C 136.727051,126.092773 131.578613,120.943848 131.578613,114.592773 C 131.578613,108.241699 136.727051,103.092773 143.078613,103.092773 C 149.430176,103.092773 154.578613,108.241699 154.578613,114.592773 Z" Canvas.Left="31.333" Canvas.Top="-31.134" d:LayoutOverrides="Width, Height, GridBox"/>
|
||||
</Canvas>
|
||||
<Path x:Name="Cursor" Stretch="Fill" Stroke="#FF000000" HorizontalAlignment="Left" Margin="-446.3,-371.719,0,0" VerticalAlignment="Top" Width="143.584" Height="242.641" Data="M-388.79815,-186.07812 L-311.5,-186.5 C-301.26965,-227.69763 -290.97216,-271.46234 -289.70991,-315.84205 -288.82618,-338.82563 -291.16628,-358.76561 -308.56356,-349.12321 -316.28716,-340.97096 -312.17065,-320.93753 -312.5,-306.5 L-312.5,-359.5 C-319.59471,-370.66963 -329.08524,-371.37546 -337.3099,-361.13706 L-335.5,-306.5 -337.73897,-370.14745 C-338.16803,-380.44503 -357.6304,-379.9879 -363.0538,-371.00558 L-363.5,-315.5 -364.22203,-418.73169 C-372.02653,-431.22202 -379.17397,-430.245 -385.7998,-418.57673 L-391.80158,-291.19937 C-395.95814,-305.48433 -396.81778,-303.62808 -409.39309,-316.08518 -418.76349,-321.14403 -423.97841,-321.79198 -432.13334,-310.93639 L-415.40014,-283.90525 -397.213,-232.94444 z" StrokeThickness="2">
|
||||
<Path.Fill>
|
||||
<RadialGradientBrush>
|
||||
<GradientStop Color="#FFFFB6B6" Offset="0"/>
|
||||
<GradientStop Color="#FFFFFDFD" Offset="1"/>
|
||||
</RadialGradientBrush>
|
||||
</Path.Fill>
|
||||
</Path>
|
||||
<!-- EOF Circle -->
|
||||
|
||||
</Grid>
|
||||
|
|
|
@ -0,0 +1,798 @@
|
|||
namespace Tweener
|
||||
{
|
||||
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Equations
|
||||
/// Main equations for the Tweener class
|
||||
/// author Michael Cameron
|
||||
/// version 1.0.1
|
||||
/// Updated for Silverlight 2.0 Beta 1
|
||||
/// </summary>
|
||||
|
||||
/*
|
||||
Disclaimer for Robert Penner's Easing Equations license:
|
||||
|
||||
TERMS OF USE - EASING EQUATIONS
|
||||
|
||||
Open source under the BSD License.
|
||||
|
||||
Copyright © 2001 Robert Penner
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
public static class Equations
|
||||
{
|
||||
// ==================================================================================================================================
|
||||
// TWEENING EQUATIONS functions -----------------------------------------------------------------------------------------------------
|
||||
// (the original equations are Robert Penner's work as mentioned on the disclaimer)
|
||||
|
||||
/**
|
||||
* Easing equation function for a simple linear tweening, with no easing.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseNone(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
return c * t / d + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInQuad(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
return c * (t /= d) * t + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutQuad(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
return -c * (t /= d) * (t - 2) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInOutQuad(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if ((t /= d / 2) < 1) return c / 2 * t * t + b;
|
||||
return -c / 2 * ((--t) * (t - 2) - 1) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutInQuad(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if (t < d / 2) return EaseOutQuad(t * 2, b, c / 2, d);
|
||||
return EaseInQuad((t * 2) - d, b + c / 2, c / 2, d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInCubic(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return c * (t /= d) * t * t + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutCubic(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return c * ((t = t / d - 1) * t * t + 1) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInOutCubic(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
|
||||
return c / 2 * ((t -= 2) * t * t + 2) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutInCubic(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if (t < d / 2) return EaseOutCubic(t * 2, b, c / 2, d);
|
||||
return EaseInCubic((t * 2) - d, b + c / 2, c / 2, d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInQuart(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return c * (t /= d) * t * t * t + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutQuart(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInOutQuart(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
|
||||
return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutInQuart(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if (t < d / 2) return EaseOutQuart(t * 2, b, c / 2, d);
|
||||
return EaseInQuart((t * 2) - d, b + c / 2, c / 2, d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInQuint(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return c * (t /= d) * t * t * t * t + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutQuint(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInOutQuint(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
|
||||
return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutInQuint(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if (t < d / 2) return EaseOutQuint(t * 2, b, c / 2, d);
|
||||
return EaseInQuint((t * 2) - d, b + c / 2, c / 2, d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInSine(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return -c * Math.Cos(t / d * (Math.PI / 2)) + c + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutSine(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return c * Math.Sin(t / d * (Math.PI / 2)) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInOutSine(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return -c / 2 * (Math.Cos(Math.PI * t / d) - 1) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutInSine(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if (t < d / 2) return EaseOutSine(t * 2, b, c / 2, d);
|
||||
return EaseInSine((t * 2) - d, b + c / 2, c / 2, d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInExpo(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return (t == 0) ? b : c * Math.Pow(2, 10 * (t / d - 1)) + b - c * 0.001;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutExpo(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return (t == d) ? b + c : c * 1.001 * (-Math.Pow(2, -10 * t / d) + 1) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInOutExpo(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if (t == 0) return b;
|
||||
if (t == d) return b + c;
|
||||
if ((t /= d / 2) < 1) return c / 2 * Math.Pow(2, 10 * (t - 1)) + b - c * 0.0005;
|
||||
return c / 2 * 1.0005 * (-Math.Pow(2, -10 * --t) + 2) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutInExpo(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if (t < d / 2) return EaseOutExpo(t * 2, b, c / 2, d);
|
||||
return EaseInExpo((t * 2) - d, b + c / 2, c / 2, d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInCirc(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return -c * (Math.Sqrt(1 - (t /= d) * t) - 1) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutCirc(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return c * Math.Sqrt(1 - (t = t / d - 1) * t) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInOutCirc(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if ((t /= d / 2) < 1) return -c / 2 * (Math.Sqrt(1 - t * t) - 1) + b;
|
||||
return c / 2 * (Math.Sqrt(1 - (t -= 2) * t) + 1) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutInCirc(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if (t < d / 2) return EaseOutCirc(t * 2, b, c / 2, d);
|
||||
return EaseInCirc((t * 2) - d, b + c / 2, c / 2, d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @param a Amplitude.
|
||||
* @param p Period.
|
||||
* @return The correct value.
|
||||
*/
|
||||
//public static double EaseInElastic (double t, double b, double c, double d, double a, double p) {
|
||||
public static double EaseInElastic(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d; double a; double p;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3]; a = ((args.Length < 5) ? 0 : args[4]); p = ((args.Length < 6) ? 0 : args[5]);
|
||||
|
||||
if (t == 0) return b; if ((t /= d) == 1) return b + c; if (p == 0) p = d * .3;
|
||||
double s;
|
||||
if (a == 0 || a < Math.Abs(c)) { a = c; s = p / 4; }
|
||||
else s = p / (2 * Math.PI) * Math.Asin(c / a);
|
||||
return -(a * Math.Pow(2, 10 * (t -= 1)) * Math.Sin((t * d - s) * (2 * Math.PI) / p)) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @param a Amplitude.
|
||||
* @param p Period.
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutElastic(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d; double a; double p;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3]; a = ((args.Length < 5) ? 0 : args[4]); p = ((args.Length < 6) ? 0 : args[5]);
|
||||
|
||||
if (t == 0) return b; if ((t /= d) == 1) return b + c; if (p == 0) p = d * .3;
|
||||
double s;
|
||||
if (a == 0 || a < Math.Abs(c)) { a = c; s = p / 4; }
|
||||
else s = p / (2 * Math.PI) * Math.Asin(c / a);
|
||||
return (a * Math.Pow(2, -10 * t) * Math.Sin((t * d - s) * (2 * Math.PI) / p) + c + b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @param a Amplitude.
|
||||
* @param p Period.
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInOutElastic(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d; double a; double p;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3]; a = ((args.Length < 5) ? 0 : args[4]); p = ((args.Length < 6) ? 0 : args[5]);
|
||||
|
||||
if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (p == 0) p = d * (.3 * 1.5);
|
||||
double s;
|
||||
if (a == 0 || a < Math.Abs(c)) { a = c; s = p / 4; }
|
||||
else s = p / (2 * Math.PI) * Math.Asin(c / a);
|
||||
if (t < 1) return -.5 * (a * Math.Pow(2, 10 * (t -= 1)) * Math.Sin((t * d - s) * (2 * Math.PI) / p)) + b;
|
||||
return a * Math.Pow(2, -10 * (t -= 1)) * Math.Sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @param a Amplitude.
|
||||
* @param p Period.
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutInElastic(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d; double a; double p;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3]; a = ((args.Length < 5) ? 0 : args[4]); p = ((args.Length < 6) ? 0 : args[5]);
|
||||
|
||||
if (t < d / 2) return EaseOutElastic(t * 2, b, c / 2, d, a, p);
|
||||
return EaseInElastic((t * 2) - d, b + c / 2, c / 2, d, a, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @param s Overshoot amount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInBack(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d; double s;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3]; s = ((args.Length < 5) ? 0 : args[4]);
|
||||
|
||||
if (s == 0) s = 1.70158;
|
||||
return c * (t /= d) * t * ((s + 1) * t - s) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @param s Overshoot amount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutBack(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d; double s;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3]; s = ((args.Length < 5) ? 0 : args[4]);
|
||||
|
||||
if (s == 0) s = 1.70158;
|
||||
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @param s Overshoot amount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInOutBack(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d; double s;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3]; s = ((args.Length < 5) ? 0 : args[4]);
|
||||
|
||||
if (s == 0) s = 1.70158;
|
||||
if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
|
||||
return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @param s Overshoot amount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutInBack(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d; double s;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3]; s = ((args.Length < 5) ? 0 : args[4]);
|
||||
|
||||
if (t < d / 2) return EaseOutBack(t * 2, b, c / 2, d, s);
|
||||
return EaseInBack((t * 2) - d, b + c / 2, c / 2, d, s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInBounce(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
return c - EaseOutBounce(d - t, 0, c, d) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutBounce(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if ((t /= d) < (1 / 2.75))
|
||||
{
|
||||
return c * (7.5625 * t * t) + b;
|
||||
}
|
||||
else if (t < (2 / 2.75))
|
||||
{
|
||||
return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
|
||||
}
|
||||
else if (t < (2.5 / 2.75))
|
||||
{
|
||||
return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
|
||||
}
|
||||
else
|
||||
{
|
||||
return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseInOutBounce(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if (t < d / 2) return EaseInBounce(t * 2, 0, c, d) * .5 + b;
|
||||
else return EaseOutBounce(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
|
||||
*
|
||||
* @param t Current time (in seconds).
|
||||
* @param b Starting value.
|
||||
* @param c Change needed in value.
|
||||
* @param d Expected easing duration (in seconds).
|
||||
* @return The correct value.
|
||||
*/
|
||||
public static double EaseOutInBounce(params double[] args)
|
||||
{
|
||||
double t; double b; double c; double d;
|
||||
t = args[0]; b = args[1]; c = args[2]; d = args[3];
|
||||
|
||||
if (t < d / 2) return EaseOutBounce(t * 2, b, c / 2, d);
|
||||
return EaseInBounce((t * 2) - d, b + c / 2, c / 2, d);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
namespace Tweener
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the set of equation types.
|
||||
/// </summary>
|
||||
public enum TransitionType
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseNone,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInQuad,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutQuad,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInOutQuad,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutInQuad,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInCubic,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutCubic,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInOutCubic,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutInCubic,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInQuart,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutQuart,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInOutQuart,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutInQuart,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInQuint,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutQuint,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInOutQuint,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutInQuint,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInSine,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutSine,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInOutSine,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutInSine,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInCirc,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutCirc,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInOutCirc,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutInCirc,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInExpo,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutExpo,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInOutExpo,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutInExpo,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInElastic,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutElastic,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInOutElastic,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutInElastic,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInBack,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutBack,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInOutBack,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutInBack,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInBounce,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutBounce,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseInOutBounce,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
EaseOutInBounce
|
||||
}
|
||||
}
|
|
@ -0,0 +1,195 @@
|
|||
namespace Tweener
|
||||
{
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
/// <summary>
|
||||
/// Provides the implementation of tween attached properties.
|
||||
/// </summary>
|
||||
public static class Tween
|
||||
{
|
||||
/// <summary>
|
||||
/// The default number of keyframes to generate per second.
|
||||
/// </summary>
|
||||
public const int DefaultFps = 20;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the tween transition type.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TransitionTypeProperty =
|
||||
DependencyProperty.RegisterAttached("TransitionType", typeof(TransitionType), typeof(Tween), new PropertyMetadata(OnTweenChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the source value of a tween double animation.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FromProperty =
|
||||
DependencyProperty.RegisterAttached("From", typeof(double), typeof(Tween), new PropertyMetadata(OnTweenChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the target value of a tween double animation.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ToProperty =
|
||||
DependencyProperty.RegisterAttached("To", typeof(double), typeof(Tween), new PropertyMetadata(OnTweenChanged));
|
||||
|
||||
/// <summary>
|
||||
/// The frames-per-second attached property.
|
||||
/// </summary>
|
||||
/// <remarks>The FPS attached property defines the number of keyframes to generate per second.</remarks>
|
||||
public static readonly DependencyProperty FpsProperty =
|
||||
DependencyProperty.RegisterAttached("Fps", typeof(double), typeof(Tween), new PropertyMetadata(OnTweenChanged));
|
||||
|
||||
private delegate double Equation(params double[] args);
|
||||
|
||||
private static void OnTweenChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
DoubleAnimationUsingKeyFrames animation = o as DoubleAnimationUsingKeyFrames;
|
||||
|
||||
if (animation != null && animation.Duration.HasTimeSpan) {
|
||||
TransitionType type = GetTransitionType(animation);
|
||||
double from = GetFrom(animation);
|
||||
double to = GetTo(animation);
|
||||
double fps = GetFps(animation);
|
||||
|
||||
if (fps <= 0) {
|
||||
fps = DefaultFps;
|
||||
}
|
||||
|
||||
FillAnimation(animation, type, from, to, animation.Duration.TimeSpan, fps);
|
||||
}
|
||||
}
|
||||
|
||||
private static void FillAnimation(DoubleAnimationUsingKeyFrames animation, TransitionType type, double from, double to, TimeSpan duration, double fps)
|
||||
{
|
||||
Equation equation = (Equation)Delegate.CreateDelegate(typeof(Equation), typeof(Equations).GetMethod(type.ToString()));
|
||||
|
||||
double total = duration.TotalMilliseconds;
|
||||
double step = 1000D / (double)fps;
|
||||
|
||||
// clear animation
|
||||
animation.KeyFrames.Clear();
|
||||
|
||||
for (double i = 0; i < total; i += step) {
|
||||
LinearDoubleKeyFrame frame = new LinearDoubleKeyFrame();
|
||||
frame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(i));
|
||||
frame.Value = equation(i, from, to - from, total);
|
||||
|
||||
animation.KeyFrames.Add(frame);
|
||||
}
|
||||
|
||||
// always add exact final key frame
|
||||
LinearDoubleKeyFrame finalFrame = new LinearDoubleKeyFrame();
|
||||
finalFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(total));
|
||||
finalFrame.Value = to;
|
||||
animation.KeyFrames.Add(finalFrame);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a tween animation with a default number of frames per second..
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <param name="from">From.</param>
|
||||
/// <param name="to">To.</param>
|
||||
/// <param name="duration">The duration.</param>
|
||||
/// <returns></returns>
|
||||
public static DoubleAnimationUsingKeyFrames CreateAnimation(TransitionType type, double from, double to, TimeSpan duration)
|
||||
{
|
||||
return CreateAnimation(type, from, to, duration, DefaultFps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a tween animation.
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <param name="from">From.</param>
|
||||
/// <param name="to">To.</param>
|
||||
/// <param name="duration">The duration.</param>
|
||||
/// <param name="fps">The number of keyframes to generate per second.</param>
|
||||
/// <returns></returns>
|
||||
public static DoubleAnimationUsingKeyFrames CreateAnimation(TransitionType type, double from, double to, TimeSpan duration, double fps)
|
||||
{
|
||||
DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();
|
||||
FillAnimation(animation, type, from, to, duration, fps);
|
||||
return animation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tween transition type.
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <returns></returns>
|
||||
public static TransitionType GetTransitionType(DependencyObject o)
|
||||
{
|
||||
return (TransitionType)o.GetValue(TransitionTypeProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the tween transition type.
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
public static void SetTransitionType(DependencyObject o, TransitionType value)
|
||||
{
|
||||
o.SetValue(TransitionTypeProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tween's starting value.
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <returns></returns>
|
||||
public static double GetFrom(DependencyObject o)
|
||||
{
|
||||
return (double)o.GetValue(FromProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the tween's starting value.
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
public static void SetFrom(DependencyObject o, double value)
|
||||
{
|
||||
o.SetValue(FromProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tween's ending value.
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <returns></returns>
|
||||
public static double GetTo(DependencyObject o)
|
||||
{
|
||||
return (double)o.GetValue(ToProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the tween's ending value.
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
public static void SetTo(DependencyObject o, double value)
|
||||
{
|
||||
o.SetValue(ToProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of keyframes to generate per second.
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
public static double GetFps(DependencyObject o)
|
||||
{
|
||||
return (double)o.GetValue(FpsProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the number of keyframes to generate per second.
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
public static void SetFps(DependencyObject o, double value)
|
||||
{
|
||||
o.SetValue(FpsProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
12
Utils.cs
12
Utils.cs
|
@ -91,5 +91,17 @@ namespace BabySmash
|
|||
{
|
||||
return lRandom.Next(min, max + 1);
|
||||
}
|
||||
|
||||
internal static System.Windows.Controls.UserControl GetCursor()
|
||||
{
|
||||
switch (Properties.Settings.Default.CursorType)
|
||||
{
|
||||
case "Hand":
|
||||
return new FunCursor2();
|
||||
case "Arrow":
|
||||
return new FunCursor1();
|
||||
}
|
||||
return new FunCursor2();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@
|
|||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="ClearAfter" serializeAs="String">
|
||||
<value>65</value>
|
||||
<value>35</value>
|
||||
</setting>
|
||||
<setting name="MouseDraw" serializeAs="String">
|
||||
<value>False</value>
|
||||
|
@ -50,6 +50,12 @@
|
|||
<setting name="Sounds" serializeAs="String">
|
||||
<value>Speech</value>
|
||||
</setting>
|
||||
<setting name="CursorType" serializeAs="String">
|
||||
<value>Hand</value>
|
||||
</setting>
|
||||
<setting name="FontFamily" serializeAs="String">
|
||||
<value>Arial</value>
|
||||
</setting>
|
||||
</BabySmash.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
Загрузка…
Ссылка в новой задаче