Module: TexPlay

Includes:
Colors
Included in:
Gosu::Image
Defined in:
lib/texplay.rb,
lib/texplay/version.rb,
ext/texplay/texplay.c

Defined Under Namespace

Modules: Colors Classes: EmptyImageStub, ImageStub, LSystem, TPPoint

Constant Summary collapse

RENDER_CLEAR_COLOR =
Gosu::Color.new(255, 0, 0, 0)
VERSION =
"0.3.1"
TP_MAX_QUAD_SIZE =

a constant containing the sidelength of largest allowable quad

INT2FIX(max_quad_size() - 2)

Constants included from Colors

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

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject

Class Method Details

.create_image(window, width, height, options = {}) ⇒ Object Also known as: create_blank_image

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/texplay.rb', line 30

def create_image(window, width, height, options={})
  options = {
    :color => :alpha,
    :caching => false,
  }.merge!(options)

  raise ArgumentError, "Height and width must be positive" if height <= 0 or width <= 0
  
  img = Gosu::Image.new(window, EmptyImageStub.new(width, height), :caching => options[:caching])
  img.rect 0, 0, img.width - 1, img.height - 1, :color => options[:color], :fill => true 

  img
end

.create_macroObject

singleton method for creating & removing macros

.from_blob(window, blob_data, width, height, options = {}) ⇒ Object

Image can be :tileable, but it will break if it is tileable AND gets modified after creation.

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/texplay.rb', line 47

def from_blob(window, blob_data, width, height, options={})
  options = {
    :caching => @options[:caching],
    :tileable => false,
  }.merge!(options)

  raise ArgumentError, "Height and width must be positive (received #{width}x#{height})" if height <= 0 or width <= 0

  expected_size = height * width * 4
  if blob_data.size != expected_size
    raise ArgumentError, "Blob data is not of the correct size (expected #{expected_size} but received #{blob_data.size} bytes)"
  end

  Gosu::Image.new(window, ImageStub.new(blob_data, width, height), options[:tileable], :caching => options[:caching])
end

.get_optionsObject



67
68
69
# File 'lib/texplay.rb', line 67

def get_options
  @options
end

.initObject



78
79
80
# File 'lib/texplay.rb', line 78

def init
  set_defaults
end

.on_setup(&block) ⇒ Object



15
16
17
18
19
20
# File 'lib/texplay.rb', line 15

def on_setup(&block)
  raise "need a block" if !block
  
  @__init_procs__ ||= []
  @__init_procs__.push(block)
end

.refresh_cache_allObject

.remove_macroObject

.set_defaultsObject

default values defined here



72
73
74
75
76
# File 'lib/texplay.rb', line 72

def set_defaults
  @options = {
    :caching => true
  }
end

.set_options(options = {}) ⇒ Object



63
64
65
# File 'lib/texplay.rb', line 63

def set_options(options = {})
  @options.merge!(options)
end

.setup(receiver) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/texplay.rb', line 22

def setup(receiver)
  if @__init_procs__ then
    @__init_procs__.each do |init_proc|
      receiver.instance_eval(&init_proc)
    end
  end
end

Instance Method Details

#[]Object

#bezierObject

#boxObject

aliases; must be made on singleton class because we’re using class methods *

#cacheObject

#circleObject

#clear(options = {}) ⇒ Gosu::Image

Clear an image.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :color (Object) — default: :alpha

    Colour of the image.

Returns:



107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/texplay.rb', line 107

def clear(options = {})
  options = {
    :color => :alpha,
    :fill => true
  }.merge!(options)

  capture {
    rect 0, 0, width - 1, height - 1, options
    
    self
  }
end

#cloneObject

#colorObject

#colourObject

#compositeObject

#delete_optionsObject

#dupObject

rb_define_method(jm_Module, “[]=”, m_special_pixel, -1);

#eachObject

#fillObject

#force_syncObject

#get_optionsObject

#get_pixelObject

#lineObject

#ngonObject

#offsetObject

#paintObject

TexPlay methods

#pixelObject

#polylineObject

#quad_cached?Boolean

Returns:

  • (Boolean)

#rectObject

#refresh_cacheObject

#set_optionsObject

#set_pixelObject

#spliceObject

#to_blobObject