Module: TexPlay
- Includes:
- Colors
- Included in:
- Gosu::Image
- Defined in:
- lib/texplay.rb,
lib/texplay/alone.rb,
lib/texplay/version.rb,
lib/texplay/c_function_docs.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)
- Win =
Gosu::Window.new(100, 100, false)
- VERSION =
"0.4.3"
- 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_blank_image ⇒ Object
- .create_image(width, height, options = {}) ⇒ Object
-
.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
- .load(name) ⇒ Object
- .on_setup(&block) ⇒ Object
- .original_create_image ⇒ 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(points, options = {}) ⇒ Gosu::Image
Draw a bezier curve.
- #cache ⇒ Object
-
#circle(center_x, center_y, radius, options = {}) ⇒ Gosu::Image
Draw a circle.
-
#clear(options = {}) ⇒ Gosu::Image
Clear an image.
-
#clone ⇒ Gosu::Image
Make a copy of the image.
- #color ⇒ Object
- #colour ⇒ Object
- #delete_options ⇒ Object
-
#dup ⇒ Object
rb_define_method(jm_Module, “[]=”, m_special_pixel, -1);.
-
#each {|color, x, y| ... } ⇒ Object
Iterate through every pixel of the image, allowing modification of each pixels.
-
#fill(x, y, options = {}) ⇒ Gosu::Image
Perform a Flood Fill at a given position.
-
#force_sync(rectangle = [0, 0, width, height]) ⇒ Gosu::Image
Force synchronisation of the image (send from RAM to VRAM).
- #get_options ⇒ Object
-
#get_pixel(x, y) ⇒ Array<Float>
Get the colour of an individual pixel.
- #line(x1, y1, x2, y2, options = {}) ⇒ Gosu::Image
- #method_missing ⇒ Object
-
#ngon(center_x, center_y, radius, sides, options = {}) ⇒ Gosu::Image
Draw an n-sided polygon.
-
#offset(x, y) ⇒ Gosu::Image
Offset all future drawing actions.
-
#paint(options = {}, &block) ⇒ Object
TexPlay methods.
-
#polyline(points, options = {}) ⇒ Gosu::Image
Draw a series of connected lines.
- #quad_cached? ⇒ Boolean
-
#rect(x1, y1, x2, y2, options = {}) ⇒ Gosu::Image
(also: #box)
Draw a rectangle.
- #refresh_cache ⇒ Object
- #set_options ⇒ Object
-
#set_pixel(x, y, options = {}) ⇒ Gosu::Image
(also: #pixel)
Set the colour of an individual pixel.
-
#splice(x, y, source, options = {}) ⇒ Gosu::Image
(also: #composite)
Copy an image into another image.
-
#to_blob ⇒ String
Generate binary data from the image.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing ⇒ Object
Class Method Details
.create_blank_image ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/texplay.rb', line 54 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]) # this should be a major speedup (avoids both a cache and a sync # if color is alpha (default) if [:color] != :alpha img.rect 0, 0, img.width - 1, img.height - 1, :color => [:color], :fill => true end img end |
.create_image(width, height, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/texplay.rb', line 35 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]) # this should be a major speedup (avoids both a cache and a sync # if color is alpha (default) if [:color] != :alpha img.rect 0, 0, img.width - 1, img.height - 1, :color => [:color], :fill => true end 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.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/texplay.rb', line 57 def from_blob(window, blob_data, width, height, ={}) = { :caching => false, :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
77 78 79 |
# File 'lib/texplay.rb', line 77 def @options end |
.init ⇒ Object
88 89 90 |
# File 'lib/texplay.rb', line 88 def init set_defaults end |
.load(name) ⇒ Object
11 12 13 |
# File 'lib/texplay/alone.rb', line 11 def load(name) Gosu::Image.new(Win, name) end |
.on_setup(&block) ⇒ Object
21 22 23 24 25 |
# File 'lib/texplay.rb', line 21 def on_setup(&block) raise "need a block" if !block @__init_procs__ ||= [] @__init_procs__.push(block) end |
.original_create_image ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/texplay/alone.rb', line 15 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]) # this should be a major speedup (avoids both a cache and a sync # if color is alpha (default) if [:color] != :alpha img.rect 0, 0, img.width - 1, img.height - 1, :color => [:color], :fill => true end img end |
.refresh_cache_all ⇒ Object
.remove_macro ⇒ Object
.set_defaults ⇒ Object
default values defined here
82 83 84 85 86 |
# File 'lib/texplay.rb', line 82 def set_defaults @options = { :caching => :lazy } end |
.set_options(options = {}) ⇒ Object
73 74 75 |
# File 'lib/texplay.rb', line 73 def ( = {}) @options.merge!() end |
.setup(receiver) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/texplay.rb', line 27 def setup(receiver) if @__init_procs__ @__init_procs__.each do |init_proc| receiver.instance_eval(&init_proc) end end end |
Instance Method Details
#[] ⇒ Object
#bezier(points, options = {}) ⇒ Gosu::Image
Draw a bezier curve.
11 12 |
# File 'lib/texplay/c_function_docs.rb', line 11 def bezier(points, = {}) end |
#cache ⇒ Object
#circle(center_x, center_y, radius, options = {}) ⇒ Gosu::Image
:thickness not implemented for circle.
Draw a circle.
25 26 |
# File 'lib/texplay/c_function_docs.rb', line 25 def circle(center_x, center_y, radius, = {}) end |
#clear(options = {}) ⇒ Gosu::Image
Clear an image.
117 118 119 120 121 122 123 124 |
# File 'lib/texplay.rb', line 117 def clear( = {}) = { :color => :alpha, :fill => true }.merge!() rect 0, 0, width - 1, height - 1, end |
#clone ⇒ Gosu::Image
Make a copy of the image.
31 32 |
# File 'lib/texplay/c_function_docs.rb', line 31 def clone() end |
#color ⇒ Object
#colour ⇒ Object
#delete_options ⇒ Object
#dup ⇒ Object
rb_define_method(jm_Module, “[]=”, m_special_pixel, -1);
35 36 |
# File 'lib/texplay/c_function_docs.rb', line 35 def dup() end |
#each {|color, x, y| ... } ⇒ Object
Iterate through every pixel of the image, allowing modification of each pixels.
45 46 |
# File 'lib/texplay/c_function_docs.rb', line 45 def each(&block) end |
#fill(x, y, options = {}) ⇒ Gosu::Image
Perform a Flood Fill at a given position.
55 56 |
# File 'lib/texplay/c_function_docs.rb', line 55 def fill(x, y, = {}) end |
#force_sync(rectangle = [0, 0, width, height]) ⇒ Gosu::Image
Force synchronisation of the image (send from RAM to VRAM).
62 63 |
# File 'lib/texplay/c_function_docs.rb', line 62 def force_sync(rectangle = [0, 0, width, height]) end |
#get_options ⇒ Object
#get_pixel(x, y) ⇒ Array<Float>
Get the colour of an individual pixel.
70 71 |
# File 'lib/texplay/c_function_docs.rb', line 70 def get_pixel(x, y) end |
#line(x1, y1, x2, y2, options = {}) ⇒ Gosu::Image
81 82 |
# File 'lib/texplay/c_function_docs.rb', line 81 def line(x1, y1, x2, y2, = {}) end |
#ngon(center_x, center_y, radius, sides, options = {}) ⇒ Gosu::Image
Draw an n-sided polygon.
90 91 |
# File 'lib/texplay/c_function_docs.rb', line 90 def ngon(center_x, center_y, radius, sides, = {}) end |
#offset(x, y) ⇒ Gosu::Image
Offset all future drawing actions.
The offset is non-stacking.
Can also use offset(:default) to reset offset to (0, 0).
102 103 |
# File 'lib/texplay/c_function_docs.rb', line 102 def offset(x, y) end |
#paint(options = {}, &block) ⇒ Object
TexPlay methods
120 121 |
# File 'lib/texplay/c_function_docs.rb', line 120 def paint( = {}, &block) end |
#polyline(points, options = {}) ⇒ Gosu::Image
Draw a series of connected lines.
129 130 |
# File 'lib/texplay/c_function_docs.rb', line 129 def polyline(points, = {}) end |
#quad_cached? ⇒ Boolean
#rect(x1, y1, x2, y2, options = {}) ⇒ Gosu::Image Also known as: box
Draw a rectangle.
141 142 |
# File 'lib/texplay/c_function_docs.rb', line 141 def rect(x1, y1, x2, y2, = {}) end |
#refresh_cache ⇒ Object
#set_options ⇒ Object
#set_pixel(x, y, options = {}) ⇒ Gosu::Image Also known as: pixel
Set the colour of an individual pixel.
154 155 |
# File 'lib/texplay/c_function_docs.rb', line 154 def set_pixel(x, y, = {}) end |
#splice(x, y, source, options = {}) ⇒ Gosu::Image Also known as: composite
Copy an image into another image.
167 168 |
# File 'lib/texplay/c_function_docs.rb', line 167 def splice(x, y, source, = {}) end |
#to_blob ⇒ String
This method is usually overridden by the default Gosu::Image#to_blob.
This method causes a segmentation fault in Windows.
Generate binary data from the image.
176 177 |
# File 'lib/texplay/c_function_docs.rb', line 176 def to_blob end |