generate-art.ps1 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. Add-Type -AssemblyName System.Drawing
  2. $out = Join-Path $PSScriptRoot '..\assets\resources\sprites'
  3. New-Item -ItemType Directory -Force $out | Out-Null
  4. function Color($hex, $alpha = 255) {
  5. $hex = $hex.TrimStart('#')
  6. [System.Drawing.Color]::FromArgb($alpha, [Convert]::ToInt32($hex.Substring(0,2),16), [Convert]::ToInt32($hex.Substring(2,2),16), [Convert]::ToInt32($hex.Substring(4,2),16))
  7. }
  8. function Save-Png($name, $w, $h, [scriptblock]$draw) {
  9. $bmp = New-Object System.Drawing.Bitmap $w, $h, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
  10. $g = [System.Drawing.Graphics]::FromImage($bmp)
  11. $g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
  12. $g.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::NearestNeighbor
  13. & $draw $g $w $h
  14. $path = Join-Path $out "$name.png"
  15. $bmp.Save($path, [System.Drawing.Imaging.ImageFormat]::Png)
  16. $g.Dispose()
  17. $bmp.Dispose()
  18. }
  19. function Brush($hex, $alpha = 255) { New-Object System.Drawing.SolidBrush (Color $hex $alpha) }
  20. function PenC($hex, $width = 1, $alpha = 255) { New-Object System.Drawing.Pen (Color $hex $alpha), $width }
  21. Save-Png 'bg_jungle' 2048 540 {
  22. param($g,$w,$h)
  23. $rect = New-Object System.Drawing.Rectangle 0,0,$w,$h
  24. $bg = New-Object System.Drawing.Drawing2D.LinearGradientBrush $rect,(Color '#101738'),(Color '#123a32'),90
  25. $g.FillRectangle($bg,$rect)
  26. for ($i=0; $i -lt 85; $i++) {
  27. $x = ($i * 73) % $w
  28. $top = 40 + (($i * 29) % 170)
  29. $height = 260 + (($i * 47) % 220)
  30. $green = if ($i % 2 -eq 0) { '#1f7352' } else { '#285e68' }
  31. $g.FillEllipse((Brush $green 110), $x-55, $top, 120, $height)
  32. $g.FillRectangle((Brush '#0b292b' 180), $x-7, $top+80, 14, $height)
  33. }
  34. for ($i=0; $i -lt 42; $i++) {
  35. $x = ($i * 149) % $w
  36. $y = 110 + (($i * 61) % 280)
  37. $g.FillEllipse((Brush '#73f6ff' 70), $x, $y, 8, 8)
  38. $g.FillEllipse((Brush '#ff4fc3' 45), $x+22, $y+12, 5, 5)
  39. }
  40. for ($i=0; $i -lt 9; $i++) {
  41. $x = $i * 245 + 80
  42. $g.FillPolygon((Brush '#273a5d' 190), @(
  43. [System.Drawing.PointF]::new($x,245),
  44. [System.Drawing.PointF]::new($x+170,225),
  45. [System.Drawing.PointF]::new($x+230,330),
  46. [System.Drawing.PointF]::new($x+40,348)
  47. ))
  48. $g.DrawLine((PenC '#69f8ff' 2 140), $x+32, 270, $x+178, 256)
  49. }
  50. }
  51. Save-Png 'ground_strip' 512 96 {
  52. param($g,$w,$h)
  53. $g.Clear((Color '#162d35'))
  54. $g.FillRectangle((Brush '#2a6645'),0,0,$w,30)
  55. $g.FillRectangle((Brush '#173730'),0,30,$w,66)
  56. for ($i=0; $i -lt 34; $i++) {
  57. $x = $i * 16
  58. $g.FillPolygon((Brush '#6ee08d' 180), @(
  59. [System.Drawing.PointF]::new($x,24),
  60. [System.Drawing.PointF]::new($x+8,4),
  61. [System.Drawing.PointF]::new($x+15,24)
  62. ))
  63. }
  64. for ($i=0; $i -lt 28; $i++) {
  65. $x = ($i * 37) % $w
  66. $y = 42 + (($i * 19) % 42)
  67. $g.FillEllipse((Brush '#49f5ff' 70),$x,$y,8,5)
  68. }
  69. }
  70. Save-Png 'player' 96 112 {
  71. param($g,$w,$h)
  72. $g.Clear([System.Drawing.Color]::Transparent)
  73. $g.FillEllipse((Brush '#49f5ff' 42), 17, 14, 62, 82)
  74. $g.FillRectangle((Brush '#26384a'), 35, 39, 31, 38)
  75. $g.FillRectangle((Brush '#46d9ff'), 39, 32, 23, 19)
  76. $g.FillRectangle((Brush '#121923'), 42, 35, 17, 7)
  77. $g.FillRectangle((Brush '#f7d16a'), 50, 53, 31, 10)
  78. $g.FillRectangle((Brush '#596c76'), 72, 55, 20, 6)
  79. $g.FillRectangle((Brush '#29384a'), 29, 73, 13, 28)
  80. $g.FillRectangle((Brush '#29384a'), 57, 73, 13, 28)
  81. $g.FillRectangle((Brush '#f052a8'), 31, 42, 7, 31)
  82. $g.DrawRectangle((PenC '#9dfbff' 3), 35, 39, 31, 38)
  83. }
  84. Save-Png 'enemy_spore' 80 80 {
  85. param($g,$w,$h)
  86. $g.Clear([System.Drawing.Color]::Transparent)
  87. $g.FillEllipse((Brush '#f05098' 88), 6, 12, 68, 56)
  88. $g.FillEllipse((Brush '#7330a4'), 13, 18, 54, 44)
  89. $g.FillEllipse((Brush '#a8ff5c'), 23, 27, 11, 11)
  90. $g.FillEllipse((Brush '#a8ff5c'), 48, 29, 9, 9)
  91. $g.DrawArc((PenC '#ff8fd6' 4), 12, 16, 55, 44, 200, 140)
  92. $g.FillPolygon((Brush '#341b4d'), @([System.Drawing.PointF]::new(23,59),[System.Drawing.PointF]::new(33,76),[System.Drawing.PointF]::new(42,59)))
  93. $g.FillPolygon((Brush '#341b4d'), @([System.Drawing.PointF]::new(46,59),[System.Drawing.PointF]::new(58,74),[System.Drawing.PointF]::new(62,58)))
  94. }
  95. Save-Png 'enemy_wing' 92 78 {
  96. param($g,$w,$h)
  97. $g.Clear([System.Drawing.Color]::Transparent)
  98. $g.FillPolygon((Brush '#50f4ff' 105), @([System.Drawing.PointF]::new(9,26),[System.Drawing.PointF]::new(38,9),[System.Drawing.PointF]::new(38,49)))
  99. $g.FillPolygon((Brush '#50f4ff' 105), @([System.Drawing.PointF]::new(84,26),[System.Drawing.PointF]::new(54,9),[System.Drawing.PointF]::new(54,49)))
  100. $g.FillEllipse((Brush '#7a33c8'), 27, 18, 38, 42)
  101. $g.FillEllipse((Brush '#ff65bd'), 39, 25, 15, 16)
  102. $g.DrawEllipse((PenC '#dffcff' 2 180), 27, 18, 38, 42)
  103. }
  104. Save-Png 'enemy_turret' 96 76 {
  105. param($g,$w,$h)
  106. $g.Clear([System.Drawing.Color]::Transparent)
  107. $g.FillRectangle((Brush '#243e51'), 18, 33, 58, 28)
  108. $g.FillPie((Brush '#3f6473'), 24, 10, 48, 48, 180, 180)
  109. $g.FillRectangle((Brush '#92fbff'), 8, 28, 44, 10)
  110. $g.FillRectangle((Brush '#ffcc4d'), 2, 29, 9, 8)
  111. $g.DrawRectangle((PenC '#73f6ff' 3 170), 18, 33, 58, 28)
  112. }
  113. Save-Png 'boss_star_hive' 240 240 {
  114. param($g,$w,$h)
  115. $g.Clear([System.Drawing.Color]::Transparent)
  116. $g.FillEllipse((Brush '#34f1ff' 45), 18, 14, 204, 204)
  117. $g.FillEllipse((Brush '#3a1c64'), 43, 38, 154, 155)
  118. $g.FillEllipse((Brush '#ff4fae'), 74, 62, 92, 88)
  119. $g.FillEllipse((Brush '#f9ff90'), 102, 91, 34, 32)
  120. $g.DrawEllipse((PenC '#75faff' 6 190), 43, 38, 154, 155)
  121. for ($i=0; $i -lt 8; $i++) {
  122. $a = $i * [Math]::PI / 4
  123. $cx = 120 + [Math]::Cos($a) * 95
  124. $cy = 116 + [Math]::Sin($a) * 92
  125. $g.FillEllipse((Brush '#8c42e6'), [float]($cx-15), [float]($cy-15), 30, 30)
  126. $g.DrawLine((PenC '#ff86d0' 5 170), 120, 116, [float]$cx, [float]$cy)
  127. }
  128. $g.FillPolygon((Brush '#14182b'), @(
  129. [System.Drawing.PointF]::new(90,132),
  130. [System.Drawing.PointF]::new(120,154),
  131. [System.Drawing.PointF]::new(151,132),
  132. [System.Drawing.PointF]::new(120,142)
  133. ))
  134. }
  135. Save-Png 'alien_crystal' 72 90 {
  136. param($g,$w,$h)
  137. $g.Clear([System.Drawing.Color]::Transparent)
  138. $g.FillPolygon((Brush '#53f3ff' 135), @(
  139. [System.Drawing.PointF]::new(36,2),
  140. [System.Drawing.PointF]::new(65,38),
  141. [System.Drawing.PointF]::new(47,86),
  142. [System.Drawing.PointF]::new(16,86),
  143. [System.Drawing.PointF]::new(7,39)
  144. ))
  145. $g.FillPolygon((Brush '#ff4ec0' 100), @([System.Drawing.PointF]::new(36,2),[System.Drawing.PointF]::new(47,86),[System.Drawing.PointF]::new(31,72)))
  146. $g.DrawPolygon((PenC '#dffcff' 3 160), @(
  147. [System.Drawing.PointF]::new(36,2),
  148. [System.Drawing.PointF]::new(65,38),
  149. [System.Drawing.PointF]::new(47,86),
  150. [System.Drawing.PointF]::new(16,86),
  151. [System.Drawing.PointF]::new(7,39)
  152. ))
  153. }
  154. Save-Png 'bullet_rifle' 36 20 {
  155. param($g,$w,$h)
  156. $g.Clear([System.Drawing.Color]::Transparent)
  157. $g.FillEllipse((Brush '#fff39a'), 2, 6, 28, 8)
  158. $g.FillEllipse((Brush '#ffb84d'), 22, 5, 10, 10)
  159. }
  160. Save-Png 'bullet_flame' 48 28 {
  161. param($g,$w,$h)
  162. $g.Clear([System.Drawing.Color]::Transparent)
  163. $g.FillEllipse((Brush '#ff4c38' 190), 5, 4, 36, 20)
  164. $g.FillEllipse((Brush '#ffd45c' 220), 18, 8, 18, 12)
  165. }
  166. Save-Png 'bullet_rail' 96 24 {
  167. param($g,$w,$h)
  168. $g.Clear([System.Drawing.Color]::Transparent)
  169. $g.FillRectangle((Brush '#dfffff' 220), 4, 9, 82, 6)
  170. $g.FillEllipse((Brush '#68f7ff' 120), 0, 3, 92, 18)
  171. }
  172. Save-Png 'bullet_acid' 32 32 {
  173. param($g,$w,$h)
  174. $g.Clear([System.Drawing.Color]::Transparent)
  175. $g.FillEllipse((Brush '#bf5cff' 190), 5, 5, 22, 22)
  176. $g.FillEllipse((Brush '#ebff78' 210), 12, 9, 7, 7)
  177. }
  178. Save-Png 'ui_button' 96 84 {
  179. param($g,$w,$h)
  180. $g.Clear([System.Drawing.Color]::Transparent)
  181. $g.FillEllipse((Brush '#0b1726' 175), 4, 6, 88, 72)
  182. $g.DrawEllipse((PenC '#69f8ff' 3 180), 4, 6, 88, 72)
  183. $g.FillEllipse((Brush '#ff4fc3' 58), 18, 16, 58, 46)
  184. }
  185. Write-Host "Generated art assets in $out"