class Graphics::Simulation

A simulation. This ties everything together and provides a bunch of convenience methods to make life easier.

In the Model View Controller (MVC) pattern, the simulation is the Controller and controls both the window and all bodies involved in the simulation. The bodies are the Model and each body class is expected to have an inner View class w/ a draw class method for the View.

For example, in examples/bounce.rb:

+ BounceSimulation subclasses Graphics::Simulation + BounceSimulation has many Balls + Ball#update maintains all ball movement. + BounceSimulation#draw automatically calls Ball::View.draw on all balls. + Ball::View.draw takes a window and a ball and draws it.

Public Instance Methods

initialize_rainbow(rainbow, name) click to toggle source

Generate colors using a rainbow and a prefix name.

# File lib/graphics/rainbows.rb, line 114
def initialize_rainbow rainbow, name
  rainbow.cache.each do |degree, color|
    color_name = "#{name}_#{degree}".to_sym
    self.register_color(color_name, *color, 255)
  end
end