Class: Gosu::Image

Inherits:
Object show all
Includes:
TexPlay
Defined in:
lib/texplay.rb

Constant Summary

Constants included from TexPlay

TexPlay::RENDER_CLEAR_COLOR, TexPlay::TP_MAX_QUAD_SIZE, TexPlay::VERSION

Constants included from TexPlay::Colors

TexPlay::Colors::Alpha, TexPlay::Colors::Black, TexPlay::Colors::Blue, TexPlay::Colors::Brown, TexPlay::Colors::Cyan, TexPlay::Colors::Green, TexPlay::Colors::Grey, TexPlay::Colors::Orange, TexPlay::Colors::Purple, TexPlay::Colors::Red, TexPlay::Colors::Turquoise, TexPlay::Colors::Tyrian, TexPlay::Colors::White, TexPlay::Colors::Yellow

Class Method Summary collapse

Methods included from TexPlay

#[], #bezier, #box, #cache, #circle, #clear, #clone, #color, #colour, #composite, create_image, create_macro, #delete_options, #dup, #each, #fill, #force_sync, from_blob, #get_options, get_options, #get_pixel, init, #line, #method_missing, #ngon, #offset, on_setup, #paint, #pixel, #polyline, #quad_cached?, #rect, #refresh_cache, refresh_cache_all, remove_macro, set_defaults, set_options, #set_options, #set_pixel, setup, #splice, #to_blob

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class TexPlay

Class Method Details

.from_text(*args, &block) ⇒ Object



193
194
195
196
197
198
199
200
# File 'lib/texplay.rb', line 193

def from_text(*args, &block)

  options = args.last.is_a?(Hash) ? args.pop : {}
  # invoke old behaviour
  obj = original_from_text(*args, &block)

  prepare_image(obj, args.first, options)
end

.new(*args, &block) ⇒ Object



182
183
184
185
186
187
188
189
# File 'lib/texplay.rb', line 182

def new(*args, &block)

  options = args.last.is_a?(Hash) ? args.pop : {}
  # invoke old behaviour
  obj = original_new(*args, &block)

  prepare_image(obj, args.first, options)
end

.original_from_textObject



191
# File 'lib/texplay.rb', line 191

alias_method :original_from_text, :from_text

.original_newObject



180
# File 'lib/texplay.rb', line 180

alias_method :original_new, :new

.prepare_image(obj, window, options = {}) ⇒ Object



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/texplay.rb', line 202

def prepare_image(obj, window, options={})
  options = {
    :caching => TexPlay.get_options[:caching]
  }.merge!(options)
  
  # refresh the TexPlay image cache
  if obj.width <= (TexPlay::TP_MAX_QUAD_SIZE) &&
      obj.height <= (TexPlay::TP_MAX_QUAD_SIZE) && obj.quad_cached? then
    obj.refresh_cache if options[:caching]
  end
  
  # run custom setup
  TexPlay.setup(obj)
  
  obj.instance_variable_set(:@__window__, window)

  obj
end