hyperstellar 1.5.6__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. hyperstellar/__init__.py +299 -0
  2. hyperstellar/__init__.pyi +1019 -0
  3. hyperstellar/_native/linux-x64/shaders/axis.frag +8 -0
  4. hyperstellar/_native/linux-x64/shaders/axis.vert +13 -0
  5. hyperstellar/_native/linux-x64/shaders/fragShader.frag +27 -0
  6. hyperstellar/_native/linux-x64/shaders/geoShader.geom +69 -0
  7. hyperstellar/_native/linux-x64/shaders/math.comp +2177 -0
  8. hyperstellar/_native/linux-x64/shaders/paint.comp +1214 -0
  9. hyperstellar/_native/linux-x64/shaders/quad.frag +26 -0
  10. hyperstellar/_native/linux-x64/shaders/quad.geom +149 -0
  11. hyperstellar/_native/linux-x64/shaders/quad.vert +39 -0
  12. hyperstellar/_native/linux-x64/shaders/vertexShader.vert +13 -0
  13. hyperstellar/_native/linux-x64/stellar.so +0 -0
  14. hyperstellar/_native/windows-x64/shaders/axis.frag +8 -0
  15. hyperstellar/_native/windows-x64/shaders/axis.vert +13 -0
  16. hyperstellar/_native/windows-x64/shaders/fragShader.frag +27 -0
  17. hyperstellar/_native/windows-x64/shaders/geoShader.geom +69 -0
  18. hyperstellar/_native/windows-x64/shaders/math.comp +2177 -0
  19. hyperstellar/_native/windows-x64/shaders/paint.comp +1214 -0
  20. hyperstellar/_native/windows-x64/shaders/quad.frag +26 -0
  21. hyperstellar/_native/windows-x64/shaders/quad.geom +149 -0
  22. hyperstellar/_native/windows-x64/shaders/quad.vert +39 -0
  23. hyperstellar/_native/windows-x64/shaders/vertexShader.vert +13 -0
  24. hyperstellar/_native/windows-x64/stellar.pyd +0 -0
  25. hyperstellar/debug.py +169 -0
  26. hyperstellar/jit.py +2010 -0
  27. hyperstellar/jit_linter.py +3 -0
  28. hyperstellar/py.typed +0 -0
  29. hyperstellar/shader.py +1356 -0
  30. hyperstellar/typed.py +152 -0
  31. hyperstellar-1.5.6.dist-info/METADATA +470 -0
  32. hyperstellar-1.5.6.dist-info/RECORD +35 -0
  33. hyperstellar-1.5.6.dist-info/WHEEL +5 -0
  34. hyperstellar-1.5.6.dist-info/licenses/LICENSE +24 -0
  35. hyperstellar-1.5.6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,26 @@
