Skip to content

New approach#2

Merged
RMANOV merged 8 commits into
rust-rewritefrom
new-approach
Jan 17, 2026
Merged

New approach#2
RMANOV merged 8 commits into
rust-rewritefrom
new-approach

Conversation

@RMANOV
Copy link
Copy Markdown
Owner

@RMANOV RMANOV commented Jan 17, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 17, 2026 07:53
@RMANOV RMANOV merged commit 78dca92 into rust-rewrite Jan 17, 2026
2 of 3 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a new screensaver implementation featuring 18 distinct visualizations (mandalas and 3D geometric shapes) using pure Python with Tkinter. The screensaver cycles through visualizations every 7 minutes with smooth animations, a star field background, and a clock display.

Changes:

  • Added comprehensive screensaver with 18 mathematical/geometric visualizations
  • Implemented batch file launcher for Windows
  • Uses only standard Python libraries (tkinter, math, random, datetime)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 14 comments.

File Description
05_screensaver.py Main screensaver implementation with 18 visualization classes, star field background, and GUI management
05_screensaver.bat Windows batch launcher to start the screensaver using pythonw

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread 05_screensaver.py
Comment on lines +747 to +758
for v in self.spike_verts:
x, y, z = self._rotate(v)
d = 6.0
s = d / (d - z)
proj_spikes.append((cx + x * s * size, cy - y * s * size, z, s))

# Project base vertices
proj_base = []
for v in self.verts:
x, y, z = self._rotate(v)
d = 6.0
s = d / (d - z)
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'd' is used for multiple purposes in this method: first for viewing distance (line 750), then reused for scale calculation (line 758 for base vertices). This shadowing of variable names within the same scope reduces code clarity and could lead to bugs if the code is modified. Consider using distinct variable names like 'view_distance' and 'scale'.

Suggested change
for v in self.spike_verts:
x, y, z = self._rotate(v)
d = 6.0
s = d / (d - z)
proj_spikes.append((cx + x * s * size, cy - y * s * size, z, s))
# Project base vertices
proj_base = []
for v in self.verts:
x, y, z = self._rotate(v)
d = 6.0
s = d / (d - z)
view_distance = 6.0
for v in self.spike_verts:
x, y, z = self._rotate(v)
s = view_distance / (view_distance - z)
proj_spikes.append((cx + x * s * size, cy - y * s * size, z, s))
# Project base vertices
proj_base = []
for v in self.verts:
x, y, z = self._rotate(v)
s = view_distance / (view_distance - z)

Copilot uses AI. Check for mistakes.
Comment thread 05_screensaver.py
# MAIN SCREENSAVER
# =============================================================================
class Screensaver:
"""Multi-visualization screensaver - 18 Mandalas & 3D shapes"""
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring says "Multi-visualization screensaver - 18 Mandalas & 3D shapes" but earlier the module docstring says "11 Mandala & 3D Visualizations". These should be consistent. The actual count is 18 visualizations, so line 4 should be updated to match line 1671.

Copilot uses AI. Check for mistakes.
Comment thread 05_screensaver.py
for i in range(len(self.verts)):
for j in range(i + 1, len(self.verts)):
d = sum((self.verts[i][k] - self.verts[j][k])**2 for k in range(4))
if 3.5 < d < 4.5: # Edge length ~2
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The edge length threshold uses a hardcoded range 3.5 < d < 4.5 with the comment "Edge length ~2". However, if the squared distance d should be around 4 (since 2² = 4), the comment should clarify this is checking squared distance, not linear distance. The comment "Edge length ~2" is misleading.

Suggested change
if 3.5 < d < 4.5: # Edge length ~2
if 3.5 < d < 4.5: # Squared distance ~4 (edge length ~2)

Copilot uses AI. Check for mistakes.
Comment thread 05_screensaver.py
Comment on lines +549 to +555
# Edges: connect vertices at distance 1
self.edges_idx = []
for i in range(24):
for j in range(i + 1, 24):
d = sum((self.verts[i][k] - self.verts[j][k])**2 for k in range(4))
if abs(d - 1.0) < 0.01:
self.edges_idx.append((i, j))
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "Edges: connect vertices at distance 1" but the code checks 'abs(d - 1.0) < 0.01' where d is the squared distance (sum of squared differences). For vertices at distance 1, the squared distance should be 1, so the code is correct, but the comment should clarify this checks squared distance to avoid confusion.

Copilot uses AI. Check for mistakes.
Comment thread 05_screensaver.py
Comment on lines +952 to +958
# Build edges - connect nearby nodes
self.edges_idx = []
for i in range(self.n_nodes):
for j in range(i + 1, self.n_nodes):
d = sum((self.nodes[i][k] - self.nodes[j][k])**2 for k in ['x', 'y', 'z'])
if d < 0.8:
self.edges_idx.append((i, j))
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the CosmicWeb class, the comment says "Build edges - connect nearby nodes" but the threshold value 0.8 appears to be a squared distance (since d is computed as sum of squares). The comment should clarify this is checking squared distance less than 0.8, which means actual distance less than approximately 0.894.

Copilot uses AI. Check for mistakes.
Comment thread 05_screensaver.py
self.angle_xy = self.angle_xz = self.angle_yz = 0.0
self.hue_offset = 0.0
phi = (1 + math.sqrt(5)) / 2
ip = 1 / phi
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'ip' (inverse phi) is used inconsistently. In line 323 it's defined as '1 / phi', but in line 851 it's defined as '1 / phi' again and then in line 867 it's used as 'ip * ip' when it could be clearer. Consider using consistent naming like 'inverse_phi' throughout the codebase.

Copilot uses AI. Check for mistakes.
Comment thread 05_screensaver.py
self.hue_offset = 0.0
phi = (1 + math.sqrt(5)) / 2
ip = 1 / phi
p2 = phi * phi
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name 'p2' for 'phi * phi' (phi squared) is not descriptive. Consider using 'phi_squared' or 'phi2' to make the intent clearer.

Copilot uses AI. Check for mistakes.
Comment thread 05_screensaver.bat
@@ -0,0 +1,4 @@
@echo off
cd /d "%~dp0"
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The batch file uses 'pythonw' to launch the script in a windowless mode. However, there is no verification that Python is installed or in the PATH. If Python is not available, this will fail silently. Consider adding error handling or checking for Python availability.

Suggested change
cd /d "%~dp0"
cd /d "%~dp0"
rem Check if pythonw is available in PATH
where pythonw >nul 2>&1
if errorlevel 1 (
echo pythonw.exe was not found. Please ensure Python is installed and pythonw is in your PATH.
pause
exit /b 1
)

Copilot uses AI. Check for mistakes.
Comment thread 05_screensaver.py
Comment on lines +862 to +867
# Permutations of (±φ², ±1, ±φ⁻², 0)
for i in range(4):
for s1 in [-1, 1]:
for s2 in [-1, 1]:
for s3 in [-1, 1]:
v = [s1 * p2, s2 * 1, s3 * ip * ip, 0]
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "Permutations of (±φ², ±1, ±φ⁻², 0)" but the actual implementation in line 867 uses 'ip * ip' which is φ⁻². The comment uses superscript notation φ⁻² which is mathematically correct but the code should clarify that 'ip' is 1/φ. This could be confusing for future maintainers.

Copilot uses AI. Check for mistakes.
Comment thread 05_screensaver.py
Comment on lines +868 to +870
v = v[-i:] + v[:-i] # Rotate
if tuple(v) not in self.verts:
self.verts.append(tuple(v))
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'v' is reused and mutated in place which can be confusing. After creating the list in line 867, the code rotates it in line 868 with slicing notation, but then checks if the tuple exists in self.verts. Since 'v' was created as a list and then rotated as a list, converting to tuple for comparison could be made clearer by using a different variable name for the rotated version.

Suggested change
v = v[-i:] + v[:-i] # Rotate
if tuple(v) not in self.verts:
self.verts.append(tuple(v))
rotated_v = tuple(v[-i:] + v[:-i]) # Rotate and convert to tuple
if rotated_v not in self.verts:
self.verts.append(rotated_v)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants