Module: ParticleFX2D::RendererFactory

Included in:
ParticleFX2D::Ruby2D::CanvasRendererFactory, ParticleFX2D::Ruby2D::ShapeRendererFactory
Defined in:
lib/particlefx2d/renderer_factory.rb

Overview

Defines a RendererFactory. Each emitter should have it’s own factory which is called once per particle to create a Renderer. It is possible for a factory to

  • EITHER return the same Renderer for all particles and handle the drawing for the particles;

  • OR return a renderer per particle.

Instance Method Summary collapse

Instance Method Details

#on_update_endObject

Called once per update cycle by the emitter to let the factory know that an update cycle is complete. A shared renderer factory can use this to commit the changes made, for example. A per-particle renderer factory can ignore this method as by default it does nothing.



31
32
33
# File 'lib/particlefx2d/renderer_factory.rb', line 31

def on_update_end
  # Does nothing by default.
end

#on_update_startObject

Called once per update cycle by the emitter to let the factory know that all the particles are about to be updated and redrawn. A shared renderer factory can use this to clear the underlying surface, for example. A per-particle renderer factory can ignore this method as by default it does nothing.



22
23
24
# File 'lib/particlefx2d/renderer_factory.rb', line 22

def on_update_start
  # Does nothing by default.
end

#renderer_for(_particle) ⇒ Renderer

Return a particle renderer.

Returns:



13
14
15
# File 'lib/particlefx2d/renderer_factory.rb', line 13

def renderer_for(_particle)
  raise StandardError('unimplemented')
end