MaxKK

Fireworks Physics Lab

Apr 26th, 2026
175
0
Never
8
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 52.55 KB | Software | 0 0
  1. #Author: MaxK - MarekM 30.12.2025 (reddit: u/Glad-Journalist-4807)
  2.  
  3. param(
  4. #    [int]$SkipIntro = 1,
  5. #    [string]$Music = "f.mid",
  6. #    [double]$MusVolume = 0.20,
  7. #    [string]$Boom1 = "a.wav",
  8. #    [string]$Boom2 = "b.wav",
  9. #    [string]$Boom3 = "c.wav",
  10. #    [string]$Background = "h.jpg",
  11.     [int]$SnowTick = 70,
  12.     [int]$SparkTick = 40,
  13.     [int]$FlakeCount = 50,
  14.     [int]$SparkCount = 25
  15. ) #only 1st param is working
  16.  
  17. Add-Type -AssemblyName PresentationFramework
  18. Add-Type -AssemblyName WindowsBase
  19. Add-Type -AssemblyName PresentationCore
  20. Add-Type -AssemblyName System.Windows.Forms
  21.  
  22. $SCRIPT_DIR = $PSScriptRoot
  23.  
  24.  
  25.  
  26.  
  27. $script:Gravity = 0.5
  28. $script:ExplosionForce = 15
  29. $script:AirResistance = 0.015
  30. $script:deltaTime = 1.0
  31. $script:maxSnowSpeed = 500
  32. $script:SNOW_GRAVITY_SCALE = 3
  33. $script:SNOW_AIRDRAG_SCALE = 2
  34. $script:PHYSICS_SCALE = 100
  35. $script:SNOW_AIR_DRAG_SCALED = $script:AirResistance * $script:PHYSICS_SCALE / 50
  36. $script:SNOW_GRAVITY_SCALED = $script:Gravity * $script:SNOW_GRAVITY_SCALE / 5
  37. $script:AIR_RESISTANCE_ABS = [Math]::Abs($airResistance)
  38. $script:DARK_ENERGY_FORCE = $script:AIR_RESISTANCE_ABS * 10 * $deltaTime  
  39.  
  40.  
  41. $ColorsRed = @(
  42.     [System.Windows.Media.Colors]::LightPink,
  43.     [System.Windows.Media.Colors]::Pink,
  44.     [System.Windows.Media.Colors]::LightCoral,
  45.     [System.Windows.Media.Colors]::Salmon,
  46.     [System.Windows.Media.Colors]::Coral,
  47.     [System.Windows.Media.Colors]::Tomato,
  48.     [System.Windows.Media.Colors]::OrangeRed,
  49.     [System.Windows.Media.Colors]::Red,
  50.     [System.Windows.Media.Colors]::Crimson,
  51.     [System.Windows.Media.Colors]::Firebrick
  52. )
  53.  
  54. $ColorsPurple = @(
  55.     [System.Windows.Media.Colors]::LavenderBlush,
  56.     [System.Windows.Media.Colors]::Lavender,
  57.     [System.Windows.Media.Colors]::Thistle,
  58.     [System.Windows.Media.Colors]::Plum,
  59.     [System.Windows.Media.Colors]::Violet,
  60.     [System.Windows.Media.Colors]::Orchid,
  61.     [System.Windows.Media.Colors]::MediumOrchid,
  62.     [System.Windows.Media.Colors]::DarkOrchid,
  63.     [System.Windows.Media.Colors]::BlueViolet,
  64.     [System.Windows.Media.Colors]::MediumPurple
  65. )
  66.  
  67. $ColorsGreen = @(
  68.     [System.Windows.Media.Colors]::Honeydew,
  69.     [System.Windows.Media.Colors]::MintCream,
  70.     [System.Windows.Media.Colors]::PaleGreen,
  71.     [System.Windows.Media.Colors]::LightGreen,
  72.     [System.Windows.Media.Colors]::SpringGreen,
  73.     [System.Windows.Media.Colors]::LimeGreen,
  74.     [System.Windows.Media.Colors]::Lime,
  75.     [System.Windows.Media.Colors]::ForestGreen,
  76.     [System.Windows.Media.Colors]::Green,
  77.     [System.Windows.Media.Colors]::DarkGreen
  78. )
  79.  
  80. $ColorsYellow = @(
  81.     [System.Windows.Media.Colors]::LightYellow,
  82.     [System.Windows.Media.Colors]::LemonChiffon,
  83.     [System.Windows.Media.Colors]::LightGoldenrodYellow,
  84.     [System.Windows.Media.Colors]::PapayaWhip,
  85.     [System.Windows.Media.Colors]::Moccasin,
  86.     [System.Windows.Media.Colors]::PeachPuff,
  87.     [System.Windows.Media.Colors]::Gold,
  88.     [System.Windows.Media.Colors]::Goldenrod,
  89.     [System.Windows.Media.Colors]::DarkGoldenrod,
  90.     [System.Windows.Media.Colors]::Goldenrod
  91. )
  92.  
  93. $ColorsBlue = @(
  94.     [System.Windows.Media.Colors]::AliceBlue,
  95.     [System.Windows.Media.Colors]::LightCyan,
  96.     [System.Windows.Media.Colors]::LightBlue,
  97.     [System.Windows.Media.Colors]::LightSkyBlue,
  98.     [System.Windows.Media.Colors]::SkyBlue,
  99.     [System.Windows.Media.Colors]::DeepSkyBlue,
  100.     [System.Windows.Media.Colors]::DodgerBlue,
  101.     [System.Windows.Media.Colors]::CornflowerBlue,
  102.     [System.Windows.Media.Colors]::RoyalBlue,
  103.     [System.Windows.Media.Colors]::SteelBlue
  104. )
  105.  
  106. $ColorsOrange = @(
  107.     [System.Windows.Media.Colors]::FloralWhite,
  108.     [System.Windows.Media.Colors]::Seashell,
  109.     [System.Windows.Media.Colors]::Cornsilk,
  110.     [System.Windows.Media.Colors]::Bisque,
  111.     [System.Windows.Media.Colors]::NavajoWhite,
  112.     [System.Windows.Media.Colors]::Wheat,
  113.     [System.Windows.Media.Colors]::Orange,
  114.     [System.Windows.Media.Colors]::DarkOrange,
  115.     [System.Windows.Media.Colors]::Coral,
  116.     [System.Windows.Media.Colors]::DarkSalmon
  117. )
  118.  
  119. $ColorsRainbow = @(
  120.     [System.Windows.Media.Colors]::LightPink,
  121.     [System.Windows.Media.Colors]::Gold,
  122.     [System.Windows.Media.Colors]::LightGreen,
  123.     [System.Windows.Media.Colors]::LightBlue,
  124.     [System.Windows.Media.Colors]::Lavender,
  125.     [System.Windows.Media.Colors]::LightCyan,
  126.     [System.Windows.Media.Colors]::LightYellow,
  127.     [System.Windows.Media.Colors]::LightCoral,
  128.     [System.Windows.Media.Colors]::Plum,
  129.     [System.Windows.Media.Colors]::White
  130. )
  131.  
  132. $ColorsPastel = @(
  133.     [System.Windows.Media.Colors]::LavenderBlush,
  134.     [System.Windows.Media.Colors]::LemonChiffon,
  135.     [System.Windows.Media.Colors]::MintCream,
  136.     [System.Windows.Media.Colors]::AliceBlue,
  137.     [System.Windows.Media.Colors]::Honeydew,
  138.     [System.Windows.Media.Colors]::Seashell,
  139.     [System.Windows.Media.Colors]::Thistle,
  140.     [System.Windows.Media.Colors]::LightCyan,
  141.     [System.Windows.Media.Colors]::MistyRose,
  142.     [System.Windows.Media.Colors]::Azure
  143. )
  144.  
  145. $ColorsChristmas = @(
  146.     [System.Windows.Media.Colors]::Gold,
  147.     [System.Windows.Media.Colors]::Red,
  148.     [System.Windows.Media.Colors]::ForestGreen,
  149.     [System.Windows.Media.Colors]::White,
  150.     [System.Windows.Media.Colors]::Silver,
  151.     [System.Windows.Media.Colors]::Crimson,
  152.     [System.Windows.Media.Colors]::DarkGreen,
  153.     [System.Windows.Media.Colors]::Goldenrod,
  154.     [System.Windows.Media.Colors]::LightCyan,
  155.     [System.Windows.Media.Colors]::LightPink
  156. )
  157.  
  158.  
  159.  
  160.  
  161.  
  162. #$player1 = New-Object System.Windows.Media.MediaPlayer
  163. #$player1.Open([Uri](Join-Path $SCRIPT_DIR $Music))
  164. #$player1.Volume = $MusVolume
  165.  
  166. #$playerksm = New-Object System.Windows.Media.MediaPlayer
  167. #$playerksm.Open([Uri](Join-Path $SCRIPT_DIR "s.mp3"))
  168. #$playerksm.Volume = 0.7
  169.  
  170.  
  171. #$bgFile =   Join-Path $SCRIPT_DIR "h.jpg"
  172.  
  173. function DE { [System.Windows.Forms.Application]::DoEvents() }
  174.  
  175. # function TypeKey {
  176.     # $wav = Join-Path $SCRIPT_DIR 't.wav'
  177.     # $key = New-Object System.Media.SoundPlayer $wav
  178.     # $key.PlaySync()
  179. # }
  180.  
  181. # function What {
  182.     # $wav = Join-Path $SCRIPT_DIR "w.wav"
  183.     # $key = New-Object System.Media.SoundPlayer $wav
  184.     # $key.PlaySync()
  185. # }
  186.  
  187.  
  188. # $player1.Add_MediaEnded({
  189.     # $player1.Position = [TimeSpan]::Zero
  190.     # $player1.Play()
  191. # })
  192.  
  193. [xml]$xaml = @"
  194. <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  195.        Title="๐ŸŽ„๐ŸŽ…โ„"
  196.        Height="680" Width="800"
  197.        WindowStartupLocation="CenterScreen"
  198.        ResizeMode="NoResize"
  199.        WindowStyle="ToolWindow"
  200.        Topmost="True"
  201.        Background="Black">
  202.    <Grid>
  203.        <Grid.RowDefinitions>
  204.            <RowDefinition Height="*"/>
  205.            <RowDefinition Height="Auto"/>
  206.        </Grid.RowDefinitions>
  207.        
  208.        <Canvas Name="MainCanvas" Grid.Row="0">
  209.            <Canvas.Background>
  210.                <!--ImageBrush ImageSource="$bgFile" Stretch="Fill"/-->
  211.            </Canvas.Background>
  212.            <TextBlock Name="s1" Text="*" FontSize="10" Foreground="White" Canvas.Left="30" Canvas.Top="2"/>
  213.            <TextBlock Name="s2" Text="*" FontSize="8" Foreground="Pink" Canvas.Left="752" Canvas.Top="45"/>
  214.            <TextBlock Name="s3" Text="*" FontSize="4" Foreground="LightCyan" Canvas.Left="40" Canvas.Top="50"/>
  215.            <TextBlock Name="s4" Text="*" FontSize="6" Foreground="LightCyan" Canvas.Left="10" Canvas.Top="40"/>
  216.            <TextBlock Name="s5" Text="*" FontSize="9" Foreground="LightCyan" Canvas.Left="520" Canvas.Top="25"/>
  217.            <TextBlock Name="s6" Text="*" FontSize="7" Foreground="Yellow" Canvas.Left="20" Canvas.Top="80"/>
  218.            <TextBlock Name="s7" Text="*" FontSize="5" Foreground="White" Canvas.Left="600" Canvas.Top="60"/>
  219.            <TextBlock Name="s8" Text="." FontSize="18" Foreground="White" Canvas.Left="50" Canvas.Top="10"/>
  220.            <TextBlock Name="s9" Text="." FontSize="22" Foreground="Pink" Canvas.Left="452" Canvas.Top="65"/>
  221.            <TextBlock Name="s10" Text="." FontSize="12" Foreground="LightCyan" Canvas.Left="340" Canvas.Top="30"/>
  222.            <TextBlock Name="s11" Text="." FontSize="16" Foreground="LightCyan" Canvas.Left="100" Canvas.Top="15"/>
  223.            <TextBlock Name="s12" Text="." FontSize="10" Foreground="LightCyan" Canvas.Left="150" Canvas.Top="5"/>
  224.            <TextBlock Name="s13" Text="." FontSize="8" Foreground="Yellow" Canvas.Left="720" Canvas.Top="100"/>
  225.            <TextBlock Name="s14" Text="." FontSize="20" Foreground="White" Canvas.Left="260" Canvas.Top="18"/>
  226.            
  227.            <TextBlock Name="SnowTest" Canvas.Left="18" Canvas.Top="15" FontFamily="Lucida Console"
  228.                   FontSize="14" Foreground="Lime" Text=""/>
  229.            <TextBlock Name="FPS" Canvas.Left="15" Canvas.Top="45" FontFamily="Lucida Console"
  230.                   FontSize="14" Foreground="Cyan" Text=""/>
  231.            
  232.            <Canvas Name="FireCanvas" Top="0" Left="0"
  233.                    Width="800" Height="600"
  234.                    Panel.ZIndex="99"
  235.                    IsHitTestVisible="False"/>
  236.        </Canvas>
  237.        <Border Grid.Row="1" Background="#1A1A1A" BorderBrush="Gold" BorderThickness="2" Margin="5">
  238.             <StackPanel Orientation="Vertical" Margin="10">
  239.                
  240.                 <TextBlock Text="๐Ÿงช FIREWORK PHYSICS LAB"
  241.                            Foreground="Gold"
  242.                            FontSize="14"
  243.                            FontWeight="Bold"
  244.                            HorizontalAlignment="Center"
  245.                            Margin="0,0,0,10"/>
  246.                
  247.                 <Grid>
  248.                     <Grid.ColumnDefinitions>
  249.                         <ColumnDefinition Width="*"/>
  250.                         <ColumnDefinition Width="*"/>
  251.                         <ColumnDefinition Width="*"/>
  252.                     </Grid.ColumnDefinitions>
  253.                    
  254.                    
  255.                     <StackPanel Grid.Column="0" Margin="10,0">
  256.                         <TextBlock Text="Gravity: 1"
  257.                                    Name="GravityValue"
  258.                                    Foreground="LightCyan"
  259.                                    FontSize="12"
  260.                                    HorizontalAlignment="Center"/>
  261.                         <Slider Name="GravitySlider"
  262.                                 Minimum="-2.0"
  263.                                 Maximum="5.0"
  264.                                 Value="1"
  265.                                 TickFrequency="0.1"
  266.                                 TickPlacement="BottomRight"
  267.                                 Foreground="Cyan"
  268.                                 Margin="5,0"
  269.                                 ToolTip="Gravity force. Press G(+) or Shift-G(-) to fine tune">
  270.                             <Slider.Resources>
  271.                                 <Style TargetType="Thumb">
  272.                                     <Setter Property="Background" Value="Cyan"/>
  273.                                     <Setter Property="Height" Value="15"/>
  274.                                     <Setter Property="Width" Value="15"/>
  275.                                 </Style>
  276.                                 <Style TargetType="TickBar">
  277.                                     <Setter Property="Fill" Value="LightGray"/>
  278.                                 </Style>
  279.                             </Slider.Resources>
  280.                         </Slider>
  281.                         <TextBlock Text="๐Ÿ”ฝ Gravity force (+/- G/Shift G)"
  282.                                    Foreground="White"
  283.                                    FontSize="11"
  284.                                    HorizontalAlignment="Center"/>
  285.                     </StackPanel>
  286.                     <StackPanel Grid.Column="1" Margin="10,0">
  287.                         <TextBlock Text="Explosion force: 15"
  288.                                    Name="ForceValue"
  289.                                    Foreground="LightCoral"
  290.                                    FontSize="12"
  291.                                    HorizontalAlignment="Center"/>
  292.                         <Slider Name="ForceSlider"
  293.                                 Minimum="1"
  294.                                 Maximum="2000"
  295.                                 Value="10"
  296.                                 TickFrequency="1"
  297.                                 TickPlacement="BottomRight"
  298.                                 Foreground="OrangeRed"
  299.                                 Margin="5,0"
  300.                                 ToolTip="Explosion force. Press E(+) or Shift-E(-) to fine tune">
  301.                             <Slider.Resources>
  302.                                 <Style TargetType="Thumb">
  303.                                     <Setter Property="Background" Value="OrangeRed"/>
  304.                                     <Setter Property="Height" Value="15"/>
  305.                                     <Setter Property="Width" Value="15"/>
  306.                                 </Style>
  307.                             </Slider.Resources>
  308.                         </Slider>
  309.                         <TextBlock Text="๐Ÿ’ฅ Explosion force (+/- E/Shift E)"
  310.                                    Foreground="White"
  311.                                    FontSize="11"
  312.                                    HorizontalAlignment="Center"/>
  313.                     </StackPanel>
  314.                     <StackPanel Grid.Column="2" Margin="10,0">
  315.                         <TextBlock Text="Drag coefficient: $script:AirResistance"
  316.                                    Name="AirResistanceValue"
  317.                                    Foreground="LightGreen"
  318.                                    FontSize="12"
  319.                                    HorizontalAlignment="Center"/>
  320.                         <Slider Name="AirResistanceSlider"
  321.                                 Minimum="-0.002"
  322.                                 Maximum="5"
  323.                                 Value="$script:AirResistance"
  324.                                 TickFrequency="0.001"
  325.                                 TickPlacement="BottomRight"
  326.                                 Foreground="LimeGreen"
  327.                                 Margin="5,0"
  328.                                 ToolTip="Drag coefficient. Press D(+) or Shift D(-) to fine tune">
  329.                             <Slider.Resources>
  330.                                 <Style TargetType="Thumb">
  331.                                     <Setter Property="Background" Value="LimeGreen"/>
  332.                                     <Setter Property="Height" Value="15"/>
  333.                                     <Setter Property="Width" Value="15"/>
  334.                                 </Style>
  335.                             </Slider.Resources>
  336.                         </Slider>
  337.                         <TextBlock Text="๐ŸŒฌ๏ธ Drag coefficient (+/- D/Shift D)"
  338.                                    Foreground="White"
  339.                                    FontSize="11"
  340.                                    HorizontalAlignment="Center"/>
  341.                     </StackPanel>
  342.                 </Grid>
  343.                 <Button Name="ResetButton"
  344.                         Content="๐Ÿ”„ Reset"
  345.                         Width="200"
  346.                         Height="30"
  347.                         Background="#333333"
  348.                         Foreground="White"
  349.                         BorderBrush="Gray"
  350.                         Margin="0,10,0,5"
  351.                         HorizontalAlignment="Center"
  352.                         ToolTip="Reset"/>
  353.                 <Border Background="#222222" CornerRadius="5" Margin="0,5" Padding="5">
  354.                     <TextBlock Name="CurrentPhysicsLabel"
  355.                                Text="โš™๏ธ Actual: G=0.50, E=15.0, C=$script:AirResistance"
  356.                                Foreground="LightGray"
  357.                                FontSize="12"
  358.                                HorizontalAlignment="Center"/>
  359.                 </Border>
  360.             </StackPanel>
  361.         </Border>
  362.     </Grid>
  363. </Window>
  364. "@
  365.  
  366. function Get-DragDescription {
  367.    param([double]$dragValue)
  368.    
  369.     $dragRanges = @(
  370.         @{ Max = -0.0000000001; Description = "Vacuum (+ dark energy)" }
  371.         @{ Max = 0.00005;       Description = "Interstellar medium" }
  372.         @{ Max = 0.001;         Description = "Moon exosphere" }
  373.         @{ Max = 0.002;         Description = "Pluto / Charon exosphere" }
  374.         @{ Max = 0.003;         Description = "Io plasma torus (tenuous)" }
  375.         @{ Max = 0.004;         Description = "Thin COโ‚‚, early Mars" }
  376.         @{ Max = 0.006;         Description = "Triton nitrogen geysers" }  
  377.         @{ Max = 0.010;         Description = "Mars atmosphere (present)" }
  378.         @{ Max = 0.015;         Description = "Earth atmosphere" }        
  379.         @{ Max = 0.04;          Description = "Uranus/Neptune upper haze" }
  380.         @{ Max = 0.08;          Description = "Gas giant upper clouds (Jupiter)" }
  381.         @{ Max = 0.12;          Description = "Saturn cloud tops" }
  382.         @{ Max = 0.15;          Description = "Titan atmosphere" }
  383.         @{ Max = 0.3;           Description = "Deep Jovian atmosphere (pressure)" }
  384.         @{ Max = 0.5;           Description = "Venus upper clouds" }
  385.         @{ Max = 0.8;           Description = "Venus lower atmosphere" }
  386.         @{ Max = 1.5;           Description = "Water (Earthsea level)" }
  387.         @{ Max = 2.0;           Description = "Cryogenic fluid (Liquid methane sea)" }
  388.         @{ Max = 2.5;           Description = "Mercury (liquid metal)" }
  389.         @{ Max = 3.0;           Description = "Europa sub-surface ocean (salty)" }
  390.         @{ Max = 3.5;           Description = "Molten metal" }
  391.         @{ Max = 4.0;           Description = "Molten iron / Planetary core material" }
  392.         @{ Max = 4.5;           Description = "Hot tar / Bitumen" }
  393.         @{ Max = 5.0;           Description = "Honey ๐Ÿ˜‰/ Ultra-dense fluid" }
  394.     )
  395.  
  396.    foreach ($range in $dragRanges) {
  397.        if ($dragValue -le $range.Max) {
  398.            return $range.Description
  399.        }
  400.    }
  401.    return "Unknown Medium"
  402. }
  403.  
  404.  
  405.  
  406. function Get-GravityDescription {
  407.    param([double]$gravityValue)
  408.        
  409.     $gravityRanges = @(
  410.         @{ Max = -2.0;  Description = "Alcubierre drive field (exotic matter core)" }
  411.         @{ Max = -1.5;  Description = "Exotic matter strong repulsion" }
  412.         @{ Max = -1.0;  Description = "Negative energy density bubble" }
  413.         @{ Max = -0.5;  Description = "Static wormhole throat repulsion" }
  414.         @{ Max = -0.1;  Description = "Quantum foam negative mass fluctuation" }
  415.         @{ Max = 0.0;   Description = "Zero-G / Orbit" }
  416.         @{ Max = 0.1;   Description = "Asteroid / Deimos" }
  417.         @{ Max = 0.15;  Description = "Moon (Luna)" }
  418.         @{ Max = 0.35;  Description = "Mars" }
  419.         @{ Max = 0.9;   Description = "Venus, similar to Earth" }
  420.         @{ Max = 1.0;   Description = "Earth, sea level, standard)" }
  421.         @{ Max = 1.1;   Description = "Wolf 1069 b, Earth-mass exoplanet" }
  422.         @{ Max = 1.5;   Description = "Kepler-296f, Super-Earth candidate" }
  423.         @{ Max = 2.0;   Description = "HD 40307 g, massive Super-Earth candidate" }
  424.         @{ Max = 2.5;   Description = "Gliese 667 Cc, dense iron Super-Earth" }
  425.         @{ Max = 3.0;   Description = "Neptune-like" }
  426.         @{ Max = 4.0;   Description = "Uranus-like" }
  427.         @{ Max = 5.0;   Description = "Gas giant (Jupiter-like)" }
  428.     )
  429.  
  430.  
  431.    foreach ($range in $gravityRanges) {
  432.        if ($gravityValue -le $range.Max) {
  433.            return $range.Description
  434.        }
  435.    }
  436.    return "Unknown "
  437. }
  438.  
  439.  
  440. function Get-YieldDescription {
  441.    param([double]$yieldValue)
  442.    
  443.     $yieldRanges = @(
  444.         @{ Max = 1.4;   Description = "Tiny firecracker" }
  445.         @{ Max = 2.2;   Description = "String firecracker" }
  446.         @{ Max = 3.2;   Description = "Large firecracker (M-80)" }
  447.         @{ Max = 3.9;   Description = "โญ LARGE FIREWORK (~20g TNT)" }
  448.         @{ Max = 4.5;   Description = "Very large firework shell" }    
  449.         @{ Max = 5.5;   Description = "Stun grenade (Flashbang)" }
  450.         @{ Max = 7.1;   Description = "Hand grenade (M67)" }
  451.         @{ Max = 8.9;   Description = "RPG-7 warhead" }
  452.         @{ Max = 10.0;  Description = "40mm grenade (HEDP)" }
  453.         @{ Max = 12.2;  Description = "60mm mortar shell" }
  454.         @{ Max = 15.0;  Description = "120mm mortar shell" }
  455.         @{ Max = 18.7;  Description = "Anti-tank mine" }
  456.         @{ Max = 22.4;  Description = "500lb bomb (WWII)" }
  457.         @{ Max = 27.4;  Description = "'Daisy Cutter' (BLU-82)" }
  458.         @{ Max = 33.2;  Description = "1000lb bomb (JDAM)" }
  459.         @{ Max = 41.2;  Description = "2000lb bomb (GBU-31)" }
  460.         @{ Max = 45;  Description = "Major truck bomb" }
  461.     )
  462.  
  463.    foreach ($range in $yieldRanges) {
  464.        if ([Math]::Sqrt($yieldValue) -le $range.Max) {
  465.            return $range.Description
  466.        }
  467.    }
  468.    return "No idea"
  469. }
  470.  
  471. function New-SparkShape {
  472.    param($color, $size)
  473.    
  474.    $shapeType = Get-Random -Minimum 0 -Maximum 4
  475.    
  476.    switch ($shapeType) {
  477.        0 {
  478.            $rect = New-Object System.Windows.Shapes.Rectangle
  479.            $rect.Width = $size * 1.5
  480.            $rect.Height = $size * 1.5
  481.            $rect.Fill = New-Object System.Windows.Media.SolidColorBrush $color
  482.            $rect
  483.        }
  484.        
  485.        1 {
  486.            $points = New-Object System.Windows.Media.PointCollection
  487.            $points.Add([System.Windows.Point]::new($size, 0))
  488.            $points.Add([System.Windows.Point]::new($size * 2, $size))
  489.            $points.Add([System.Windows.Point]::new($size, $size * 2))
  490.            $points.Add([System.Windows.Point]::new(0, $size))
  491.            
  492.            $polygon = New-Object System.Windows.Shapes.Polygon
  493.            $polygon.Points = $points
  494.            $polygon.Fill = New-Object System.Windows.Media.SolidColorBrush $color
  495.            $polygon.Stroke = New-Object System.Windows.Media.SolidColorBrush $color
  496.            $polygon.StrokeThickness = 0.5
  497.            $polygon.Width = $size * 2
  498.            $polygon.Height = $size * 2
  499.            $polygon
  500.        }
  501.        
  502.        2 {
  503.            $geometry = New-Object System.Windows.Media.GeometryGroup
  504.            $verticalRect = New-Object System.Windows.Media.RectangleGeometry
  505.            $verticalRect.Rect = [System.Windows.Rect]::new($size * 0.7, 0, $size * 0.6, $size * 2)
  506.            $horizontalRect = New-Object System.Windows.Media.RectangleGeometry
  507.            $horizontalRect.Rect = [System.Windows.Rect]::new(0, $size * 0.7, $size * 2, $size * 0.6)
  508.            $geometry.Children.Add($verticalRect)
  509.            $geometry.Children.Add($horizontalRect)
  510.            
  511.            $path = New-Object System.Windows.Shapes.Path
  512.            $path.Data = $geometry
  513.            $path.Fill = New-Object System.Windows.Media.SolidColorBrush $color
  514.            $path.Width = $size * 2
  515.            $path.Height = $size * 2
  516.            $path
  517.        }
  518.        
  519.        3 {
  520.            $geometry = New-Object System.Windows.Media.GeometryGroup
  521.            $pathGeometry1 = New-Object System.Windows.Media.PathGeometry
  522.            $figure1 = New-Object System.Windows.Media.PathFigure
  523.            $figure1.StartPoint = [System.Windows.Point]::new(0, 0)
  524.            $figure1.Segments.Add([System.Windows.Media.LineSegment]::new([System.Windows.Point]::new($size, $size * 2), $true))
  525.            $figure1.Segments.Add([System.Windows.Media.LineSegment]::new([System.Windows.Point]::new($size * 2, 0), $true))
  526.            $figure1.IsClosed = $true
  527.            $pathGeometry1.Figures.Add($figure1)
  528.            
  529.            $pathGeometry2 = New-Object System.Windows.Media.PathGeometry
  530.            $figure2 = New-Object System.Windows.Media.PathFigure
  531.            $figure2.StartPoint = [System.Windows.Point]::new(0, $size * 2)
  532.            $figure2.Segments.Add([System.Windows.Media.LineSegment]::new([System.Windows.Point]::new($size, 0), $true))
  533.            $figure2.Segments.Add([System.Windows.Media.LineSegment]::new([System.Windows.Point]::new($size * 2, $size * 2), $true))
  534.            $figure2.IsClosed = $true
  535.            $pathGeometry2.Figures.Add($figure2)
  536.            
  537.            $geometry.Children.Add($pathGeometry1)
  538.            $geometry.Children.Add($pathGeometry2)
  539.            
  540.            $path = New-Object System.Windows.Shapes.Path
  541.            $path.Data = $geometry
  542.            $path.Fill = New-Object System.Windows.Media.SolidColorBrush $color
  543.            $path.Width = $size * 2
  544.            $path.Height = $size * 2
  545.            $path
  546.        }
  547.    }
  548. }
  549.  
  550.  
  551. function Sort-AllColorPalettes {
  552.    function Get-ColorBrightness($Color) {
  553.        return (0.3 * $Color.R + 0.4 * $Color.G + 0.3 * $Color.B) / 255.0
  554.    }
  555.    $palettePairs = @(
  556.        @{Name = "ColorsRed"; Value = $ColorsRed }
  557.        @{Name = "ColorsPurple"; Value = $ColorsPurple }
  558.        @{Name = "ColorsGreen"; Value = $ColorsGreen }
  559.        @{Name = "ColorsYellow"; Value = $ColorsYellow }
  560.        @{Name = "ColorsBlue"; Value = $ColorsBlue }
  561.        @{Name = "ColorsOrange"; Value = $ColorsOrange }
  562.        @{Name = "ColorsRainbow"; Value = $ColorsRainbow }
  563.        @{Name = "ColorsPastel"; Value = $ColorsPastel }
  564.        @{Name = "ColorsChristmas"; Value = $ColorsChristmas }
  565.    )
  566.    
  567.    foreach ($pair in $palettePairs) {
  568.        $sorted = $pair.Value | Sort-Object { Get-ColorBrightness $_ } -Descending
  569.        Set-Variable -Scope Script -Name $pair.Name -Value $sorted
  570.    }
  571. }
  572.  
  573.  
  574. function Add-TwinkleColorsToPalettes {
  575.    foreach ($paletteName in @("ColorsRed", "ColorsPurple", "ColorsGreen", "ColorsYellow",
  576.                               "ColorsBlue", "ColorsOrange", "ColorsRainbow", "ColorsPastel", "ColorsChristmas")) {
  577.        $palette = Get-Variable -Name $paletteName -ValueOnly
  578.        
  579.        $twinkleColors = @()
  580.        foreach ($color in $palette) {
  581.            
  582.            
  583.            
  584.            $twinkle1 = [System.Windows.Media.Color]::FromRgb(
  585.                [Math]::Min(255, $color.R + 70),
  586.                [Math]::Min(255, $color.G + 70),
  587.                [Math]::Min(255, $color.B + 70)
  588.            )
  589.            $twinkle2 = [System.Windows.Media.Color]::FromRgb(
  590.                [Math]::Min(255, $color.R + 100),
  591.                [Math]::Min(255, $color.G + 100),
  592.                [Math]::Min(255, $color.B + 100)
  593.            )
  594.            
  595.            $twinkleColors += $twinkle1, $twinkle2
  596.        }
  597.        $extendedPalette = $twinkleColors + $palette
  598.        Set-Variable -Scope Script -Name $paletteName -Value $extendedPalette
  599.    }
  600. }
  601.  
  602. Sort-AllColorPalettes
  603. Add-TwinkleColorsToPalettes
  604.  
  605. function Get-ColorPalette {
  606.    param(
  607.        [int]$MinColors = 3,
  608.        [int]$MaxColors = 10,
  609.        [switch]$RandomSize = $true,
  610.        [switch]$Sorted = $true  
  611.    )
  612.    
  613.  
  614.    $palettes = @($ColorsRed, $ColorsPurple, $ColorsGreen, $ColorsYellow,
  615.                  $ColorsBlue, $ColorsOrange, $ColorsRainbow, $ColorsPastel, $ColorsChristmas)
  616.    $selectedPalette = $palettes[(Get-Random -Minimum 0 -Maximum $palettes.Count)]
  617.    if ($RandomSize) {
  618.        $paletteSize = Get-Random -Minimum $MinColors -Maximum $MaxColors
  619.    } else {
  620.        $paletteSize = $MaxColors
  621.    }
  622.    if ($paletteSize -lt $selectedPalette.Count) {
  623.        $startIndex = Get-Random -Minimum 0 -Maximum ($selectedPalette.Count - $paletteSize)
  624.        $palette = $selectedPalette[$startIndex..($startIndex + $paletteSize - 1)]
  625.    } else {
  626.        $palette = $selectedPalette[0..($paletteSize - 1)]
  627.    }
  628.    
  629.    return $palette
  630. }
  631.  
  632.  
  633. function Apply-BlastToSnowflakes {
  634.    param($blastX, $blastY, $blastPower = 40)
  635.    
  636.  
  637.    $airDensity = [Math]::Max(0.001, $script:AirResistance)
  638.    $baseRadius = 250
  639.    $blastRadius = $baseRadius / (1 + $airDensity * 5)
  640.    $baseForce = $blastPower * 0.5
  641.    $maxForce = $baseForce / (1 + $airDensity * 8)
  642.    
  643.    foreach ($flake in $snowflakes) {
  644.        $dx = $flake.X - $blastX
  645.        $dy = $flake.Y - $blastY
  646.        $distance = [Math]::Sqrt($dx * $dx + $dy * $dy)
  647.        
  648.        if ($distance -lt $blastRadius -and $distance -gt 3) {
  649.            $dirX = $dx / $distance
  650.            $dirY = $dy / $distance
  651.            $distanceFactor = 1.0 / ($distance * 0.08)
  652.            $force = $maxForce * $distanceFactor
  653.            $force = [Math]::Min($force, $maxForce * 1.5)
  654.            $massFactor = 1.0 / ($flake.Mass + 0.3)
  655.            
  656.            $flake.VX += $dirX * $force * $massFactor * 0.015
  657.            $flake.VY += $dirY * $force * $massFactor * 0.015
  658.            
  659.            
  660.            $turbulence = 1.0 / (1 + $airDensity * 4)
  661.            $flake.VX += (Get-Random -Minimum -$turbulence -Maximum $turbulence) * 0.005
  662.            $flake.VY += (Get-Random -Minimum -$turbulence -Maximum $turbulence) * 0.005
  663.            
  664.            $rotationEffect = 1.0 / (1 + $airDensity * 2)
  665.            $flake.RotationSpeed += (Get-Random -Minimum -4 -Maximum 4) * $rotationEffect
  666.        }
  667.    }
  668. }
  669.  
  670.  
  671.  
  672. function New-Firework {
  673.    param($x, $y)
  674.  
  675.    $PIXEL_SCALE = 2.0
  676.    $halfPhysicsScale = 0.5 * $script:PHYSICS_SCALE
  677.     $baseExplosionForce = $script:ExplosionForce * $script:PHYSICS_SCALE
  678.    
  679.    $dragFactor = $script:AirResistance * 0.8
  680.    $viscosity = 1.0 + ($dragFactor * 3.0)
  681.    $tanhArg = ($dragFactor - 0.015) * 20
  682.    $adjustment = 1.0 + (0.3 * [Math]::Tanh($tanhArg))
  683.    $mediumDamping = 1.0 / (1.0 + ($viscosity * $dragFactor * $adjustment))
  684.    $effectiveExplosionForce = $baseExplosionForce * $mediumDamping
  685.    $fireworkPalette = Get-ColorPalette
  686.     $paletteSize = $fireworkPalette.Count
  687.     $BlastForceForSnow = $script:ExplosionForce * 10
  688.    Apply-BlastToSnowflakes $x $y $BlastForceForSnow
  689.    $randomSparkCount = Get-Random -Minimum 0 -Maximum 15
  690.    $nSparks = [math]::Round(25 + $randomSparkCount)
  691.    
  692.    $avgForcePerSpark = $effectiveExplosionForce / [Math]::Max(1, $nSparks)
  693.    
  694.    $rng = New-Object System.Random
  695.    $SPEED_SCALE_FACTOR = 2000
  696.    $speedLimitFactor = 1.0 / (1.0 + ($script:AirResistance * 2.0))
  697.     Apply-BlastToSnowflakes
  698.    for ($i = 0; $i -lt $nSparks; $i++) {
  699.        $baseSize = $rng.Next(1, 5)  
  700.        $angle = $rng.NextDouble() * 360.0
  701.        $radians = $angle * [Math]::PI / 180.0
  702.        
  703.        $mass = $baseSize * $halfPhysicsScale
  704.        
  705.        $forceShare = 0.7 + ($rng.NextDouble() * 0.6)  
  706.        $sparkForce = $avgForcePerSpark * $forceShare
  707.        
  708.        $baseSpeed = ($sparkForce * $SPEED_SCALE_FACTOR) / $mass
  709.        $sizeDragEffect = 1.0 / [Math]::Sqrt($baseSize)  
  710.        $massInertiaEffect = [Math]::Sqrt($mass / 50)  
  711.        $initialSpeed = $baseSpeed * $sizeDragEffect * $massInertiaEffect
  712.        $randomMultiplier = 0.8 + ($rng.NextDouble() * 0.4)
  713.        $initialSpeed = $initialSpeed * $randomMultiplier
  714.        $targetSpeed = $initialSpeed * $speedLimitFactor
  715.        $finalRandom = 0.9 + ($rng.NextDouble() * 0.2 * (1.0 + $script:AirResistance))
  716.        $initialSpeed = $targetSpeed * $finalRandom
  717.        
  718.        if ($script:AirResistance -gt 1.0) {
  719.            $angleNoise = ($rng.NextDouble() - 0.5) * 25.0 * $script:AirResistance
  720.            $radians += $angleNoise * [Math]::PI / 180.0
  721.        }
  722.        
  723.        
  724.        
  725.        $maxStartIndex = [Math]::Min(2, $paletteSize - 1)
  726.        $startColorIndex = $rng.Next(0, $maxStartIndex + 1)
  727.        $currentColorIndex = $startColorIndex
  728.        $startColor = $fireworkPalette[$startColorIndex]
  729.        $shape = New-SparkShape -color $startColor -size $baseSize
  730.        
  731.        if ($shape -eq $null) { continue }
  732.        $halfWidth = $shape.Width / 2
  733.        $halfHeight = $shape.Height / 2
  734.        $shapePosX = $x - $halfWidth
  735.        $shapePosY = $y - $halfHeight
  736.        
  737.        $fireCanvas.Children.Add($shape) | Out-Null
  738.        [System.Windows.Controls.Canvas]::SetLeft($shape, $shapePosX)
  739.        [System.Windows.Controls.Canvas]::SetTop($shape, $shapePosY)
  740.  
  741.        $cosAngle = [Math]::Cos($radians)
  742.        $sinAngle = [Math]::Sin($radians)
  743.        $velocityX = $cosAngle * $initialSpeed
  744.        $velocityY = $sinAngle * $initialSpeed
  745.        
  746.        $spark = [PSCustomObject]@{
  747.            Shape = $shape
  748.            X = $x
  749.            Y = $y
  750.            VX = $velocityX
  751.            VY = $velocityY
  752.            Opacity = 1
  753.            BaseSize = $baseSize
  754.            CurrentSize = $baseSize
  755.            Rotation = $rng.Next(0, 360)
  756.            RotationSpeed = $rng.Next(-15, 15)
  757.            Mass = $mass
  758.            PhysicsScale = $script:PHYSICS_SCALE
  759.            LifeTime = $rng.Next(40, 100)
  760.            Age = 0
  761.            CurrentColorIndex = $currentColorIndex
  762.            StartColorIndex = $startColorIndex
  763.            ColorChangeCounter = 0
  764.            ColorChangeSpeed = $rng.Next(3, 8)
  765.            ShapeType = $shape.GetType().Name
  766.            MediumDamping = $mediumDamping
  767.            DarkenOverTime = $true
  768.             ShouldTwinkle = $rng.NextDouble() -lt 0.3
  769.             TwinkleIntensity = $rng.NextDouble() * 0.2 + 0.1
  770.             TwinkleFrequency = $rng.Next(5, 15)
  771.             TwinkleCounter = 0
  772.             ColorPalette = $fireworkPalette
  773.             StartInTwinkleZone = $rng.NextDouble() -lt 0.5
  774.             IsTwinkling = $false
  775.             TwinklePhase = 0
  776.        }
  777.        
  778.        $activeSparks.Add($spark)
  779.    }
  780.    
  781.     $soundIndex = Get-Random -Minimum 0 -Maximum 3
  782.    $volume = 0.8 + $script:ExplosionForce / 100
  783.    $adjustedVolume = $volume * $mediumDamping
  784.    
  785.    #$boom = New-Object System.Windows.Media.MediaPlayer
  786.    
  787.    # Register-ObjectEvent -InputObject $boom -EventName MediaEnded -Action {
  788.        # $boom = $EventArgs.Source
  789.        # $boom.Close()
  790.        # $boom = $null
  791.    # } | Out-Null
  792.    # switch ($soundIndex) {
  793.        # 0 { $boom.Open([Uri](Join-Path $SCRIPT_DIR "a.wav")) }
  794.        # 1 { $boom.Open([Uri](Join-Path $SCRIPT_DIR "b.wav")) }
  795.        # 2 { $boom.Open([Uri](Join-Path $SCRIPT_DIR "c.wav")) }
  796.    # }
  797.    
  798.    # $boom.Volume = [Math]::Max(0.1, [Math]::Min(1.0, $adjustedVolume))
  799.    # $boom.Play()
  800. }
  801.  
  802. $reader = New-Object System.Xml.XmlNodeReader $xaml
  803. $window = [Windows.Markup.XamlReader]::Load($reader)
  804.  
  805.  
  806. $snowtest = $window.FindName("SnowTest")
  807. $fpstext = $window.FindName("FPS")
  808. $fireCanvas = $window.FindName("FireCanvas")
  809. $canvas = $window.FindName("MainCanvas")
  810. $window.Add_MouseLeftButtonDown({
  811.    $pos = $_.GetPosition($fireCanvas)
  812.    New-Firework $pos.X $pos.Y
  813. })
  814.  
  815. function UpdatePhysicsLabel {
  816.    $label = $window.FindName("CurrentPhysicsLabel")
  817.    $roundDragCoeff = [math]::Round($script:AirResistance,3)
  818.    $descDensity = Get-DragDescription $roundDragCoeff    
  819.     $roundGravity = [math]::Round($script:Gravity*2,1)
  820.    $descGravity = Get-GravityDescription $roundGravity
  821.     $roundYield = [math]::Round($script:ExplosionForce,1)
  822.    $descYield = Get-YieldDescription $roundYield
  823.    
  824.    
  825.    $label.Text = "โš™๏ธ Current: G($descGravity)=$roundGravity, E($descYield)=$roundYield, D($descDensity)=$roundDragCoeff"
  826.     $script:SNOW_AIR_DRAG_SCALED = $script:AirResistance * $script:PHYSICS_SCALE / 50
  827.     $script:SNOW_GRAVITY_SCALED = $script:Gravity * $script:SNOW_GRAVITY_SCALE / 5
  828.     $script:AIR_RESISTANCE_ABS = [Math]::Abs($airResistance)
  829.     $script:DARK_ENERGY_FORCE = $script:AIR_RESISTANCE_ABS * 10 * $deltaTime  
  830. }
  831.  
  832.  
  833.  
  834. $window.Add_KeyDown({
  835.    param($sender, $e)
  836.  
  837.    switch ($e.Key) {
  838.        'G' {
  839.            $delta = if ($e.KeyboardDevice.Modifiers -band 'Shift') { -0.01 } else { 0.01 }
  840.             $slider = $window.FindName("GravitySlider")        
  841.            $script:Gravity = ([math]::Max($slider.Minimum, [math]::Min($slider.Maximum,$slider.Value + $delta)))/2
  842.             $slider.Value = $script:Gravity*2
  843.            UpdatePhysicsLabel
  844.        }
  845.        'E' {
  846.            $delta = if ($e.KeyboardDevice.Modifiers -band 'Shift') { -1 } else { 1 }
  847.            $slider = $window.FindName("ForceSlider")
  848.            $script:ExplosionForce = [math]::Max($slider.Minimum, [math]::Min($slider.Maximum, $script:ExplosionForce + $delta))
  849.            $slider.Value = $script:ExplosionForce
  850.            UpdatePhysicsLabel
  851.        }
  852.        'D' {
  853.            $delta = if ($e.KeyboardDevice.Modifiers -band 'Shift') { -0.001 } else { 0.001 }
  854.            $slider = $window.FindName("AirResistanceSlider")
  855.            $script:AirResistance = [math]::Max($slider.Minimum, [math]::Min($slider.Maximum, $script:AirResistance + $delta))
  856.            $slider.Value = $script:AirResistance
  857.            UpdatePhysicsLabel
  858.        }
  859.    }
  860.  
  861.    $e.Handled = $true
  862. })
  863.  
  864. UpdatePhysicsLabel
  865.  
  866. $gravitySlider = $window.FindName("GravitySlider")
  867. $forceSlider = $window.FindName("ForceSlider")
  868. $airSlider = $window.FindName("AirResistanceSlider")
  869.  
  870.  
  871. $gravitySlider.Add_ValueChanged({
  872.    $value = [math]::Round($this.Value, 2)
  873.    $window.FindName("GravityValue").Text = "Gravity: $value"
  874.    $script:Gravity = $value/2
  875.    UpdatePhysicsLabel
  876. })
  877.  
  878. $forceSlider.Add_ValueChanged({
  879.    $value = [math]::Round($this.Value, 1)
  880.    $window.FindName("ForceValue").Text = "Explosion size: $value"
  881.    $script:ExplosionForce = $value
  882.    UpdatePhysicsLabel
  883. })
  884.  
  885. $airSlider.Add_ValueChanged({
  886.    $value = [math]::Round($this.Value, 3)
  887.    $window.FindName("AirResistanceValue").Text = "Drag Coefficient: $value"
  888.    $script:AirResistance = $value
  889.    UpdatePhysicsLabel
  890. })
  891.  
  892. $window.FindName("ResetButton").Add_Click({
  893.    $script:Gravity = 0.5
  894.    $script:ExplosionForce = 15
  895.    $script:AirResistance = 0.015
  896.    
  897.    $window.FindName("GravitySlider").Value = 1
  898.    $window.FindName("ForceSlider").Value = 15
  899.    $window.FindName("AirResistanceSlider").Value = 0.015
  900.    
  901.    UpdatePhysicsLabel
  902. })
  903.  
  904. UpdatePhysicsLabel
  905.  
  906. $shapes = "A","B","C","D"
  907. $flakes = for ($i = 1; $i -le 50; $i++) {
  908.    @{
  909.        Name  = "fl$i"
  910.        X     = Get-Random -Min 0 -Max 800
  911.        Y     = Get-Random -Min -30 -Max 630
  912.        Shape = Get-Random $shapes
  913.    }
  914. }
  915.  
  916. $snowflakes = @()
  917. $SNOWFLAKE_SHAPES = @{
  918.    A = "M10,0 L10.5,1.5 L12,1 L11,3 L13,4 L11,5 L12,7 L10,6 L8,7 L9,5 L7,4 L9,3 L8,1 L9.5,1.5 Z"
  919.    B = "M10,0 L11,3 L14,4 L11,5 L12,8 L10,6 L8,8 L9,5 L6,4 L9,3 Z"
  920.    C = "M10,0 L12,6 L18,6 L13,10 L15,16 L10,12 L5,16 L7,10 L2,6 L8,6 Z"
  921.    D = "M11,0 L13,4 L16,5 L13,7 L14,10 L11,7 L8,10 L9,7 L6,5 L9,4 L11,0 Z"
  922. }
  923.  
  924. foreach ($f in $flakes) {
  925.    $flake = [PSCustomObject]@{
  926.        Shape = $null
  927.        X = $f.X
  928.        Y = $f.Y
  929.        Mass = 0.15
  930.        VY = 0
  931.        VX = 0
  932.        Rotation = 0
  933.        RotationSpeed = (Get-Random -Minimum -2 -Maximum 2)
  934.        Size = (Get-Random -Minimum 0.8 -Maximum 1.2)
  935.        LifeTime = 0
  936.        Wind = (Get-Random -Minimum -0.5 -Maximum 0.5)
  937.        MaxLifeTime = 1200
  938.        IsActive = $true
  939.    }
  940.    $flake.VY = $script:AirResistance * $script:SNOW_AIRDRAG_SCALE
  941.    
  942.    $p = New-Object System.Windows.Shapes.Path
  943.    $p.Name = $f.Name
  944.    $p.Fill = [System.Windows.Media.Brushes]::White
  945.    $p.Stroke = [System.Windows.Media.Brushes]::LightBlue
  946.    $p.StrokeThickness = 1
  947.    $p.Data = [System.Windows.Media.Geometry]::Parse($SNOWFLAKE_SHAPES[$f.Shape])
  948.    $p.Opacity = (Get-Random -Minimum 0.3 -Maximum 0.5)
  949.    
  950.    $scale = New-Object System.Windows.Media.ScaleTransform
  951.    $scale.ScaleX = $flake.Size
  952.    $scale.ScaleY = $flake.Size
  953.    $p.RenderTransform = $scale
  954.    
  955.    $flake.Shape = $p
  956.    $snowflakes += $flake
  957.    
  958.    [System.Windows.Controls.Canvas]::SetLeft($p, $flake.X)
  959.    [System.Windows.Controls.Canvas]::SetTop($p, $flake.Y)
  960.    $canvas.Children.Add($p) | Out-Null
  961. }
  962.  
  963. $activeSparks = New-Object System.Collections.Generic.List[PSCustomObject]
  964. $activeBlastWaves = New-Object System.Collections.ArrayList
  965.  
  966. $snowTimer = New-Object System.Windows.Threading.DispatcherTimer
  967. $snowTimer.Interval = [System.TimeSpan]::FromMilliseconds(60)
  968.  
  969.  
  970. $snowTimer.Add_Tick({
  971.    $gravity = $script:SNOW_GRAVITY_SCALED
  972.    $airResistance = $script:SNOW_AIR_DRAG_SCALED
  973.    $windStrength = 0.3
  974.    $airResistanceAbs = [Math]::Abs($airResistance)
  975.     #$oCount = ($flakes.Count+$activeSparks.Count)
  976.    #$fpstext.Text = "Objects count: $oCount"
  977.    $deltaTime = $script:deltaTime
  978.    
  979.    $windFrequency = 50.0
  980.    $windAmplitude = 0.3
  981.    
  982.    $centerX = 400
  983.    $centerY = 300
  984.    $darkEnergyForce = $script:DARK_ENERGY_FORCE
  985.    
  986.    $rotationDampFactor = 0.2
  987.    
  988.    $canvasWidth = $canvas.ActualWidth
  989.    $resetMinY = -10
  990.    $resetMaxY = 610
  991.     $resetMaxYP20 = $resetMaxY+20
  992.     $resetMinYM20 = $resetMinY-20
  993.    $resetOpacityMin = 0.7
  994.    $resetOpacityMax = 1.0
  995.    $resetWindMin = -0.3
  996.    $resetWindMax = 0.3
  997.    $resetVXDamping = 0.7
  998.    $resetFlakeDamping = 0.8 - [Math]::Min($airResistanceAbs * 0.1, 0.5)
  999.    
  1000.    
  1001.    foreach ($flake in $snowflakes) {
  1002.        if (-not $flake.IsActive) { continue }
  1003.        
  1004.        $flake.LifeTime++
  1005.        $mass = $flake.Mass
  1006.        $forceY = $gravity * $mass
  1007.        
  1008.        $windVariation = 1 + [Math]::Sin($flake.LifeTime / $windFrequency) * $windAmplitude
  1009.        $currentWind = $flake.Wind * $windStrength * $windVariation
  1010.        $forceX = $currentWind * $mass
  1011.        
  1012.        $vx = $flake.VX
  1013.        $vy = $flake.VY
  1014.        $speed = [Math]::Sqrt($vx * $vx + $vy * $vy)
  1015.        
  1016.        if ($speed -gt 0) {
  1017.            $dragForce = $airResistance * $speed
  1018.            $dragEffect = $dragForce * (1.0 / $speed) * 0.1  
  1019.            
  1020.            $flake.VX -= $dragEffect * $vx
  1021.            $flake.VY -= $dragEffect * $vy
  1022.        }
  1023.        
  1024.        if ($airResistance -gt 0.0001) {
  1025.            $terminalVelocity = ($gravity * $mass) / $airResistance
  1026.            
  1027.            if ([Math]::Abs($terminalVelocity) -gt $script:maxSnowSpeed) {
  1028.                $terminalVelocity = [Math]::Sign($terminalVelocity) * $script:maxSnowSpeed
  1029.            }
  1030.        } else {
  1031.            $terminalVelocity = 0
  1032.        }
  1033.         $fvy=$flake.VY
  1034.        
  1035.        if ([Math]::Sign($flake.VY) -eq [Math]::Sign($gravity) -and
  1036.            [Math]::Abs($flake.VY) -gt [Math]::Abs($terminalVelocity)) {
  1037.            $flake.VY = $terminalVelocity
  1038.        }
  1039.        
  1040.        $flake.VX += $forceX
  1041.        $flake.VY += $forceY
  1042.        
  1043.        if ($airResistance -lt 0) {
  1044.            $vecX = $flake.X - $centerX
  1045.            $vecY = $flake.Y - $centerY
  1046.            $distanceSquared = $vecX * $vecX + $vecY * $vecY
  1047.            
  1048.            if ($distanceSquared -lt 0.01) {  
  1049.                $distanceSquared = 0.01
  1050.            }
  1051.            
  1052.            $distance = [Math]::Sqrt($distanceSquared)
  1053.            $distanceInverse = 1.0 / $distance
  1054.            $dirX = $vecX * $distanceInverse
  1055.            $dirY = $vecY * $distanceInverse
  1056.            
  1057.            $flake.VX += $dirX * $darkEnergyForce  
  1058.            $flake.VY += $dirY * $darkEnergyForce  
  1059.        }
  1060.        
  1061.        $flake.X += $flake.VX
  1062.        $flake.Y += $flake.VY
  1063.        
  1064.        $rotationDamping = 1.0 - [Math]::Min($airResistanceAbs * $rotationDampFactor, 0.8)
  1065.        $flake.Rotation += $flake.RotationSpeed * $rotationDamping * $deltaTime
  1066.        $flake.RotationSpeed *= $rotationDamping
  1067.  
  1068.        if ($flake.X -lt -20) {
  1069.            $flake.X = 820
  1070.            $flake.VX = [Math]::Abs($flake.VX) * $resetVXDamping
  1071.        }
  1072.        elseif ($flake.X -gt 820) {
  1073.            $flake.X = -20
  1074.            $flake.VX = -[Math]::Abs($flake.VX) * $resetVXDamping
  1075.        }
  1076.        
  1077.        
  1078.        
  1079.        if ($flake.Y -le $resetMinYM20) {
  1080.             $flake.X = Get-Random -Minimum 0 -Maximum $canvasWidth
  1081.            $flake.Y = Get-Random -Minimum $resetMaxY -Maximum $resetMaxYP20
  1082.             $flake.VX *= $resetFlakeDamping
  1083.            $flake.VY *= $resetFlakeDamping
  1084.            
  1085.            $flake.LifeTime = 0
  1086.            $flake.Shape.Opacity = Get-Random -Minimum $resetOpacityMin -Maximum $resetOpacityMax
  1087.            $flake.Wind = Get-Random -Minimum $resetWindMin -Maximum $resetWindMax
  1088.            $flake.IsActive = $true
  1089.         }  
  1090.         if ($flake.Y -gt $resetMaxYP20) {
  1091.            $flake.X = Get-Random -Minimum 0 -Maximum $canvasWidth
  1092.            $flake.Y = Get-Random -Minimum $resetMinYM20 -Maximum $resetMinY
  1093.             $flake.VX *= $resetFlakeDamping
  1094.            $flake.VY *= $resetFlakeDamping
  1095.            
  1096.            $flake.LifeTime = 0
  1097.            $flake.Shape.Opacity = Get-Random -Minimum $resetOpacityMin -Maximum $resetOpacityMax
  1098.            $flake.Wind = Get-Random -Minimum $resetWindMin -Maximum $resetWindMax
  1099.            $flake.IsActive = $true
  1100.        }
  1101.      
  1102.        [System.Windows.Controls.Canvas]::SetLeft($flake.Shape, $flake.X)
  1103.        [System.Windows.Controls.Canvas]::SetTop($flake.Shape, $flake.Y)
  1104.        
  1105.        $rotate = New-Object System.Windows.Media.RotateTransform
  1106.        $rotate.Angle = $flake.Rotation
  1107.        $flake.Shape.RenderTransform = $rotate
  1108.        
  1109.        if ((Get-Random) -lt 0.1) {
  1110.            $flake.Shape.Opacity = $flake.Shape.Opacity * (0.8 + (Get-Random -Minimum 0 -Maximum 20) / 100)
  1111.        }
  1112.    }
  1113. })
  1114.  
  1115. $updateTimer = New-Object System.Windows.Threading.DispatcherTimer
  1116. $updateTimer.Interval = [TimeSpan]::FromMilliseconds(30)
  1117.  
  1118.  
  1119. $updateTimer.Add_Tick({
  1120.    
  1121.    
  1122.     # $timeLeft = $player1.NaturalDuration.TimeSpan - $player1.Position
  1123.     # $minutes = [int]$timeLeft.TotalMinutes
  1124.     # $seconds = $timeLeft.Seconds
  1125.     # $ms = $timeLeft.Milliseconds
  1126.     # $timeText = "{0:D2}:{1:D2}.{2:D3}" -f $minutes, $seconds, $ms
  1127.    
  1128.     # $snowtest.Text = $timeText
  1129.    
  1130.     #$script:deltaTime = 1.0
  1131.        
  1132.    $currentGravity = $script:Gravity * $script:PHYSICS_SCALE / 10
  1133.    $airResistanceBase = 0.3 * ($script:AirResistance / 0.02)
  1134.    
  1135.    if ($script:AirResistance -gt 1.0) {
  1136.        $nonLinearFactor = [Math]::Sqrt($script:AirResistance)
  1137.        $currentAirResistance = 0.3 * $nonLinearFactor * 10
  1138.    } else {
  1139.        $currentAirResistance = $airResistanceBase
  1140.    }
  1141.    $deltaTime = $script:deltaTime #*1.0
  1142.    $deltaTimeDouble = $script:deltaTime*2.0
  1143.    $minSpeedThreshold = 2.0
  1144.    
  1145.    $physScaleTimes5 = $script:PHYSICS_SCALE * 5
  1146.    $speedNormalizationDivisor = $script:PHYSICS_SCALE * 50.0
  1147.    $positionScale = ($deltaTimeDouble) / $script:PHYSICS_SCALE
  1148.    
  1149.    foreach ($s in $activeSparks.ToArray()) {
  1150.        $s.Age++
  1151.        
  1152.        $mass = $s.Mass
  1153.        $massNormalized = $mass / $script:PHYSICS_SCALE
  1154.        $forceY = ($currentGravity * $mass) / $script:PHYSICS_SCALE
  1155.        
  1156.        $vx = $s.VX
  1157.        $vy = $s.VY
  1158.        $vxSquared = $vx * $vx
  1159.        $vySquared = $vy * $vy
  1160.        $speed = [Math]::Sqrt($vxSquared + $vySquared)
  1161.        
  1162.        $dragX = 0
  1163.        $dragY = 0
  1164.        if ($speed -gt 0.001) {
  1165.            $speedOverPhysScale = $speed / $script:PHYSICS_SCALE
  1166.            $speedOverPhysScaleTimes5 = $speed / $physScaleTimes5
  1167.            
  1168.            $minSpeedRatio = [Math]::Min($speedOverPhysScale, 1.0)
  1169.            $additionalFactor = 0.3 + [Math]::Min($speedOverPhysScaleTimes5, 2.0)
  1170.            
  1171.            $dragForce = $currentAirResistance * $speed * $minSpeedRatio * $additionalFactor
  1172.            
  1173.            $maxStoppingForce = $massNormalized * ($speed / $deltaTimeDouble)
  1174.            if ($dragForce -gt $maxStoppingForce) {
  1175.                $dragForce = $maxStoppingForce
  1176.            }
  1177.            
  1178.            if ($dragForce -lt 0) {
  1179.                $maxNegativeDrag = 0.5 * $speed * $massNormalized
  1180.                $dragForce = [Math]::Max($dragForce, -$maxNegativeDrag)
  1181.            }
  1182.            
  1183.            $dragX = (-$dragForce * $vx) / $speed
  1184.            $dragY = (-$dragForce * $vy) / $speed
  1185.        }
  1186.        
  1187.        $accelerationX = $dragX / $massNormalized
  1188.        $accelerationY = ($forceY + $dragY) / $massNormalized
  1189.        
  1190.        $s.VX += $accelerationX * $deltaTime
  1191.        $s.VY += $accelerationY * $deltaTime
  1192.        
  1193.        if ([Math]::Abs($s.VX) -lt $minSpeedThreshold) { $s.VX = 0 }
  1194.        if ([Math]::Abs($s.VY) -lt $minSpeedThreshold) { $s.VY = 0 }
  1195.        
  1196.        $s.X += $s.VX * $positionScale
  1197.        $s.Y += $s.VY * $positionScale
  1198.        
  1199.        $lifeRatio = $s.Age / $s.LifeTime
  1200.        $normalizedSpeed = [Math]::Min(1.0, ($speed / $speedNormalizationDivisor))
  1201.        $opacityCalc = 1 - ($lifeRatio * $lifeRatio) - ($normalizedSpeed * 0.1)
  1202.        if ($opacityCalc -gt 0) {
  1203.            $s.Opacity = [Math]::Max(0, $opacityCalc)
  1204.        } else {
  1205.            $s.Opacity = 0
  1206.        }
  1207.        
  1208.        $sizeReduction = $lifeRatio * 0.7 + ($normalizedSpeed * 0.1)
  1209.        $s.CurrentSize = [Math]::Max(0.1, $s.BaseSize * (1 - $sizeReduction))
  1210.        
  1211.        $rotationFactor = 1 - ($lifeRatio * 0.5) - ($normalizedSpeed * 0.2)
  1212.        $s.Rotation += $s.RotationSpeed * $rotationFactor
  1213.        
  1214.        $s.ColorChangeCounter++
  1215.        if ($s.ColorChangeCounter -ge $s.ColorChangeSpeed) {
  1216.            $s.ColorChangeCounter = 0
  1217.            $s.CurrentColorIndex = ($s.CurrentColorIndex + 1) % $s.ColorPalette.Count
  1218.            $newColor = $s.ColorPalette[$s.CurrentColorIndex]
  1219.            
  1220.            $brush = New-Object System.Windows.Media.SolidColorBrush $newColor
  1221.            
  1222.            if ($s.ShapeType -eq "Rectangle") {
  1223.                $s.Shape.Fill = $brush
  1224.            } elseif ($s.ShapeType -eq "Polygon") {
  1225.                $s.Shape.Fill = $brush
  1226.                if ($s.Shape.Points.Count -eq 4) {
  1227.                    $s.Shape.Stroke = $brush
  1228.                }
  1229.            } elseif ($s.ShapeType -eq "Path") {
  1230.                $s.Shape.Fill = $brush
  1231.            }
  1232.        }
  1233.        
  1234.         if ($s.StartInTwinkleZone -and $s.Age -lt 10) {
  1235.             $s.IsTwinkling = $true
  1236.             $s.TwinklePhase = ($s.Age % 3)
  1237.             $s.CurrentColorIndex = $s.TwinklePhase
  1238.         } elseif ($s.IsTwinkling) {
  1239.             $s.IsTwinkling = $false
  1240.             $s.CurrentColorIndex = $twinkleColorCount + (Get-Random -Minimum 0 -Maximum 3)
  1241.         } else {
  1242.             if ($s.CurrentColorIndex -lt $s.ColorPalette.Count - 1) {
  1243.                 $s.CurrentColorIndex++
  1244.             }
  1245.         }
  1246.  
  1247.         if ((Get-Random) -lt 0.02 -and $s.Age -gt 20 -and $s.Age -lt $s.LifeTime - 20) {
  1248.             $s.CurrentColorIndex = Get-Random -Minimum 0 -Maximum $twinkleColorCount
  1249.         }
  1250.        
  1251.        if ($s.Age -ge $s.LifeTime -or $s.Opacity -le 0.05 -or
  1252.            $s.CurrentSize -le 0.1 -or $s.Y -gt $fireCanvas.ActualHeight) {
  1253.            $fireCanvas.Children.Remove($s.Shape)
  1254.            $null = $activeSparks.Remove($s)
  1255.             $script:NumberOfObjects = $script:NumberOfObjects - 1
  1256.            continue
  1257.        }
  1258.        
  1259.        $s.Shape.Opacity = $s.Opacity
  1260.        
  1261.        $scale = $s.CurrentSize / $s.BaseSize
  1262.        $sizeScaled = $s.BaseSize * 2 * $scale
  1263.        $halfSizeScaled = $sizeScaled / 2  
  1264.        
  1265.        $s.Shape.Width = $sizeScaled
  1266.        $s.Shape.Height = $sizeScaled
  1267.        
  1268.        $transform = New-Object System.Windows.Media.RotateTransform
  1269.        $transform.Angle = $s.Rotation
  1270.        $transform.CenterX = $halfSizeScaled  
  1271.        $transform.CenterY = $halfSizeScaled  
  1272.        $s.Shape.RenderTransform = $transform
  1273.        
  1274.        $nx = $s.X - $halfSizeScaled
  1275.        $ny = $s.Y - $halfSizeScaled
  1276.        
  1277.        $isValidX = -not ([double]::IsNaN($nx) -or [double]::IsInfinity($nx))
  1278.        $isValidY = -not ([double]::IsNaN($ny) -or [double]::IsInfinity($ny))
  1279.        
  1280.        if ($isValidX -and $isValidY) {      
  1281.            [System.Windows.Controls.Canvas]::SetLeft($s.Shape, $nx)
  1282.            [System.Windows.Controls.Canvas]::SetTop($s.Shape, $ny)
  1283.        }
  1284.    }
  1285. })
  1286.  
  1287. $fireTimer = New-Object System.Windows.Threading.DispatcherTimer
  1288. $fireTimer.Interval = [TimeSpan]::FromMilliseconds(300)
  1289. $fireTimer.Add_Tick({
  1290.    if ((Get-Random -Minimum 0 -Maximum 3) -eq 0) {
  1291.        $fx = Get-Random -Minimum 0 -Maximum 800
  1292.        $fy = Get-Random -Minimum 0 -Maximum 300
  1293.        New-Firework $fx $fy
  1294.    }
  1295. })
  1296.  
  1297.  
  1298. $stars = 1..14 | ForEach-Object { $window.FindName("s$_") }
  1299. $stars1 = $stars[1..7]
  1300. $stars2 = $stars[8..14]
  1301.  
  1302. $story1 = New-Object System.Windows.Media.Animation.Storyboard
  1303. $story2 = New-Object System.Windows.Media.Animation.Storyboard
  1304.  
  1305. foreach ($s in $stars1) {
  1306.    $ani = New-Object System.Windows.Media.Animation.DoubleAnimation
  1307.    $ani.From = 0
  1308.    $ani.To   = 1
  1309.    $blink=[double](Get-Random -Minimum 70 -Maximum 140)/100
  1310.    $ani.Duration= [System.TimeSpan]::FromSeconds($blink)
  1311.    $ani.AutoReverse = $true
  1312.    $ani.RepeatBehavior =[System.Windows.Media.Animation.RepeatBehavior]::Forever
  1313.    [System.Windows.Media.Animation.Storyboard]::SetTarget($ani, $s)
  1314.    [System.Windows.Media.Animation.Storyboard]::SetTargetProperty($ani,(New-Object System.Windows.PropertyPath "Opacity"))
  1315.    $story1.Children.Add($ani)
  1316. }
  1317.  
  1318. foreach ($s in $stars2) {
  1319.    $ani = New-Object System.Windows.Media.Animation.DoubleAnimation
  1320.    $ani.From = 0
  1321.    $ani.To   = 1
  1322.    $blink=[double](Get-Random -Minimum 80 -Maximum 150)/100
  1323.    $ani.BeginTime = [System.TimeSpan]::FromSeconds(0.5)
  1324.    $ani.Duration = [System.TimeSpan]::FromSeconds($blink)
  1325.    $ani.AutoReverse= $true
  1326.    $ani.RepeatBehavior = [System.Windows.Media.Animation.RepeatBehavior]::Forever
  1327.    [System.Windows.Media.Animation.Storyboard]::SetTarget($ani,$s)
  1328.    [System.Windows.Media.Animation.Storyboard]::SetTargetProperty($ani,(New-Object System.Windows.PropertyPath "Opacity"))
  1329.    $story2.Children.Add($ani)
  1330. }
  1331.  
  1332.  
  1333. $window.Add_Loaded({
  1334.    
  1335.     #Show-CmdIntroSimple
  1336.    $story1.Begin()
  1337.    $story2.Begin()
  1338. })
  1339.  
  1340.  
  1341. # if ($SkipIntro -ne 1) {
  1342.    # Show-CmdIntro
  1343.    
  1344. # }
  1345. # else
  1346. # {
  1347. #   $player1.Play()
  1348. # }
  1349.  
  1350. $window.Add_Closed({
  1351. #    $player1.Stop()
  1352. #    $player1.Close()
  1353.    $updateTimer.Stop()
  1354.    $fireTimer.Stop()
  1355.    $snowTimer.Stop()
  1356. })
  1357.  
  1358. $snowTimer.Start()
  1359. $updateTimer.Start()
  1360. $fireTimer.Start()
  1361.  
  1362. $window.ShowDialog() | Out-Null
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Jipadoc
    24 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Ravwoler
    1 day
    # CSS 0.45 KB | 0 0
    1. โญ Changelly Profit Exploit Documentation โญ
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=jzmlvmjsba
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment