mini_arcade_core.scenes.systems.builtins.particles ================================================== .. py:module:: mini_arcade_core.scenes.systems.builtins.particles .. autoapi-nested-parse:: Reusable procedural particle systems for simple fire/smoke style effects. Attributes ---------- .. autoapisummary:: mini_arcade_core.scenes.systems.builtins.particles.FIRE_COLOR_RAMP mini_arcade_core.scenes.systems.builtins.particles.SMOKE_COLOR_RAMP mini_arcade_core.scenes.systems.builtins.particles.FIRE_ALPHA_RAMP mini_arcade_core.scenes.systems.builtins.particles.SMOKE_ALPHA_RAMP mini_arcade_core.scenes.systems.builtins.particles.MAGIC_COLOR_RAMP mini_arcade_core.scenes.systems.builtins.particles.MAGIC_ALPHA_RAMP mini_arcade_core.scenes.systems.builtins.particles.POTION_COLOR_RAMP mini_arcade_core.scenes.systems.builtins.particles.POTION_ALPHA_RAMP mini_arcade_core.scenes.systems.builtins.particles.FIRE_PARTICLE_PROFILE mini_arcade_core.scenes.systems.builtins.particles.SMOKE_PARTICLE_PROFILE mini_arcade_core.scenes.systems.builtins.particles.MAGIC_PARTICLE_PROFILE mini_arcade_core.scenes.systems.builtins.particles.POTION_PARTICLE_PROFILE Classes ------- .. autoapisummary:: mini_arcade_core.scenes.systems.builtins.particles.ProceduralParticle mini_arcade_core.scenes.systems.builtins.particles.ProceduralParticleEmitterState mini_arcade_core.scenes.systems.builtins.particles.ProceduralParticleBinding mini_arcade_core.scenes.systems.builtins.particles.ProceduralParticleProfile mini_arcade_core.scenes.systems.builtins.particles.ProceduralParticleSimulationSystem mini_arcade_core.scenes.systems.builtins.particles.ProceduralParticleRenderSystem mini_arcade_core.scenes.systems.builtins.particles.ProceduralParticleBundle Functions --------- .. autoapisummary:: mini_arcade_core.scenes.systems.builtins.particles.particle_binding_with_profile mini_arcade_core.scenes.systems.builtins.particles.fire_particle_binding mini_arcade_core.scenes.systems.builtins.particles.smoke_particle_binding mini_arcade_core.scenes.systems.builtins.particles.magic_particle_binding mini_arcade_core.scenes.systems.builtins.particles.potion_particle_binding Module Contents --------------- .. py:data:: FIRE_COLOR_RAMP :type: tuple[ColorStop, Ellipsis] :value: ((0.0, (255, 252, 220)), (0.14, (255, 236, 150)), (0.34, (255, 182, 84)), (0.58, (255, 96, 44)),... .. py:data:: SMOKE_COLOR_RAMP :type: tuple[ColorStop, Ellipsis] :value: ((0.0, (146, 128, 124)), (0.3, (118, 104, 102)), (0.7, (82, 76, 78)), (1.0, (36, 32, 36))) .. py:data:: FIRE_ALPHA_RAMP :type: tuple[AlphaStop, Ellipsis] :value: ((0.0, 48), (0.08, 128), (0.28, 216), (0.72, 138), (1.0, 0)) .. py:data:: SMOKE_ALPHA_RAMP :type: tuple[AlphaStop, Ellipsis] :value: ((0.0, 18), (0.18, 42), (0.45, 64), (0.82, 34), (1.0, 0)) .. py:data:: MAGIC_COLOR_RAMP :type: tuple[ColorStop, Ellipsis] :value: ((0.0, (244, 222, 255)), (0.25, (188, 126, 255)), (0.55, (108, 72, 255)), (0.82, (56, 34, 162)),... .. py:data:: MAGIC_ALPHA_RAMP :type: tuple[AlphaStop, Ellipsis] :value: ((0.0, 34), (0.1, 96), (0.45, 188), (0.82, 92), (1.0, 0)) .. py:data:: POTION_COLOR_RAMP :type: tuple[ColorStop, Ellipsis] :value: ((0.0, (198, 255, 226)), (0.28, (120, 255, 200)), (0.56, (62, 214, 166)), (0.82, (20, 98, 88)),... .. py:data:: POTION_ALPHA_RAMP :type: tuple[AlphaStop, Ellipsis] :value: ((0.0, 22), (0.12, 74), (0.38, 146), (0.84, 60), (1.0, 0)) .. py:class:: ProceduralParticle One simulated procedural particle. .. py:attribute:: x :type: float .. py:attribute:: y :type: float .. py:attribute:: vx :type: float .. py:attribute:: vy :type: float .. py:attribute:: age :type: float .. py:attribute:: lifetime :type: float .. py:attribute:: start_radius :type: float .. py:attribute:: end_radius :type: float .. py:attribute:: phase :type: float :value: 0.0 .. py:class:: ProceduralParticleEmitterState Mutable state for one emitter. .. py:attribute:: particles :type: list[ProceduralParticle] :value: [] .. py:attribute:: spawn_accumulator :type: float :value: 0.0 .. py:attribute:: elapsed :type: float :value: 0.0 .. py:class:: ProceduralParticleBinding Bases: :py:obj:`Generic`\ [\ :py:obj:`TCtx`\ ] Configuration for one procedural particle emitter. .. py:attribute:: state_getter :type: Callable[[TCtx], ProceduralParticleEmitterState] .. py:attribute:: origin_getter :type: Callable[[TCtx], tuple[float, float]] .. py:attribute:: enabled_when :type: Callable[[TCtx], bool] .. py:attribute:: intensity_getter :type: Callable[[TCtx], float] .. py:attribute:: wind_getter :type: Callable[[TCtx], float] .. py:attribute:: viewport_getter :type: Callable[[TCtx], tuple[float, float]] .. py:attribute:: spawn_rate :type: float :value: 96.0 .. py:attribute:: max_particles :type: int :value: 180 .. py:attribute:: spawn_spread_x :type: float :value: 18.0 .. py:attribute:: spawn_spread_y :type: float :value: 6.0 .. py:attribute:: velocity_x :type: tuple[float, float] .. py:attribute:: velocity_y :type: tuple[float, float] .. py:attribute:: acceleration_x :type: float :value: 0.0 .. py:attribute:: acceleration_y :type: float :value: -18.0 .. py:attribute:: turbulence :type: float :value: 20.0 .. py:attribute:: turbulence_frequency :type: float :value: 7.0 .. py:attribute:: drag :type: float :value: 0.9 .. py:attribute:: lifetime :type: tuple[float, float] :value: (0.45, 0.9) .. py:attribute:: start_radius :type: tuple[float, float] :value: (8.0, 14.0) .. py:attribute:: end_radius :type: tuple[float, float] :value: (1.0, 4.0) .. py:attribute:: color_ramp :type: tuple[ColorStop, Ellipsis] :value: ((0.0, (255, 252, 220)), (0.14, (255, 236, 150)), (0.34, (255, 182, 84)), (0.58, (255, 96, 44)),... .. py:attribute:: alpha_ramp :type: tuple[AlphaStop, Ellipsis] :value: ((0.0, 48), (0.08, 128), (0.28, 216), (0.72, 138), (1.0, 0)) .. py:attribute:: render_pass_scales :type: tuple[float, Ellipsis] :value: (1.4, 0.92, 0.56) .. py:attribute:: render_pass_color_scales :type: tuple[float, Ellipsis] :value: (0.78, 1.0, 1.08) .. py:attribute:: render_pass_alpha_scales :type: tuple[float, Ellipsis] :value: (0.18, 0.52, 0.95) .. py:attribute:: intensity_radius_scale :type: float :value: 0.45 .. py:attribute:: intensity_lifetime_scale :type: float :value: 0.16 .. py:attribute:: intensity_velocity_scale :type: float :value: 0.28 .. py:attribute:: seed :type: int :value: 1 .. py:class:: ProceduralParticleProfile Reusable visual/physics preset for a particle emitter style. .. py:attribute:: spawn_rate :type: float .. py:attribute:: max_particles :type: int .. py:attribute:: spawn_spread_x :type: float .. py:attribute:: spawn_spread_y :type: float .. py:attribute:: velocity_x :type: tuple[float, float] .. py:attribute:: velocity_y :type: tuple[float, float] .. py:attribute:: acceleration_x :type: float .. py:attribute:: acceleration_y :type: float .. py:attribute:: turbulence :type: float .. py:attribute:: turbulence_frequency :type: float .. py:attribute:: drag :type: float .. py:attribute:: lifetime :type: tuple[float, float] .. py:attribute:: start_radius :type: tuple[float, float] .. py:attribute:: end_radius :type: tuple[float, float] .. py:attribute:: color_ramp :type: tuple[ColorStop, Ellipsis] .. py:attribute:: alpha_ramp :type: tuple[AlphaStop, Ellipsis] .. py:attribute:: render_pass_scales :type: tuple[float, Ellipsis] .. py:attribute:: render_pass_color_scales :type: tuple[float, Ellipsis] .. py:attribute:: render_pass_alpha_scales :type: tuple[float, Ellipsis] .. py:attribute:: intensity_radius_scale :type: float :value: 0.45 .. py:attribute:: intensity_lifetime_scale :type: float :value: 0.16 .. py:attribute:: intensity_velocity_scale :type: float :value: 0.28 .. py:data:: FIRE_PARTICLE_PROFILE .. py:data:: SMOKE_PARTICLE_PROFILE .. py:data:: MAGIC_PARTICLE_PROFILE .. py:data:: POTION_PARTICLE_PROFILE .. py:function:: particle_binding_with_profile(*, profile: ProceduralParticleProfile, state_getter: Callable[[TCtx], ProceduralParticleEmitterState], origin_getter: Callable[[TCtx], tuple[float, float]], intensity_getter: Callable[[TCtx], float] = _default_intensity, wind_getter: Callable[[TCtx], float] = _default_wind, viewport_getter: Callable[[TCtx], tuple[float, float]] = _default_viewport, enabled_when: Callable[[TCtx], bool] = _default_enabled_when, seed: int = 1) -> ProceduralParticleBinding[TCtx] Build an emitter binding from a reusable particle style profile. .. py:function:: fire_particle_binding(*, state_getter: Callable[[TCtx], ProceduralParticleEmitterState], origin_getter: Callable[[TCtx], tuple[float, float]], intensity_getter: Callable[[TCtx], float] = _default_intensity, wind_getter: Callable[[TCtx], float] = _default_wind, viewport_getter: Callable[[TCtx], tuple[float, float]] = _default_viewport, seed: int = 1) -> ProceduralParticleBinding[TCtx] Convenience preset for a warm fire emitter. .. py:function:: smoke_particle_binding(*, state_getter: Callable[[TCtx], ProceduralParticleEmitterState], origin_getter: Callable[[TCtx], tuple[float, float]], intensity_getter: Callable[[TCtx], float] = _default_intensity, wind_getter: Callable[[TCtx], float] = _default_wind, viewport_getter: Callable[[TCtx], tuple[float, float]] = _default_viewport, seed: int = 2) -> ProceduralParticleBinding[TCtx] Convenience preset for a soft smoke emitter. .. py:function:: magic_particle_binding(*, state_getter: Callable[[TCtx], ProceduralParticleEmitterState], origin_getter: Callable[[TCtx], tuple[float, float]], intensity_getter: Callable[[TCtx], float] = _default_intensity, wind_getter: Callable[[TCtx], float] = _default_wind, viewport_getter: Callable[[TCtx], tuple[float, float]] = _default_viewport, enabled_when: Callable[[TCtx], bool] = _default_enabled_when, seed: int = 3) -> ProceduralParticleBinding[TCtx] Convenience preset for arcane glow/spark emitters. .. py:function:: potion_particle_binding(*, state_getter: Callable[[TCtx], ProceduralParticleEmitterState], origin_getter: Callable[[TCtx], tuple[float, float]], intensity_getter: Callable[[TCtx], float] = _default_intensity, wind_getter: Callable[[TCtx], float] = _default_wind, viewport_getter: Callable[[TCtx], tuple[float, float]] = _default_viewport, enabled_when: Callable[[TCtx], bool] = _default_enabled_when, seed: int = 4) -> ProceduralParticleBinding[TCtx] Convenience preset for bubbling potion/fume emitters. .. py:class:: ProceduralParticleSimulationSystem Bases: :py:obj:`Generic`\ [\ :py:obj:`TCtx`\ ] Spawn and simulate particles for one or more emitters. .. py:attribute:: name :type: str :value: 'procedural_particle_simulation' .. py:attribute:: phase :type: int .. py:attribute:: order :type: int :value: 32 .. py:attribute:: bindings :type: tuple[ProceduralParticleBinding[TCtx], Ellipsis] :value: () .. py:method:: __post_init__() -> None .. py:method:: step(ctx: TCtx) -> None Advance emitter state, cull dead particles, and spawn new ones. .. py:class:: ProceduralParticleRenderSystem Bases: :py:obj:`Generic`\ [\ :py:obj:`TCtx`\ ] Render procedural particles using primitive circles. .. py:attribute:: name :type: str :value: 'procedural_particle_render' .. py:attribute:: phase :type: int .. py:attribute:: order :type: int :value: 105 .. py:attribute:: bindings :type: tuple[ProceduralParticleBinding[TCtx], Ellipsis] :value: () .. py:method:: step(ctx: TCtx) -> None Build a render packet with draw calls for all particles from all emitters, sorted back-to-front by Y coordinate. :param ctx: The current scene context, which must have a `packet` attribute that is a `RenderPacket` or `None`. :type ctx: TCtx .. py:class:: ProceduralParticleBundle Bases: :py:obj:`mini_arcade_core.scenes.systems.SystemBundle`\ [\ :py:obj:`TCtx`\ ] Compose simulation and render systems for one or more procedural emitters. .. py:attribute:: bindings :type: tuple[ProceduralParticleBinding[TCtx], Ellipsis] :value: () .. py:attribute:: simulation_name :type: str :value: 'procedural_particle_simulation' .. py:attribute:: simulation_phase :type: int .. py:attribute:: simulation_order :type: int :value: 32 .. py:attribute:: render_name :type: str :value: 'procedural_particle_render' .. py:attribute:: render_phase :type: int .. py:attribute:: render_order :type: int :value: 105 .. py:method:: __post_init__() -> None .. py:method:: iter_systems() -> Iterable[object] Return the concrete systems that should be added to the pipeline.