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
- .create_image(window, width, height, options = {}) ⇒ Object (also: create_blank_image)
-
.create_macro ⇒ Object
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.
- .get_options ⇒ Object
- .init ⇒ Object
- .on_setup(&block) ⇒ Object
- .refresh_cache_all ⇒ Object
- .remove_macro ⇒ Object
-
.set_defaults ⇒ Object
default values defined here.
- .set_options(options = {}) ⇒ Object
- .setup(receiver) ⇒ Object
Instance Method Summary collapse
- #[] ⇒ Object
- #bezier ⇒ Object
-
#box ⇒ Object
aliases; must be made on singleton class because we’re using class methods *.
- #cache ⇒ Object
- #circle ⇒ Object
-
#clear(options = {}) ⇒ Gosu::Image
Clear an image.
- #clone ⇒ Object
- #color ⇒ Object
- #colour ⇒ Object
- #composite ⇒ Object
- #delete_options ⇒ Object
-
#dup ⇒ Object
rb_define_method(jm_Module, “[]=”, m_special_pixel, -1);.
- #each ⇒ Object
- #fill ⇒ Object
- #force_sync ⇒ Object
- #get_options ⇒ Object
- #get_pixel ⇒ Object
- #line ⇒ Object
- #method_missing ⇒ Object
- #ngon ⇒ Object
- #offset ⇒ Object
-
#paint ⇒ Object
TexPlay methods.
- #pixel ⇒ Object
- #polyline ⇒ Object
- #quad_cached? ⇒ Boolean
- #rect ⇒ Object
- #refresh_cache ⇒ Object
- #set_options ⇒ Object
- #set_pixel ⇒ Object
- #splice ⇒ Object
- #to_blob ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing ⇒ Object
Class Method Details
.create_image(window, width, height, options = {}) ⇒ Object Also known as: create_blank_image
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, ={}) = { :color => :alpha, :caching => false, }.merge!() raise ArgumentError, "Height and width must be positive" if height <= 0 or width <= 0 img = Gosu::Image.new(window, EmptyImageStub.new(width, height), :caching => [:caching]) img.rect 0, 0, img.width - 1, img.height - 1, :color => [:color], :fill => true img end |
.create_macro ⇒ Object
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.
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, ={}) = { :caching => @options[:caching], :tileable => false, }.merge!() 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), [:tileable], :caching => [:caching]) end |
.get_options ⇒ Object
67 68 69 |
# File 'lib/texplay.rb', line 67 def @options end |
.init ⇒ Object
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_all ⇒ Object
.remove_macro ⇒ Object
.set_defaults ⇒ Object
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 ( = {}) @options.merge!() 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
#bezier ⇒ Object
#box ⇒ Object
aliases; must be made on singleton class because we’re using class methods *
#cache ⇒ Object
#circle ⇒ Object
#clear(options = {}) ⇒ Gosu::Image
Clear an image.
107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/texplay.rb', line 107 def clear( = {}) = { :color => :alpha, :fill => true }.merge!() capture { rect 0, 0, width - 1, height - 1, self } end |
#clone ⇒ Object
#color ⇒ Object
#colour ⇒ Object
#composite ⇒ Object
#delete_options ⇒ Object
#dup ⇒ Object
rb_define_method(jm_Module, “[]=”, m_special_pixel, -1);
#each ⇒ Object
#fill ⇒ Object
#force_sync ⇒ Object
#get_options ⇒ Object
#get_pixel ⇒ Object
#line ⇒ Object
#ngon ⇒ Object
#offset ⇒ Object
#paint ⇒ Object
TexPlay methods