simple2d-3d 0.2.6__tar.gz → 0.2.8__tar.gz
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.
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/PKG-INFO +1 -1
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/pyproject.toml +1 -1
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/simple2d_3d/render.py +31 -9
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/simple2d_3d.egg-info/PKG-INFO +1 -1
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/LICENSE +0 -0
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/README.md +0 -0
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/setup.cfg +0 -0
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/simple2d_3d/__init__.py +0 -0
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/simple2d_3d/colors.py +0 -0
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/simple2d_3d/gui.py +0 -0
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/simple2d_3d/setup.py +0 -0
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/simple2d_3d.egg-info/SOURCES.txt +0 -0
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/simple2d_3d.egg-info/dependency_links.txt +0 -0
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/simple2d_3d.egg-info/requires.txt +0 -0
- {simple2d_3d-0.2.6 → simple2d_3d-0.2.8}/simple2d_3d.egg-info/top_level.txt +0 -0
|
@@ -458,28 +458,50 @@ class ParticleSystem:
|
|
|
458
458
|
for p in self.particles:
|
|
459
459
|
alpha = max(0, min(255, int(p.life * 255)))
|
|
460
460
|
|
|
461
|
-
# --- 1.
|
|
461
|
+
# --- 1. Create a circular texture if it doesn't exist yet ---
|
|
462
462
|
if p.size not in self.cached_textures:
|
|
463
463
|
diameter = p.size * 2
|
|
464
|
+
radius = p.size
|
|
464
465
|
|
|
465
|
-
# Using 0 for masks lets SDL2 automatically assign a standard, correct 32-bit RGBA layout
|
|
466
466
|
surface = sdl2.SDL_CreateRGBSurface(0, diameter, diameter, 32, 0, 0, 0, 0)
|
|
467
|
-
|
|
468
|
-
# Safety check: If SDL failed to allocate the surface memory, skip this frame
|
|
469
467
|
if not surface:
|
|
470
468
|
continue
|
|
471
469
|
|
|
472
|
-
#
|
|
473
|
-
|
|
470
|
+
# We need to manually color pixels to make a smooth circle shape
|
|
471
|
+
# Lock the surface so we can write directly to raw pixel memory safely
|
|
472
|
+
sdl2.SDL_LockSurface(surface)
|
|
473
|
+
|
|
474
|
+
# Convert the raw pixels array pointer to a usable ctypes format
|
|
475
|
+
pixels_ptr = ctypes.cast(surface.contents.pixels, ctypes.POINTER(ctypes.c_uint32))
|
|
476
|
+
pitch = surface.contents.pitch // 4 # 4 bytes per pixel (32-bit)
|
|
477
|
+
|
|
478
|
+
# Get the pixel format mapping for pure white
|
|
479
|
+
white_pixel = sdl2.SDL_MapRGBA(surface.contents.format, 255, 255, 255, 255)
|
|
480
|
+
transparent_pixel = sdl2.SDL_MapRGBA(surface.contents.format, 0, 0, 0, 0)
|
|
474
481
|
|
|
475
|
-
#
|
|
482
|
+
# Loop through every single coordinate inside our square bounding box
|
|
483
|
+
for y in range(diameter):
|
|
484
|
+
for x in range(diameter):
|
|
485
|
+
# Calculate distance from the center of the square using Pythagorean theorem
|
|
486
|
+
dx = x - radius
|
|
487
|
+
dy = y - radius
|
|
488
|
+
if (dx * dx + dy * dy) <= (radius * radius):
|
|
489
|
+
# Inside the circle radius? Color it solid white!
|
|
490
|
+
pixels_ptr[y * pitch + x] = white_pixel
|
|
491
|
+
else:
|
|
492
|
+
# Outside the circle? Keep it transparent
|
|
493
|
+
pixels_ptr[y * pitch + x] = transparent_pixel
|
|
494
|
+
|
|
495
|
+
sdl2.SDL_UnlockSurface(surface)
|
|
496
|
+
|
|
497
|
+
# Upload our brand-new round circle template straight to GPU memory
|
|
476
498
|
texture = sdl2.SDL_CreateTextureFromSurface(renderer, surface)
|
|
477
499
|
sdl2.SDL_FreeSurface(surface)
|
|
478
500
|
|
|
479
501
|
if texture:
|
|
480
502
|
self.cached_textures[p.size] = texture
|
|
481
503
|
else:
|
|
482
|
-
continue
|
|
504
|
+
continue
|
|
483
505
|
|
|
484
506
|
# --- 2. Pull the texture and apply modifiers ---
|
|
485
507
|
tex = self.cached_textures.get(p.size)
|
|
@@ -497,4 +519,4 @@ class ParticleSystem:
|
|
|
497
519
|
self.dst_rect.h = int(p.size * 2)
|
|
498
520
|
|
|
499
521
|
# --- 4. Render it ---
|
|
500
|
-
sdl2.SDL_RenderCopy(renderer, tex, None, ctypes.byref(
|
|
522
|
+
sdl2.SDL_RenderCopy(renderer, tex, None, ctypes.byref(dst_rect))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|