Sha256: 44c8d5a54f67ba0405344b3eecddd8903c38534682277a5e34cf2855495fb328

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_relative 'renderer'

module ParticleFX2D
  # 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.
  module RendererFactory
    # Return a particle renderer.
    #
    # @return [Renderer] for each particle
    def renderer_for(_particle)
      raise StandardError('unimplemented')
    end

    #
    # 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.
    def on_update_start
      # Does nothing by default.
    end

    #
    # 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.
    def on_update_end
      # Does nothing by default.
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
particlefx2d-0.4.0 lib/particlefx2d/renderer_factory.rb
particlefx2d-0.3.0 lib/particlefx2d/renderer_factory.rb