spore-engine 0.1.0__py3-none-any.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.
- demo.py +500 -0
- demos/__init__.py +272 -0
- demos/scene_3d.py +223 -0
- demos/scene_abyssal_bloom.py +515 -0
- demos/scene_anim.py +90 -0
- demos/scene_anim_path.py +94 -0
- demos/scene_astral_cathedral.py +103 -0
- demos/scene_aurora.py +57 -0
- demos/scene_aurora_lagoon.py +444 -0
- demos/scene_aurora_palace.py +106 -0
- demos/scene_aurora_storm.py +115 -0
- demos/scene_autumn_forest.py +730 -0
- demos/scene_bioluminescence.py +78 -0
- demos/scene_biome_demo.py +25 -0
- demos/scene_black_hole.py +134 -0
- demos/scene_braille_current.py +149 -0
- demos/scene_celestial_temple.py +123 -0
- demos/scene_cellular.py +66 -0
- demos/scene_code_shader.py +121 -0
- demos/scene_constellation.py +131 -0
- demos/scene_cosmic_tunnel.py +126 -0
- demos/scene_crystal_cluster.py +133 -0
- demos/scene_crystal_nebula.py +133 -0
- demos/scene_dna.py +56 -0
- demos/scene_double_pendulum.py +115 -0
- demos/scene_dungeon.py +44 -0
- demos/scene_eclipse.py +97 -0
- demos/scene_ecs_lifecycle.py +281 -0
- demos/scene_ecs_swarm.py +286 -0
- demos/scene_erosion.py +51 -0
- demos/scene_ethereal_ruins.py +225 -0
- demos/scene_field_demo.py +59 -0
- demos/scene_fireflies.py +118 -0
- demos/scene_flocking.py +135 -0
- demos/scene_flowfield.py +97 -0
- demos/scene_forest_fire.py +89 -0
- demos/scene_fractals.py +74 -0
- demos/scene_fx.py +126 -0
- demos/scene_galaxy.py +84 -0
- demos/scene_geometric_flower.py +97 -0
- demos/scene_glyph_art.py +157 -0
- demos/scene_god_rays.py +269 -0
- demos/scene_golden_city.py +108 -0
- demos/scene_gravity.py +128 -0
- demos/scene_horizon.py +395 -0
- demos/scene_hypercube.py +119 -0
- demos/scene_infinite_temple.py +152 -0
- demos/scene_isometric.py +46 -0
- demos/scene_kaleidoscope.py +41 -0
- demos/scene_landscape.py +102 -0
- demos/scene_lava.py +80 -0
- demos/scene_lightning.py +77 -0
- demos/scene_lorenz.py +89 -0
- demos/scene_media_player.py +119 -0
- demos/scene_meteor.py +80 -0
- demos/scene_misc.py +106 -0
- demos/scene_neon_cathedral.py +122 -0
- demos/scene_neon_city.py +150 -0
- demos/scene_neon_grid.py +54 -0
- demos/scene_new_features.py +97 -0
- demos/scene_new_features2.py +377 -0
- demos/scene_particles.py +84 -0
- demos/scene_phantom_galaxy.py +78 -0
- demos/scene_phoenix.py +148 -0
- demos/scene_phosphor.py +171 -0
- demos/scene_photo_ascii.py +46 -0
- demos/scene_physics_enhanced.py +131 -0
- demos/scene_physics_rigid.py +103 -0
- demos/scene_platformer.py +174 -0
- demos/scene_powder.py +74 -0
- demos/scene_prism_raytracer.py +72 -0
- demos/scene_ragdoll.py +300 -0
- demos/scene_raytracer_alien.py +37 -0
- demos/scene_raytracer_crystal.py +40 -0
- demos/scene_raytracer_infinity.py +37 -0
- demos/scene_raytracer_jewel.py +46 -0
- demos/scene_raytracer_moonlit.py +43 -0
- demos/scene_raytracer_nebula.py +42 -0
- demos/scene_raytracer_photo.py +36 -0
- demos/scene_raytracer_reflections.py +48 -0
- demos/scene_raytracer_system.py +36 -0
- demos/scene_raytracer_toybox.py +36 -0
- demos/scene_ripples.py +39 -0
- demos/scene_scenery.py +84 -0
- demos/scene_screenfx.py +84 -0
- demos/scene_sdf_csg.py +41 -0
- demos/scene_sdf_dreamscape.py +75 -0
- demos/scene_sdf_glow.py +45 -0
- demos/scene_shader_symphony.py +126 -0
- demos/scene_shaders.py +96 -0
- demos/scene_shadows.py +81 -0
- demos/scene_sierpinski.py +122 -0
- demos/scene_sim.py +65 -0
- demos/scene_solar_flare.py +57 -0
- demos/scene_spline_demo.py +55 -0
- demos/scene_stained_glass.py +68 -0
- demos/scene_starry_night.py +57 -0
- demos/scene_synthwave.py +126 -0
- demos/scene_terminal_app.py +284 -0
- demos/scene_terrain_flyover.py +71 -0
- demos/scene_tilemap.py +108 -0
- demos/scene_timeline.py +86 -0
- demos/scene_tui.py +199 -0
- demos/scene_tunnel.py +35 -0
- demos/scene_ui.py +82 -0
- demos/scene_underwater.py +105 -0
- demos/scene_video_player.py +76 -0
- demos/scene_voxel_world.py +59 -0
- demos/scene_walkers.py +317 -0
- demos/scene_worley.py +34 -0
- easy_demo.py +81 -0
- shader_sandbox.py +26 -0
- spore_engine/__init__.py +170 -0
- spore_engine/__version__.py +4 -0
- spore_engine/anim/__init__.py +3 -0
- spore_engine/anim/anim.py +401 -0
- spore_engine/anim/ik.py +198 -0
- spore_engine/anim/timeline.py +191 -0
- spore_engine/cli.py +267 -0
- spore_engine/core/__init__.py +150 -0
- spore_engine/core/_accel.py +49 -0
- spore_engine/core/_optional.py +40 -0
- spore_engine/core/assets.py +324 -0
- spore_engine/core/camera.py +94 -0
- spore_engine/core/canvas.py +692 -0
- spore_engine/core/color.py +282 -0
- spore_engine/core/draw.py +542 -0
- spore_engine/core/ecs.py +197 -0
- spore_engine/core/geom.py +247 -0
- spore_engine/core/glyphs.py +62 -0
- spore_engine/core/input.py +702 -0
- spore_engine/core/reload.py +282 -0
- spore_engine/core/scene.py +145 -0
- spore_engine/core/scene_file.py +375 -0
- spore_engine/core/sprite.py +55 -0
- spore_engine/core/state.py +184 -0
- spore_engine/core/term.py +541 -0
- spore_engine/core/util.py +170 -0
- spore_engine/easy/__init__.py +17 -0
- spore_engine/easy/anim.py +164 -0
- spore_engine/easy/app.py +747 -0
- spore_engine/easy/sprite.py +297 -0
- spore_engine/easy/systems.py +908 -0
- spore_engine/easy/util.py +15 -0
- spore_engine/easy/widgets.py +101 -0
- spore_engine/fx/__init__.py +15 -0
- spore_engine/fx/effects.py +376 -0
- spore_engine/fx/field.py +117 -0
- spore_engine/fx/lightfield.py +621 -0
- spore_engine/fx/lighting.py +163 -0
- spore_engine/fx/postfx.py +268 -0
- spore_engine/fx/screenfx.py +157 -0
- spore_engine/fx/shader_lab.py +430 -0
- spore_engine/fx/shaderlab.py +345 -0
- spore_engine/fx/shaders.py +528 -0
- spore_engine/fx/textfx.py +143 -0
- spore_engine/fx/transitions.py +159 -0
- spore_engine/fx/volumetric.py +195 -0
- spore_engine/gen/__init__.py +13 -0
- spore_engine/gen/biome_terrain.py +105 -0
- spore_engine/gen/delaunay.py +173 -0
- spore_engine/gen/dungeon.py +515 -0
- spore_engine/gen/erosion.py +202 -0
- spore_engine/gen/fractals.py +171 -0
- spore_engine/gen/lsystem.py +87 -0
- spore_engine/gen/marching_cubes.py +394 -0
- spore_engine/gen/maze.py +144 -0
- spore_engine/gen/pathfinding.py +140 -0
- spore_engine/gen/scenery.py +292 -0
- spore_engine/gen/splines.py +98 -0
- spore_engine/gen/terrain.py +152 -0
- spore_engine/gen/wfc.py +202 -0
- spore_engine/media/__init__.py +5 -0
- spore_engine/media/_pillow_compat.py +24 -0
- spore_engine/media/ansi_io.py +175 -0
- spore_engine/media/converter.py +264 -0
- spore_engine/media/export.py +378 -0
- spore_engine/media/ffmpeg.py +225 -0
- spore_engine/media/glyphart.py +326 -0
- spore_engine/media/imaging.py +110 -0
- spore_engine/media/img3d.py +201 -0
- spore_engine/media/video.py +287 -0
- spore_engine/render3d/__init__.py +7 -0
- spore_engine/render3d/engine3d.py +250 -0
- spore_engine/render3d/isometric.py +91 -0
- spore_engine/render3d/model_loader.py +127 -0
- spore_engine/render3d/raytracer.py +386 -0
- spore_engine/render3d/sdf.py +231 -0
- spore_engine/render3d/voxel.py +100 -0
- spore_engine/sim/__init__.py +9 -0
- spore_engine/sim/cellular.py +277 -0
- spore_engine/sim/fluid.py +261 -0
- spore_engine/sim/noise.py +248 -0
- spore_engine/sim/physics.py +988 -0
- spore_engine/sim/physics3d.py +194 -0
- spore_engine/sim/powder.py +447 -0
- spore_engine/sim/softbody.py +238 -0
- spore_engine/sim/steering.py +228 -0
- spore_engine/ui/__init__.py +4 -0
- spore_engine/ui/font.py +113 -0
- spore_engine/ui/tilemap.py +194 -0
- spore_engine/ui/toolkit.py +476 -0
- spore_engine/ui/widgets.py +819 -0
- spore_engine-0.1.0.dist-info/METADATA +342 -0
- spore_engine-0.1.0.dist-info/RECORD +209 -0
- spore_engine-0.1.0.dist-info/WHEEL +5 -0
- spore_engine-0.1.0.dist-info/entry_points.txt +3 -0
- spore_engine-0.1.0.dist-info/licenses/LICENSE +121 -0
- spore_engine-0.1.0.dist-info/top_level.txt +5 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import math, random
|
|
2
|
+
from spore_engine import *
|
|
3
|
+
from spore_engine.core.color import *
|
|
4
|
+
|
|
5
|
+
_BIO = None
|
|
6
|
+
|
|
7
|
+
def scene_bioluminescence(c, hr, t, pt, dt):
|
|
8
|
+
global _BIO
|
|
9
|
+
w, h = c.w, c.h
|
|
10
|
+
|
|
11
|
+
if _BIO is None:
|
|
12
|
+
jellies = []
|
|
13
|
+
for _ in range(4):
|
|
14
|
+
jellies.append({
|
|
15
|
+
'x': random.uniform(0, w), 'y': random.uniform(h*0.15, h*0.6),
|
|
16
|
+
'vx': random.uniform(-0.3, 0.3), 'vy': random.uniform(-0.15, 0.15),
|
|
17
|
+
'hue': random.choice([0.55, 0.6, 0.65, 0.7, 0.75, 0.8]),
|
|
18
|
+
'phase': random.uniform(0, 2*math.pi),
|
|
19
|
+
'size': random.uniform(2, 4),
|
|
20
|
+
})
|
|
21
|
+
plankton = []
|
|
22
|
+
for _ in range(40):
|
|
23
|
+
plankton.append({
|
|
24
|
+
'x': random.uniform(0, w), 'y': random.uniform(0, h),
|
|
25
|
+
'hue': random.uniform(0.2, 0.8),
|
|
26
|
+
'vx': random.uniform(-0.2, 0.2), 'vy': random.uniform(-0.1, -0.3),
|
|
27
|
+
'bright': random.uniform(0.3, 0.8),
|
|
28
|
+
})
|
|
29
|
+
_BIO = {'jellies': jellies, 'plankton': plankton}
|
|
30
|
+
|
|
31
|
+
s = _BIO
|
|
32
|
+
|
|
33
|
+
for y in range(h):
|
|
34
|
+
ty = y / h
|
|
35
|
+
col = Color(int(2+ty*6), int(0+ty*2), int(5+ty*15))
|
|
36
|
+
for x in range(w):
|
|
37
|
+
c.set_pixel(x, y, ' ', bg=col, z=-100)
|
|
38
|
+
|
|
39
|
+
for p in s['plankton']:
|
|
40
|
+
p['x'] += p['vx'] * dt * 8
|
|
41
|
+
p['y'] += p['vy'] * dt * 8
|
|
42
|
+
if p['y'] < -2: p['y'] = h+2; p['x'] = random.uniform(2, w-2)
|
|
43
|
+
if p['x'] < -2: p['x'] = w+2
|
|
44
|
+
if p['x'] > w+2: p['x'] = -2
|
|
45
|
+
px, py = int(p['x']), int(p['y'])
|
|
46
|
+
if 0 <= px < w and 0 <= py < h:
|
|
47
|
+
pulse = 0.5 + 0.5 * math.sin(t * 0.5 + p['hue'] * 10)
|
|
48
|
+
b = p['bright'] * pulse
|
|
49
|
+
col = Color.from_hsv(p['hue'], 0.7, b*0.4)
|
|
50
|
+
c.set_pixel(px, py, '·', col, z=5)
|
|
51
|
+
|
|
52
|
+
for j in s['jellies']:
|
|
53
|
+
j['x'] += j['vx'] * dt * 12
|
|
54
|
+
j['y'] += j['vy'] * dt * 10
|
|
55
|
+
j['vy'] += math.sin(t*0.5+j['phase'])*dt*0.5
|
|
56
|
+
j['x'] = max(2, min(w-3, j['x']))
|
|
57
|
+
j['y'] = max(2, min(h-3, j['y']))
|
|
58
|
+
px, py_ = int(j['x']), int(j['y'])
|
|
59
|
+
sz = int(j['size'])
|
|
60
|
+
hue = j['hue']
|
|
61
|
+
pulse = 0.6 + 0.4 * math.sin(t * 1.5 + j['phase'])
|
|
62
|
+
|
|
63
|
+
for dy in range(-sz*2, sz+1):
|
|
64
|
+
for dx in range(-sz, sz+1):
|
|
65
|
+
d = math.hypot(dx, dy)
|
|
66
|
+
if d <= sz * 1.5:
|
|
67
|
+
pp, pyp = px+dx, py_+dy
|
|
68
|
+
if 0 <= pp < w and 0 <= pyp < h:
|
|
69
|
+
bell = d <= sz
|
|
70
|
+
if bell:
|
|
71
|
+
a = 1 - d/sz
|
|
72
|
+
col = Color.from_hsv(hue, 0.8, 0.2+a*0.6*pulse)
|
|
73
|
+
c.set_pixel(pp, pyp, '█' if a > 0.6 else '▒', col, z=10)
|
|
74
|
+
elif dy > 0:
|
|
75
|
+
tent = (d - sz) / (sz*0.5)
|
|
76
|
+
if tent < 1:
|
|
77
|
+
col = Color.from_hsv(hue, 0.9, 0.1+(1-tent)*0.3*pulse)
|
|
78
|
+
c.set_pixel(pp, pyp, '~' if dy % 3 == 0 else '·', col, z=9)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import math
|
|
2
|
+
from spore_engine import *
|
|
3
|
+
from spore_engine.core.color import *
|
|
4
|
+
from spore_engine.gen.biome_terrain import BiomeMap
|
|
5
|
+
|
|
6
|
+
_BD = None
|
|
7
|
+
|
|
8
|
+
def scene_biome_demo(c, hr, t, pt, dt):
|
|
9
|
+
global _BD
|
|
10
|
+
w, h = c.w, c.h
|
|
11
|
+
if _BD is None:
|
|
12
|
+
bm = BiomeMap(w, h, seed=int(t * 10) % 1000)
|
|
13
|
+
_BD = {'bm': bm, 'last_seed': 0}
|
|
14
|
+
|
|
15
|
+
s = _BD
|
|
16
|
+
new_seed = int(t * 0.15) % 1000
|
|
17
|
+
if new_seed != s.get('last_seed', -1):
|
|
18
|
+
s['bm'] = BiomeMap(w, h, seed=new_seed)
|
|
19
|
+
s['last_seed'] = new_seed
|
|
20
|
+
|
|
21
|
+
bm = s['bm']
|
|
22
|
+
bm.render(c)
|
|
23
|
+
|
|
24
|
+
c.draw_text(2, 0, "Multi-Biome Terrain", WHITE, z=100)
|
|
25
|
+
c.draw_text(2, h - 1, "Regenerates every ~7s", DIM, z=100)
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import math, random
|
|
2
|
+
from spore_engine import *
|
|
3
|
+
from spore_engine.core.color import *
|
|
4
|
+
|
|
5
|
+
_BH = None
|
|
6
|
+
|
|
7
|
+
def scene_black_hole(c, hr, t, pt, dt):
|
|
8
|
+
global _BH
|
|
9
|
+
w, h = c.w, c.h
|
|
10
|
+
cx, cy = w / 2, h * 0.42
|
|
11
|
+
|
|
12
|
+
if _BH is None:
|
|
13
|
+
disc_parts = []
|
|
14
|
+
for _ in range(200):
|
|
15
|
+
dist = random.uniform(3, min(w, h) * 0.38)
|
|
16
|
+
angle = random.uniform(0, 2 * math.pi)
|
|
17
|
+
disc_parts.append({
|
|
18
|
+
'dist': dist, 'angle': angle,
|
|
19
|
+
'hue_shift': random.uniform(0, 1),
|
|
20
|
+
'speed': 0.3 + 2.0 / max(1, dist * 0.5),
|
|
21
|
+
})
|
|
22
|
+
bg_stars = []
|
|
23
|
+
for _ in range(150):
|
|
24
|
+
sx = random.uniform(0, w)
|
|
25
|
+
sy = random.uniform(0, h * 0.85)
|
|
26
|
+
twinkle = random.uniform(0, 2 * math.pi)
|
|
27
|
+
bg_stars.append({'x': sx, 'y': sy, 'phase': twinkle, 'size': random.uniform(0.3, 1.0)})
|
|
28
|
+
jet_dirs = []
|
|
29
|
+
for _ in range(60):
|
|
30
|
+
jet_dirs.append({'ang': random.uniform(-0.15, 0.15), 'speed': random.uniform(0.5, 2.0), 'phase': random.uniform(0, 2*math.pi)})
|
|
31
|
+
_BH = {'disc': disc_parts, 'stars': bg_stars, 'jets': jet_dirs}
|
|
32
|
+
|
|
33
|
+
s = _BH
|
|
34
|
+
|
|
35
|
+
for y in range(h):
|
|
36
|
+
ty = y / h
|
|
37
|
+
col = Color(0, int(ty * 4), int(ty * 6 + 2))
|
|
38
|
+
for x in range(w):
|
|
39
|
+
c.set_pixel(x, y, ' ', bg=col, z=-100)
|
|
40
|
+
|
|
41
|
+
for star in s['stars']:
|
|
42
|
+
px, py = int(star['x']), int(star['y'])
|
|
43
|
+
dx = px - cx
|
|
44
|
+
dy = py - cy
|
|
45
|
+
dist = math.hypot(dx, dy)
|
|
46
|
+
angle = math.atan2(dy, dx)
|
|
47
|
+
|
|
48
|
+
if dist > 5:
|
|
49
|
+
lensing = 1 + 8 / max(1, dist * 0.8)
|
|
50
|
+
lens_dist = dist ** 0.85
|
|
51
|
+
src_angle = angle + math.sin(angle * 2 - t * 0.1) * 2 / max(1, dist)
|
|
52
|
+
src_x = cx + math.cos(src_angle) * lens_dist
|
|
53
|
+
src_y = cy + math.sin(src_angle) * lens_dist
|
|
54
|
+
if 0 <= src_x < w and 0 <= src_y < h:
|
|
55
|
+
tw = 0.5 + 0.5 * math.sin(t * 1.2 + star['phase'])
|
|
56
|
+
mag = 1 + 4 / max(1, dist * 0.6)
|
|
57
|
+
brightness = min(1.0, tw * star['size'] * mag * 0.5)
|
|
58
|
+
if brightness > 0.1:
|
|
59
|
+
col = Color(
|
|
60
|
+
int(180 * brightness) + int(40 * brightness * math.sin(t + px * 0.1)),
|
|
61
|
+
int(200 * brightness),
|
|
62
|
+
int(255 * brightness))
|
|
63
|
+
ch = '·' if brightness < 0.3 else ('✦' if brightness < 0.6 else '★')
|
|
64
|
+
c.set_pixel(px, py, ch, col, z=3)
|
|
65
|
+
|
|
66
|
+
ev_horizon = min(w, h) * 0.045
|
|
67
|
+
for dy in range(-int(ev_horizon * 1.5), int(ev_horizon * 1.5)):
|
|
68
|
+
for dx in range(-int(ev_horizon * 1.5), int(ev_horizon * 1.5)):
|
|
69
|
+
d = math.hypot(dx, dy)
|
|
70
|
+
px, py2 = int(cx + dx), int(cy + dy)
|
|
71
|
+
if 0 <= px < w and 0 <= py2 < h:
|
|
72
|
+
if d <= ev_horizon:
|
|
73
|
+
c.set_pixel(px, py2, ' ', bg=Color(0, 0, 0), z=50)
|
|
74
|
+
elif d <= ev_horizon * 1.4:
|
|
75
|
+
glow = 1 - (d - ev_horizon) / (ev_horizon * 0.4)
|
|
76
|
+
ph = 0.5 + 0.5 * math.sin(t * 2 + dx * 0.5 + dy * 0.5)
|
|
77
|
+
col = Color(int(60 * glow * ph), int(40 * glow * ph), int(100 * glow * ph))
|
|
78
|
+
c.set_pixel(px, py2, '·', col, z=49)
|
|
79
|
+
|
|
80
|
+
for part in s['disc']:
|
|
81
|
+
part['angle'] += part['speed'] * dt * 2.0
|
|
82
|
+
if abs(part['dist'] - 4) < 1:
|
|
83
|
+
part['angle'] += dt * 3.0
|
|
84
|
+
dist = part['dist']
|
|
85
|
+
angle = part['angle']
|
|
86
|
+
x = cx + dist * math.cos(angle)
|
|
87
|
+
y = cy + dist * math.sin(angle) * 0.35
|
|
88
|
+
px, py2 = int(x), int(y)
|
|
89
|
+
if 0 <= px < w and 0 <= py2 < h:
|
|
90
|
+
vel_dir = -math.sin(angle), math.cos(angle) * 0.35
|
|
91
|
+
doppler = 0.7 + 0.3 * math.cos(angle - math.atan2(vel_dir[1], vel_dir[0]))
|
|
92
|
+
inner_glow = 1 - (dist - 3) / max(1, min(w, h) * 0.38 - 3)
|
|
93
|
+
brightness = min(1.0, inner_glow * doppler)
|
|
94
|
+
if brightness > 0.05:
|
|
95
|
+
hue = (0.02 + inner_glow * 0.08 + part['hue_shift'] * 0.03 + t * 0.005) % 1.0
|
|
96
|
+
sat = 0.6 + inner_glow * 0.4
|
|
97
|
+
col = Color.from_hsv(hue, sat, min(1.0, brightness * 1.2))
|
|
98
|
+
ch = '░' if brightness < 0.3 else ('▒' if brightness < 0.5 else ('▓' if brightness < 0.7 else '█'))
|
|
99
|
+
c.set_pixel(px, py2, ch, col, z=20)
|
|
100
|
+
|
|
101
|
+
for j in s['jets']:
|
|
102
|
+
j_angle = j['ang'] + math.sin(t * 0.3 + j['phase']) * 0.05
|
|
103
|
+
jet_speed = j['speed'] * (1 + 0.3 * math.sin(t * 0.5 + j['phase'] * 2))
|
|
104
|
+
for dist in range(1, int(min(w, h) * 0.35)):
|
|
105
|
+
r = dist * 0.015
|
|
106
|
+
nx = cx + math.cos(-math.pi / 2 + j_angle) * dist
|
|
107
|
+
ny = cy + math.sin(-math.pi / 2 + j_angle) * dist
|
|
108
|
+
for spread in [-1, 0, 1]:
|
|
109
|
+
sdx = nx + spread * r * dist * 0.05
|
|
110
|
+
sdy = ny + spread * r * dist * 0.05
|
|
111
|
+
px, py2 = int(sdx), int(sdy)
|
|
112
|
+
if 0 <= px < w and 0 <= py2 < h:
|
|
113
|
+
pulse = 0.5 + 0.5 * math.sin(t * 1.5 - dist * 0.1 + j['phase'])
|
|
114
|
+
bright = max(0, (1 - dist / (min(w, h) * 0.35)) * pulse * 0.6)
|
|
115
|
+
if bright > 0.05:
|
|
116
|
+
hue = (0.65 + dist * 0.005 + t * 0.01) % 1.0
|
|
117
|
+
col = Color.from_hsv(hue, 0.8, bright)
|
|
118
|
+
c.set_pixel(px, py2, '·' if bright < 0.2 else ('░' if bright < 0.4 else '▒'), col, z=25)
|
|
119
|
+
|
|
120
|
+
for dist in range(1, int(min(w, h) * 0.35)):
|
|
121
|
+
r = dist * 0.015
|
|
122
|
+
nx = cx + math.cos(math.pi / 2 + j_angle) * dist
|
|
123
|
+
ny = cy + math.sin(math.pi / 2 + j_angle) * dist
|
|
124
|
+
for spread in [-1, 0, 1]:
|
|
125
|
+
sdx = nx + spread * r * dist * 0.05
|
|
126
|
+
sdy = ny + spread * r * dist * 0.05
|
|
127
|
+
px, py2 = int(sdx), int(sdy)
|
|
128
|
+
if 0 <= px < w and 0 <= py2 < h:
|
|
129
|
+
pulse = 0.5 + 0.5 * math.sin(t * 1.5 - dist * 0.1 + j['phase'])
|
|
130
|
+
bright = max(0, (1 - dist / (min(w, h) * 0.35)) * pulse * 0.6)
|
|
131
|
+
if bright > 0.05:
|
|
132
|
+
hue = (0.65 + dist * 0.005 + t * 0.01) % 1.0
|
|
133
|
+
col = Color.from_hsv(hue, 0.8, bright)
|
|
134
|
+
c.set_pixel(px, py2, '·' if bright < 0.2 else ('░' if bright < 0.4 else '▒'), col, z=25)
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""Braille Current - a flow field on the engine's densest surface.
|
|
2
|
+
|
|
3
|
+
Braille only pays off for *continuous* imagery - a flow field, a gradient, a
|
|
4
|
+
photo - where per-cell glyphs force a staircase edge. The image is composited in
|
|
5
|
+
linear light and quantized to dots at the end, so filament cores sum and roll
|
|
6
|
+
off through ``tonemap`` instead of clipping, and the dots are ordered-dithered
|
|
7
|
+
so eight binary dots carry a tonal ramp.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import math
|
|
11
|
+
|
|
12
|
+
import numpy as np
|
|
13
|
+
|
|
14
|
+
from spore_engine import (Canvas, Color, LinearCanvas, PerlinNoise,
|
|
15
|
+
scene_state, to_braille)
|
|
16
|
+
|
|
17
|
+
TAU = math.tau
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _field(nx, ny, t, pn):
|
|
21
|
+
"""A slowly-turning flow field, and the scalar it is worth drawing.
|
|
22
|
+
|
|
23
|
+
Three fbm octaves, with the whole frame advected along a direction that
|
|
24
|
+
itself rotates, so the filaments stretch and shear over time instead of
|
|
25
|
+
merely sliding past. Uses the noise class's own grid sampler, which is
|
|
26
|
+
vectorised - a per-pixel ``noise2`` call would cost ~12k Python calls a
|
|
27
|
+
frame.
|
|
28
|
+
|
|
29
|
+
A rotating *offset* rather than a rotated sampling frame: the grid sampler
|
|
30
|
+
takes an origin, not a basis, and the shear that results reads the same on
|
|
31
|
+
screen without a second resample per frame.
|
|
32
|
+
"""
|
|
33
|
+
ang = 0.55 * math.sin(t * 0.11) + 0.18 * t
|
|
34
|
+
ca, sa = math.cos(ang), math.sin(ang)
|
|
35
|
+
ox, oy = ca * t * 7.0, -sa * t * 5.0
|
|
36
|
+
# One 3-octave call rather than two 2-octave ones: the sampler pays a fixed
|
|
37
|
+
# cost per call, so octaves are the cheap axis. And 1/55 is the difference
|
|
38
|
+
# between "flow" and "stripes" - a coarser field is nearly linear across the
|
|
39
|
+
# frame, so its level sets are parallel lines rather than filaments.
|
|
40
|
+
return pn.fbm2d_grid(nx, ny, scale=1.0 / 55.0, ox=ox, oy=oy,
|
|
41
|
+
octaves=3).astype(np.float32)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _filaments(frame, nx, ny, t, pn):
|
|
45
|
+
"""Additive streaks that follow the field, packed into a float buffer.
|
|
46
|
+
|
|
47
|
+
``frame`` is the raw ``(h, w, 3)`` array, so light is summed with ``+=`` and
|
|
48
|
+
is free to exceed 255 - that is the entire point of the surface.
|
|
49
|
+
"""
|
|
50
|
+
field = _field(nx, ny, t, pn)
|
|
51
|
+
|
|
52
|
+
# Direction of steepest ascent of the field, used as the streak direction.
|
|
53
|
+
gy, gx = np.gradient(field)
|
|
54
|
+
speed = np.hypot(gx, gy)
|
|
55
|
+
norm = np.maximum(speed, 1e-5)
|
|
56
|
+
ux, uy = gx / norm, gy / norm
|
|
57
|
+
|
|
58
|
+
# Band count is the other half of the look: too many and the ridges are
|
|
59
|
+
# narrower than a sub-cell, so the dither averages them into speckle.
|
|
60
|
+
ridge = np.abs((field * 3.4 + t * 0.30) % 1.0 - 0.5) * 2.0
|
|
61
|
+
line = np.clip(1.0 - ridge * 2.0, 0.0, 1.0) ** 1.3
|
|
62
|
+
line *= np.clip(speed * 3.0, 0.0, 1.0)
|
|
63
|
+
|
|
64
|
+
# Cyan rising, amber falling, so direction is legible from hue alone.
|
|
65
|
+
warm = np.clip(-uy, 0.0, 1.0)[..., None]
|
|
66
|
+
cool = np.clip(uy, 0.0, 1.0)[..., None]
|
|
67
|
+
col = (np.array([255.0, 150.0, 60.0]) * warm
|
|
68
|
+
+ np.array([70.0, 205.0, 255.0]) * cool)
|
|
69
|
+
frame += (line[..., None] * col) * 120.0
|
|
70
|
+
frame += (line[..., None] * np.array([255.0, 240.0, 220.0])) * 20.0
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _backdrop(frame, nx, ny):
|
|
74
|
+
"""A dim vertical wash, so the empty regions are not simply black."""
|
|
75
|
+
pos = np.linspace(0.0, 1.0, ny, dtype=np.float32)[:, None, None]
|
|
76
|
+
deep = np.array([2.0, 4.0, 11.0], np.float32)
|
|
77
|
+
top = np.array([7.0, 17.0, 34.0], np.float32)
|
|
78
|
+
frame += deep + (top - deep) * (1.0 - pos)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _sparks(frame, nx, ny, t, st):
|
|
82
|
+
"""A few bright additive motes, to show highlights roll off."""
|
|
83
|
+
k = st.get('sparks', None, lambda: [
|
|
84
|
+
(float((i * 0.618033988749895) % 1.0),
|
|
85
|
+
float((i * 0.7548776662466927) % 1.0),
|
|
86
|
+
1.4 + (i % 5) * 0.9,
|
|
87
|
+
0.31 + (i % 7) * 0.043)
|
|
88
|
+
for i in range(14)])
|
|
89
|
+
for i, (fx, fy, ph, sp) in enumerate(k):
|
|
90
|
+
px = (fx * nx + t * 13.0 * sp) % max(1, nx)
|
|
91
|
+
py = (fy * ny - t * 7.0 * sp) % max(1, ny)
|
|
92
|
+
twinkle = 0.5 + 0.5 * math.sin(t * sp * 6.0 + ph * 9.0)
|
|
93
|
+
if twinkle < 0.30:
|
|
94
|
+
continue
|
|
95
|
+
y0, y1 = max(0, int(py) - 3), min(ny, int(py) + 4)
|
|
96
|
+
x0, x1 = max(0, int(px) - 3), min(nx, int(px) + 4)
|
|
97
|
+
if y1 <= y0 or x1 <= x0:
|
|
98
|
+
continue
|
|
99
|
+
yy = np.arange(y0, y1, dtype=np.float32)[:, None] - py
|
|
100
|
+
xx = np.arange(x0, x1, dtype=np.float32)[None, :] - px
|
|
101
|
+
fall = np.exp(-(xx * xx + yy * yy) * 0.16)
|
|
102
|
+
amp = 120.0 * twinkle ** 3
|
|
103
|
+
frame[y0:y1, x0:x1] += (fall * amp)[..., None] * np.array(
|
|
104
|
+
[255.0, 226.0, 170.0], np.float32)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _grade(lc, t):
|
|
108
|
+
"""Tonemap, bloom, vignette - the same chain the other float scenes use."""
|
|
109
|
+
lc.tonemap(knee=150.0, white=255.0)
|
|
110
|
+
lc.bloom(threshold=26.0, span=74.0, radii=(1, 3), weights=(0.80, 0.42),
|
|
111
|
+
tint=(0.62, 0.88, 1.0), gain=44.0, source_tint=True)
|
|
112
|
+
lc.vignette(gain=0.30, exponent=1.5, radius=0.78)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _hud(c, t, st):
|
|
116
|
+
c.draw_text(2, 0, '~ Braille Current ~',
|
|
117
|
+
Color.from_hsv(0.52 + 0.04 * math.sin(t * 0.06), 0.5, 1.0), z=100)
|
|
118
|
+
c.draw_text(2, c.h - 1, '8 dots per cell | ordered dither | linear light',
|
|
119
|
+
Color(60, 88, 118), z=100)
|
|
120
|
+
stats = c.render_stats
|
|
121
|
+
if stats is None:
|
|
122
|
+
return
|
|
123
|
+
fps = st.get('fps')
|
|
124
|
+
rate = f'{fps:5.0f} fps' if fps else ' -- fps'
|
|
125
|
+
note = 'full redraw' if stats['full'] else f'{stats["cells"]} cells'
|
|
126
|
+
c.draw_text_at(3, 0, f'{rate} - {note} - {stats["bytes"] / 1024:.1f} KiB/f',
|
|
127
|
+
Color(44, 62, 84), z=100)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def scene_braille_current(canvas: Canvas, hires_canvas, time: float,
|
|
131
|
+
particle_system=None, dt: float = 0.0):
|
|
132
|
+
"""Braille Current - a flow field on the engine's densest surface."""
|
|
133
|
+
w, h = canvas.width, canvas.height
|
|
134
|
+
st = scene_state('braille_current')
|
|
135
|
+
pn = st.get('noise', None, lambda: PerlinNoise(0xB7A11))
|
|
136
|
+
|
|
137
|
+
if w < 8 or h < 4:
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
# The float buffer is exactly braille resolution, so the fold never scales.
|
|
141
|
+
nx, ny = w * 2, h * 4
|
|
142
|
+
lc = LinearCanvas(nx, ny)
|
|
143
|
+
_backdrop(lc.data, nx, ny)
|
|
144
|
+
_filaments(lc.data, nx, ny, time, pn)
|
|
145
|
+
_sparks(lc.data, nx, ny, time, st)
|
|
146
|
+
_grade(lc, time)
|
|
147
|
+
|
|
148
|
+
to_braille(lc, canvas, gamma=0.85, ink=250.0)
|
|
149
|
+
_hud(canvas, time, st)
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import math, random
|
|
2
|
+
from spore_engine import *
|
|
3
|
+
from spore_engine.core.color import *
|
|
4
|
+
|
|
5
|
+
_CT = None
|
|
6
|
+
|
|
7
|
+
def scene_celestial_temple(c, hr, t, pt, dt):
|
|
8
|
+
global _CT
|
|
9
|
+
w, h = c.w, c.h
|
|
10
|
+
|
|
11
|
+
if _CT is None:
|
|
12
|
+
clouds = []
|
|
13
|
+
for _ in range(15):
|
|
14
|
+
clouds.append({
|
|
15
|
+
'x': random.uniform(-w*0.2, w*1.2), 'y': random.uniform(h*0.05, h*0.25),
|
|
16
|
+
'w': random.uniform(8, 20), 'vx': random.uniform(0.2, 0.8),
|
|
17
|
+
'phase': random.uniform(0, 2*math.pi),
|
|
18
|
+
'hue': random.uniform(0.0, 0.08),
|
|
19
|
+
})
|
|
20
|
+
floating_particles = []
|
|
21
|
+
for _ in range(25):
|
|
22
|
+
floating_particles.append({
|
|
23
|
+
'x': random.uniform(0, w), 'y': random.uniform(0, h),
|
|
24
|
+
'vx': random.uniform(-0.2, 0.2), 'vy': random.uniform(-0.3, -0.1),
|
|
25
|
+
'phase': random.uniform(0, 2*math.pi),
|
|
26
|
+
})
|
|
27
|
+
_CT = {'clouds': clouds, 'particles': floating_particles}
|
|
28
|
+
|
|
29
|
+
s = _CT
|
|
30
|
+
|
|
31
|
+
for y in range(h):
|
|
32
|
+
ty = y / h
|
|
33
|
+
if ty < 0.6:
|
|
34
|
+
hue = 0.08 - ty * 0.08
|
|
35
|
+
sat = 0.2 + ty * 0.3
|
|
36
|
+
bright = 0.05 + 0.45 * (1 - ty)
|
|
37
|
+
else:
|
|
38
|
+
t2 = (ty - 0.6) / 0.4
|
|
39
|
+
hue = 0.04 + t2 * 0.03
|
|
40
|
+
sat = 0.3 + t2 * 0.2
|
|
41
|
+
bright = 0.2 * (1 - t2 * 0.5)
|
|
42
|
+
col = Color.from_hsv(max(0, hue), min(1, sat), max(0.02, bright))
|
|
43
|
+
for x in range(w):
|
|
44
|
+
c.set_pixel(x, y, ' ', bg=col, z=-100)
|
|
45
|
+
|
|
46
|
+
for cld in s['clouds']:
|
|
47
|
+
cld['x'] += cld['vx'] * dt * 8
|
|
48
|
+
if cld['x'] > w*1.2: cld['x'] = -cld['w']
|
|
49
|
+
for dy in range(3):
|
|
50
|
+
for dx in range(int(cld['w'])):
|
|
51
|
+
px = int(cld['x']) + dx - int(cld['w']/2)
|
|
52
|
+
py = int(cld['y']) + dy
|
|
53
|
+
d = abs(dx - cld['w']/2) / (cld['w']/2)
|
|
54
|
+
if d < 1 and 0 <= px < w and 0 <= py < h:
|
|
55
|
+
a = 1 - d
|
|
56
|
+
col = Color.from_hsv(cld['hue'], 0.3, 0.2+a*0.5)
|
|
57
|
+
c.set_pixel(px, py, '█', col, z=6)
|
|
58
|
+
|
|
59
|
+
temple_base = int(h * 0.55)
|
|
60
|
+
temple_cx = w // 2
|
|
61
|
+
for y in range(temple_base, h):
|
|
62
|
+
for x in range(w):
|
|
63
|
+
dist_from_center = abs(x - temple_cx)
|
|
64
|
+
width = int(20 + (h-1-y) * 0.5)
|
|
65
|
+
if dist_from_center <= width:
|
|
66
|
+
if y == temple_base:
|
|
67
|
+
c.set_pixel(x, y, '▄', Color(180, 170, 140), z=8)
|
|
68
|
+
elif x == temple_cx - width or x == temple_cx + width:
|
|
69
|
+
c.set_pixel(x, y, '║', Color(160, 150, 120), z=8)
|
|
70
|
+
elif abs(x - temple_cx) <= 2:
|
|
71
|
+
c.set_pixel(x, y, '║', Color(180, 170, 140), z=8)
|
|
72
|
+
elif dist_from_center < width - 1:
|
|
73
|
+
col = Color(int(100+(h-1-y)*4), int(95+(h-1-y)*3), int(80+(h-1-y)*2))
|
|
74
|
+
c.set_pixel(x, y, '█', col, z=8)
|
|
75
|
+
|
|
76
|
+
columns = [temple_cx - 12, temple_cx - 4, temple_cx + 4, temple_cx + 12]
|
|
77
|
+
col_h = 12
|
|
78
|
+
for col_x in columns:
|
|
79
|
+
for dy in range(col_h):
|
|
80
|
+
y = temple_base - dy
|
|
81
|
+
if y >= 0:
|
|
82
|
+
if 0 <= col_x < w and y < h:
|
|
83
|
+
c.set_pixel(col_x, y, '║', Color(180, 170, 140), z=10)
|
|
84
|
+
if 0 <= col_x+1 < w and y < h:
|
|
85
|
+
c.set_pixel(col_x+1, y, '▓', Color(140, 130, 100), z=10)
|
|
86
|
+
|
|
87
|
+
pediment_y = temple_base - col_h
|
|
88
|
+
for dx in range(-18, 19):
|
|
89
|
+
px = temple_cx + dx
|
|
90
|
+
if 0 <= px < w and 0 <= pediment_y < h:
|
|
91
|
+
if abs(dx) == 18:
|
|
92
|
+
c.set_pixel(px, pediment_y, '║', Color(180, 170, 140), z=11)
|
|
93
|
+
elif abs(dx) < 18 and pediment_y >= 0:
|
|
94
|
+
c.set_pixel(px, pediment_y, '▀', Color(180, 170, 140), z=11)
|
|
95
|
+
if 0 <= px < w and pediment_y-1 >= 0 and pediment_y-1 < h:
|
|
96
|
+
slope = 18 - abs(dx)
|
|
97
|
+
if slope > 10:
|
|
98
|
+
c.set_pixel(px, pediment_y-1, '▲', Color(180, 170, 140), z=12)
|
|
99
|
+
|
|
100
|
+
light_count = 7
|
|
101
|
+
for i in range(light_count):
|
|
102
|
+
a = (i / light_count) * 2 * math.pi + t * 0.1
|
|
103
|
+
bx = temple_cx + int(25 * math.cos(a))
|
|
104
|
+
by = temple_base - 20 + int(15 * math.sin(a))
|
|
105
|
+
for r in range(3, 10):
|
|
106
|
+
for ang in range(0, 360, 30):
|
|
107
|
+
rad = r * 0.5
|
|
108
|
+
lx = bx + int(rad * math.cos(ang*math.pi/180))
|
|
109
|
+
ly = by + int(rad * math.sin(ang*math.pi/180))
|
|
110
|
+
if 0 <= lx < w and 0 <= ly < h:
|
|
111
|
+
col = Color.from_hsv((i/light_count + t*0.01) % 1.0, 0.7, 0.3*(1-r/10))
|
|
112
|
+
c.set_pixel(lx, ly, '·', col, z=14)
|
|
113
|
+
|
|
114
|
+
for p in s['particles']:
|
|
115
|
+
p['x'] += p['vx'] * dt * 5 + math.sin(t*0.5+p['phase'])*0.2
|
|
116
|
+
p['y'] += p['vy'] * dt * 5
|
|
117
|
+
if p['y'] < -5: p['y'] = h+5
|
|
118
|
+
if p['x'] < -5: p['x'] = w+5
|
|
119
|
+
if p['x'] > w+5: p['x'] = -5
|
|
120
|
+
px, py = int(p['x']), int(p['y'])
|
|
121
|
+
if 0 <= px < w and 0 <= py < h:
|
|
122
|
+
pulse = 0.3+0.7*(0.5+0.5*math.sin(t+px*0.5+p['phase']))
|
|
123
|
+
c.set_pixel(px, py, '·', Color(255, 240, 200).mul(pulse*0.4), z=16)
|
demos/scene_cellular.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import math, random
|
|
2
|
+
from spore_engine import *
|
|
3
|
+
from spore_engine.core.color import *
|
|
4
|
+
from spore_engine.sim.cellular import GameOfLife, Automata1D, WireWorld, LangtonsAnt, PATTERNS
|
|
5
|
+
|
|
6
|
+
_gol = None
|
|
7
|
+
def scene_game_of_life(c, hr, t, pt, dt):
|
|
8
|
+
global _gol
|
|
9
|
+
if _gol is None:
|
|
10
|
+
_gol = GameOfLife(c.w, c.h)
|
|
11
|
+
_gol.randomize(0.35)
|
|
12
|
+
_gol.set_pattern(c.w//2-5, c.h//2-5, PATTERNS['glider_gun'])
|
|
13
|
+
for _ in range(3):
|
|
14
|
+
_gol.step()
|
|
15
|
+
for y in range(c.h):
|
|
16
|
+
for x in range(c.w):
|
|
17
|
+
n = (math.sin(x*0.02+t*0.3)+math.cos(y*0.02+t*0.2))*0.5+0.5
|
|
18
|
+
c.set_pixel(x, y, ' ', bg=Color(int(2+n*6), int(1+n*3), int(3+n*8)), z=-100)
|
|
19
|
+
_gol.render(c)
|
|
20
|
+
c.draw_text(2, 0, "Conway's Game of Life", Color(100,255,100), z=100)
|
|
21
|
+
|
|
22
|
+
_ca = None
|
|
23
|
+
def scene_automata_1d(c, hr, t, pt, dt):
|
|
24
|
+
global _ca
|
|
25
|
+
rules = [30, 90, 110, 150, 182, 73]
|
|
26
|
+
rule = rules[int(t/6)%len(rules)]
|
|
27
|
+
if _ca is None or t < 0.1:
|
|
28
|
+
_ca = Automata1D(c.w, rule)
|
|
29
|
+
_ca.render(c, 0, 0, min(c.h-2, 200), t=t)
|
|
30
|
+
c.draw_text(2, c.h-2, f"1D Cellular — Rule {rule}", Color(100,200,255), z=100)
|
|
31
|
+
|
|
32
|
+
_ww = None
|
|
33
|
+
def scene_wireworld(c, hr, t, pt, dt):
|
|
34
|
+
global _ww
|
|
35
|
+
if _ww is None:
|
|
36
|
+
_ww = WireWorld(c.w, c.h)
|
|
37
|
+
for y in range(c.h):
|
|
38
|
+
for x in range(c.w):
|
|
39
|
+
if y==0 or y==c.h-1 or x==0 or x==c.w-1:
|
|
40
|
+
_ww.set(x, y, 3)
|
|
41
|
+
for x in range(10, 30):
|
|
42
|
+
_ww.set(x, c.h//2, 3)
|
|
43
|
+
for x in range(15, 25):
|
|
44
|
+
_ww.set(x, c.h//2+1, 3)
|
|
45
|
+
_ww.set(5, c.h//2, 1)
|
|
46
|
+
_ww.set(5, c.h//2-1, 3)
|
|
47
|
+
for x in range(5, 15):
|
|
48
|
+
_ww.set(x, c.h//2-2, 3)
|
|
49
|
+
for _ in range(2):
|
|
50
|
+
_ww.step()
|
|
51
|
+
for y in range(c.h):
|
|
52
|
+
for x in range(c.w):
|
|
53
|
+
n = (math.sin(x*0.04+t*0.1)+math.cos(y*0.03))*0.5+0.5
|
|
54
|
+
c.set_pixel(x, y, ' ', bg=Color(int(3+n*5), int(1+n*3), int(5+n*10)), z=-100)
|
|
55
|
+
_ww.render(c)
|
|
56
|
+
c.draw_text(2, 0, "WireWorld", Color(255,200,0), z=100)
|
|
57
|
+
|
|
58
|
+
_la = None
|
|
59
|
+
def scene_langton(c, hr, t, pt, dt):
|
|
60
|
+
global _la
|
|
61
|
+
if _la is None:
|
|
62
|
+
_la = LangtonsAnt(c.w, c.h)
|
|
63
|
+
for _ in range(20):
|
|
64
|
+
_la.step()
|
|
65
|
+
_la.render(c, t=t)
|
|
66
|
+
c.draw_text(2, 0, "Langton's Ant", Color(255,255,100), z=100)
|