Advertisement
MuratYildirimoglu

Drawing sinusoidal wave in Powershell

May 12th, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. 0..100 | foreach {
  2. $value=[int](30*[math]::sin($_/10))
  3. if ($value -gt 0) {
  4. $wprint=” “*70+”*”*$value
  5. write-host $wprint}
  6. else {
  7. $wprint=” “*(70-(-1*$value))+”*”*($value*-1)
  8. write-host $wprint
  9. }
  10. }
  11.  
  12. The above script draws a sinusoid wave on the text screen and it is in portrait mode.
  13.  
  14. The following code draws a sinusoid wave on the current graphical screen using the mouse cursor:
  15.  
  16. Add-Type -AssemblyName System.Windows.Forms
  17. Add-Type -AssemblyName System.Drawing
  18. 0..900 | foreach {
  19. $value=[int](50*[math]::sin($_/20))
  20. if ($value -gt 0) {
  21. [int]$location=300+$value }
  22. else {
  23. [int]$location=300-($value*-1)
  24. }
  25. $Position = [System.Drawing.Point]::new(100+$_,$location)
  26. [System.Windows.Forms.Cursor]::Position = $Position
  27. for($i=1; $i -le 10000; $i++) {}
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement