-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorginal.ps1
More file actions
57 lines (52 loc) · 2.19 KB
/
Copy pathorginal.ps1
File metadata and controls
57 lines (52 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<#
.SYNOPSIS
A 3D Spinning Earth (Globe) rendered in the PowerShell console.
.DESCRIPTION
This script uses mathematical projections and ASCII shading to create a 3D-effect
rotating sphere. It calculates the Z-depth and surface normals to apply
dynamic lighting as the "Earth" rotates.
#>
# Configuration
$width = [Console]::WindowWidth - 1
$height = [Console]::WindowHeight - 1
$radius = [Math]::Min($width / 4, $height / 2) - 3
$angle = 0
$ascii = " .':,;!~+*abdeghjmnpqw#B8&WM@$" # Extended professional shading palette
$stars = " . * . ' " # Starfield characters
Write-Host "Initializing 3D Studio Rendering Engine..." -ForegroundColor Cyan
Start-Sleep -Seconds 1
Clear-Host
try {
while ($true) {
$sb = New-Object System.Text.StringBuilder
for ($y = -$radius; $y -le $radius; $y++) {
for ($x = -$radius * 2; $x -le $radius * 2; $x++) {
# Circle equation: x^2 + y^2 = r^2 (adjusted for console aspect ratio)
$dist = [Math]::Sqrt($x * $x / 4 + $y * $y)
if ($dist -le $radius) {
# Calculate 3D normal vector components
$z = [Math]::Sqrt($radius * $radius - ($x * $x / 4) - ($y * $y))
$nz = $z / $radius
$nx = ($x / 2) / $radius
# Calculate luminance based on a rotating light source
$lightX = [Math]::Sin($angle)
$lightZ = [Math]::Cos($angle)
$luminance = ($nx * $lightX + $nz * $lightZ)
$idx = [int](([Math]::Max(0, $luminance)) * ($ascii.Length - 1))
[void]$sb.Append($ascii[$idx])
} else {
# Render Starfield
$starIdx = ($x + $y + [int]($angle * 10)) % $stars.Length
[void]$sb.Append($stars[[Math]::Abs($starIdx)])
}
}
[void]$sb.Append("`n")
}
[Console]::SetCursorPosition(0, 0)
[Console]::Write($sb.ToString())
$angle += 0.1
Start-Sleep -Milliseconds 10
}
} catch {
Write-Host "`nAnimation stopped." -ForegroundColor Gray
}