1
+ #version 430 core
2
+
3
+ in vec2 fragTexCoord;
4
+ in vec4 fragColor;
5
+ in float fragSpeed;
6
+
7
+ out vec4 FragColor;
8
+
9
+ void main() {
10
+ // Circle if texcoord is non-zero (from circle emission)
11
+ bool isCircle = fragTexCoord != vec2(0.0);
12
+
13
+ if (isCircle) {
14
+ float dist = length(fragTexCoord);
15
+
16
+ // HARD EDGE: Discard everything outside the exact circle boundary
17
+ if (dist > 1.0) discard;
18
+
19
+ // No smoothstep - just use the original color with full opacity
20
+ FragColor = fragColor;
21
+
22
+ } else {
23
+ // Rectangle & polygon (texcoord = 0) - use color as-is
24
+ FragColor = fragColor;
25
+ }
26
+ }
@@ -0,0 +1,149 @@
1
+ #version 430 core
2
+
3
+ layout(points) in;
4
+ layout(triangle_strip, max_vertices = 64) out;
5
+
6
+ in vec2 vPosition[];
7
+ in vec2 vVelocity[];
8
+ in float vMass[];
9
+ in float vCharge[];
10
+ in int vVisualSkinType[];
11
+ in vec4 vVisualData[]; // x=rotation, y=angular_vel, z=width/radius, w=height/sides
12
+ in vec4 vColor[];
13
+
14
+ out vec2 fragTexCoord;
15
+ out vec4 fragColor;
16
+ out float fragSpeed;
17
+
18
+ uniform mat4 uProjection;
19
+ uniform mat4 uView;
20
+
21
+ const int SKIN_CIRCLE = 0;
22
+ const int SKIN_RECTANGLE = 1;
23
+ const int SKIN_POLYGON = 2;
24
+ const float PI = 3.14159265359;
25
+
26
+ void emitCircle(vec2 center, float radius, vec4 color, float speed) {
27
+ mat4 MVP = uProjection * uView;
28
+
29
+ // Bottom-left
30
+ gl_Position = MVP * vec4(center + vec2(-radius, -radius), 0.0, 1.0);
31
+ fragTexCoord = vec2(-1.0, -1.0);
32
+ fragColor = color;
33
+ fragSpeed = speed;
34
+ EmitVertex();
35
+
36
+ // Top-left
37
+ gl_Position = MVP * vec4(center + vec2(-radius, radius), 0.0, 1.0);
38
+ fragTexCoord = vec2(-1.0, 1.0);
39
+ fragColor = color;
40
+ fragSpeed = speed;
41
+ EmitVertex();
42
+
43
+ // Bottom-right
44
+ gl_Position = MVP * vec4(center + vec2(radius, -radius), 0.0, 1.0);
45
+ fragTexCoord = vec2(1.0, -1.0);
46
+ fragColor = color;
47
+ fragSpeed = speed;
48
+ EmitVertex();
49
+
50
+ // Top-right
51
+ gl_Position = MVP * vec4(center + vec2(radius, radius), 0.0, 1.0);
52
+ fragTexCoord = vec2(1.0, 1.0);
53
+ fragColor = color;
54
+ fragSpeed = speed;
55
+ EmitVertex();
56
+
57
+ EndPrimitive();
58
+ }
59
+
60
+ void emitRectangle(vec2 center, float width, float height, float rotation, vec4 color, float speed) {
61
+ mat4 MVP = uProjection * uView;
62
+
63
+ float cosR = cos(rotation);
64
+ float sinR = sin(rotation);
65
+ float hw = width * 0.5;
66
+ float hh = height * 0.5;
67
+
68
+ vec2 corners[4];
69
+ corners[0] = vec2(-hw, -hh);
70
+ corners[1] = vec2( hw, -hh);
71
+ corners[2] = vec2(-hw, hh);
72
+ corners[3] = vec2( hw, hh);
73
+
74
+ for (int i = 0; i < 4; i++) {
75
+ vec2 rotated = vec2(
76
+ corners[i].x * cosR - corners[i].y * sinR,
77
+ corners[i].x * sinR + corners[i].y * cosR
78
+ );
79
+ gl_Position = MVP * vec4(center + rotated, 0.0, 1.0);
80
+ fragTexCoord = vec2(0.0);
81
+ fragColor = color;
82
+ fragSpeed = speed;
83
+ EmitVertex();
84
+ }
85
+ EndPrimitive();
86
+ }
87
+
88
+ void emitPolygon(vec2 center, float radius, int numSides, float rotation, vec4 color, float speed) {
89
+ mat4 MVP = uProjection * uView;
90
+ numSides = clamp(numSides, 3, 20);
91
+
92
+ vec2 pts[21];
93
+ for (int i = 0; i < numSides; i++) {
94
+ float angle = rotation + (2.0 * PI * float(i) / float(numSides));
95
+ pts[i] = center + vec2(cos(angle), sin(angle)) * radius;
96
+ }
97
+
98
+ for (int i = 0; i < numSides; i++) {
99
+ gl_Position = MVP * vec4(pts[i], 0.0, 1.0);
100
+ fragColor = color;
101
+ fragSpeed = speed;
102
+ fragTexCoord = vec2(0.0);
103
+ EmitVertex();
104
+
105
+ gl_Position = MVP * vec4(center, 0.0, 1.0);
106
+ fragColor = color;
107
+ fragSpeed = speed;
108
+ fragTexCoord = vec2(0.0);
109
+ EmitVertex();
110
+ }
111
+
112
+ gl_Position = MVP * vec4(pts[0], 0.0, 1.0);
113
+ fragColor = color;
114
+ fragSpeed = speed;
115
+ fragTexCoord = vec2(0.0);
116
+ EmitVertex();
117
+
118
+ EndPrimitive();
119
+ }
120
+
121
+ void main() {
122
+ vec2 pos = vPosition[0];
123
+ vec2 vel = vVelocity[0];
124
+ float speed = length(vel);
125
+ int skinType = vVisualSkinType[0];
126
+
127
+ //LAYOUT: width/height in x/y, rotation/angular_vel in z/w
128
+ float param_x = vVisualData[0].x; // width or radius
129
+ float param_y = vVisualData[0].y; // height or numSides
130
+ float rotation = vVisualData[0].z; // ROTATION NOW IN Z
131
+ float angular_vel = vVisualData[0].w; // ANGULAR_VEL NOW IN W
132
+
133
+ vec4 color = vColor[0];
134
+
135
+ if (skinType == SKIN_CIRCLE) {
136
+ float radius = param_x;
137
+ emitCircle(pos, radius, color, speed);
138
+ }
139
+ else if (skinType == SKIN_RECTANGLE) {
140
+ float width = param_x;
141
+ float height = param_y;
142
+ emitRectangle(pos, width, height, rotation, color, speed);
143
+ }
144
+ else if (skinType == SKIN_POLYGON) {
145
+ float radius = param_x;
146
+ int numSides = int(param_y);
147
+ emitPolygon(pos, radius, numSides, rotation, color, speed);
148
+ }
149
+ }
@@ -0,0 +1,39 @@
1
+ #version 430 core
2
+
3
+ // These should match VAO setup from objects.cpp
4
+ layout(location = 0) in vec2 aPosition;
5
+ layout(location = 1) in vec2 aVelocity;
6
+ layout(location = 2) in float aMass;
7
+ layout(location = 3) in float aCharge;
8
+ layout(location = 4) in int aVisualSkinType;
9
+ layout(location = 5) in vec4 aVisualData;
10
+ layout(location = 6) in vec4 aColor;
11
+ layout(location = 7) in int aEquationID;
12
+
13
+ out vec2 vPosition;
14
+ out vec2 vVelocity;
15
+ out float vMass;
16
+ out float vCharge;
17
+ out int vVisualSkinType;
18
+ out vec4 vVisualData;
19
+ out vec4 vColor;
20
+ //Add rotation and angular velocity as separate outputs if needed
21
+ out float vRotation;
22
+ out float vAngularVelocity;
23
+
24
+ void main() {
25
+ vPosition = aPosition;
26
+ vVelocity = aVelocity;
27
+ vMass = aMass;
28
+ vCharge = aCharge;
29
+ vVisualSkinType = aVisualSkinType;
30
+ vVisualData = aVisualData;
31
+ vColor = aColor;
32
+
33
+ // Extract rotation and angular velocity from visualData
34
+ vRotation = aVisualData.x;
35
+ vAngularVelocity = aVisualData.y;
36
+
37
+ gl_Position = vec4(aPosition, 0.0, 1.0);
38
+ gl_PointSize = 10.0; // For point rendering fallback
39
+ }
@@ -0,0 +1,13 @@
1
+ #version 430 core
2
+ layout(location = 0) in vec2 basePos;
3
+ uniform vec2 chargePos = vec2(0.0, 0.0);
4
+ uniform mat4 projection;
5
+ out vec2 v_basePos;
6
+ out vec2 v_chargePos;
7
+ void main()
8
+ {
9
+ vec4 hi = projection * vec4(basePos, 0.0, 1.0);
10
+ gl_Position = vec4(basePos, 0.0, 1.0);
11
+ v_basePos = basePos;
12
+ v_chargePos = chargePos;
13
+ }
hyperstellar/debug.py ADDED
@@ -0,0 +1,169 @@
1
+ """
2
+ Debugging utilities for the JIT system.
3
+
4
+ Provides logging, shader source dumping, and rich error reporting with line context.
5
+ """
6
+
7
+ import sys
8
+ import difflib
9
+ from typing import Optional, List, Set, Tuple
10
+
11
+ # Global debug flag
12
+ _DEBUG_ENABLED: bool = False
13
+ _LOG_LEVEL: int = 0 # 0=error, 1=warn, 2=info, 3=debug
14
+
15
+
16
+ def enable_debug(flag: bool = True) -> None:
17
+ """Enable or disable debug output."""
18
+ global _DEBUG_ENABLED
19
+ _DEBUG_ENABLED = flag
20
+
21
+
22
+ def set_log_level(level: int) -> None:
23
+ """Set verbosity level (0=error, 1=warn, 2=info, 3=debug)."""
24
+ global _LOG_LEVEL
25
+ _LOG_LEVEL = level
26
+
27
+
28
+ def _log(level: int, msg: str) -> None:
29
+ if not _DEBUG_ENABLED or level > _LOG_LEVEL:
30
+ return
31
+ prefix = ["[ERROR]", "[WARN]", "[INFO]", "[DEBUG]"][level]
32
+ print(f"{prefix} {msg}", file=sys.stderr)
33
+
34
+
35
+ def error(msg: str) -> None:
36
+ """Log an error message."""
37
+ _log(0, msg)
38
+
39
+
40
+ def warn(msg: str) -> None:
41
+ """Log a warning message."""
42
+ _log(1, msg)
43
+
44
+
45
+ def info(msg: str) -> None:
46
+ """Log an info message."""
47
+ _log(2, msg)
48
+
49
+
50
+ def debug(msg: str) -> None:
51
+ """Log a debug message."""
52
+ _log(3, msg)
53
+
54
+
55
+ def log_shader(source: str, title: Optional[str] = None) -> None:
56
+ """Print the generated shader source to stderr."""
57
+ if not _DEBUG_ENABLED:
58
+ return
59
+ if title:
60
+ print(f"\n--- {title} ---", file=sys.stderr)
61
+ print(source, file=sys.stderr)
62
+ print("--- end shader ---\n", file=sys.stderr)
63
+
64
+
65
+ def trace_call(func_name: str, *args, **kwargs) -> None:
66
+ """Log a function call with its arguments (for debugging JIT internals)."""
67
+ if not _DEBUG_ENABLED:
68
+ return
69
+ args_str = ", ".join(repr(a) for a in args)
70
+ if kwargs:
71
+ kwargs_str = ", ".join(f"{k}={v!r}" for k, v in kwargs.items())
72
+ if args_str:
73
+ args_str += ", " + kwargs_str
74
+ else:
75
+ args_str = kwargs_str
76
+ debug(f"CALL {func_name}({args_str})")
77
+
78
+
79
+ # ----------------------------------------------------------------------------
80
+ # Rich error reporting with line context and suggestions
81
+ # ----------------------------------------------------------------------------
82
+
83
+ def _get_line_context(source: str, lineno: int, context_lines: int = 2) -> str:
84
+ """Return a few lines of source around the given line number."""
85
+ if lineno is None or not source:
86
+ return ""
87
+ lines = source.splitlines()
88
+ if lineno < 1 or lineno > len(lines):
89
+ return ""
90
+ start = max(0, lineno - context_lines - 1)
91
+ end = min(len(lines), lineno + context_lines)
92
+ context_lines_output = []
93
+ for i in range(start, end):
94
+ line_num = i + 1
95
+ marker = ">" if line_num == lineno else " "
96
+ context_lines_output.append(f"{line_num:4} {marker} {lines[i]}")
97
+ return "\n".join(context_lines_output)
98
+
99
+
100
+ def report_error(
101
+ msg: str,
102
+ source: str,
103
+ lineno: Optional[int] = None,
104
+ col_offset: Optional[int] = None,
105
+ suggestion: Optional[str] = None,
106
+ context_lines: int = 2,
107
+ ) -> None:
108
+ """
109
+ Print a formatted error message with source context and an optional suggestion.
110
+ Raises SyntaxError after printing.
111
+ """
112
+ full_msg = f"JIT Error: {msg}"
113
+ if suggestion:
114
+ full_msg += f"\nDid you mean: {suggestion}?"
115
+ if lineno is not None:
116
+ context = _get_line_context(source, lineno, context_lines)
117
+ if context:
118
+ full_msg += f"\n\nIn source:\n{context}"
119
+ error(full_msg)
120
+ raise SyntaxError(full_msg)
121
+
122
+
123
+ def report_warning(
124
+ msg: str,
125
+ source: str,
126
+ lineno: Optional[int] = None,
127
+ col_offset: Optional[int] = None,
128
+ suggestion: Optional[str] = None,
129
+ context_lines: int = 2,
130
+ ) -> None:
131
+ """Print a formatted warning message with source context."""
132
+ full_msg = f"JIT Warning: {msg}"
133
+ if suggestion:
134
+ full_msg += f"\nDid you mean: {suggestion}?"
135
+ if lineno is not None:
136
+ context = _get_line_context(source, lineno, context_lines)
137
+ if context:
138
+ full_msg += f"\n\nIn source:\n{context}"
139
+ warn(full_msg)
140
+
141
+
142
+ def get_close_matches(word: str, possibilities: Set[str], n: int = 3, cutoff: float = 0.6) -> List[str]:
143
+ """
144
+ Return a list of close matches from a set of possibilities.
145
+ Uses difflib.get_close_matches internally.
146
+ """
147
+ return difflib.get_close_matches(word, list(possibilities), n, cutoff)
148
+
149
+
150
+ def format_error_summary(errors: List[Tuple[str, Optional[int], Optional[int], Optional[str]]],
151
+ source: str) -> str:
152
+ """
153
+ Format a list of errors (msg, lineno, col_offset, suggestion) into a single
154
+ human-readable string with source context.
155
+ """
156
+ if not errors:
157
+ return ""
158
+ lines = []
159
+ for msg, lineno, col, suggestion in errors:
160
+ line_info = f" at line {lineno}" if lineno is not None else ""
161
+ full_msg = f"{msg}{line_info}"
162
+ if suggestion:
163
+ full_msg += f"\nDid you mean: {suggestion}?"
164
+ if lineno is not None:
165
+ context = _get_line_context(source, lineno, 1)
166
+ if context:
167
+ full_msg += f"\n{context}"
168
+ lines.append(full_msg)
169
+ return "\n\n".join(lines)