texplay 0.4.3-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/.gemtest +0 -0
  2. data/CHANGELOG +222 -0
  3. data/README.markdown +48 -0
  4. data/Rakefile +16 -0
  5. data/examples/common.rb +18 -0
  6. data/examples/example_alpha_blend.rb +29 -0
  7. data/examples/example_bezier.rb +41 -0
  8. data/examples/example_blank.rb +37 -0
  9. data/examples/example_cache.rb +21 -0
  10. data/examples/example_color_control.rb +69 -0
  11. data/examples/example_color_transform.rb +62 -0
  12. data/examples/example_color_transform_circle.rb +34 -0
  13. data/examples/example_darken.rb +24 -0
  14. data/examples/example_dup.rb +73 -0
  15. data/examples/example_each.rb +39 -0
  16. data/examples/example_effect.rb +34 -0
  17. data/examples/example_fill.rb +43 -0
  18. data/examples/example_fill_old.rb +48 -0
  19. data/examples/example_fluent.rb +29 -0
  20. data/examples/example_font.rb +31 -0
  21. data/examples/example_hash_arguments.rb +46 -0
  22. data/examples/example_ippa.rb +23 -0
  23. data/examples/example_light.rb +75 -0
  24. data/examples/example_light_multiply.rb +18 -0
  25. data/examples/example_lsystem.rb +61 -0
  26. data/examples/example_melt.rb +25 -0
  27. data/examples/example_meyet.rb +62 -0
  28. data/examples/example_polyline.rb +42 -0
  29. data/examples/example_scale.rb +27 -0
  30. data/examples/example_select.rb +36 -0
  31. data/examples/example_select2.rb +25 -0
  32. data/examples/example_simple.rb +46 -0
  33. data/examples/example_splice.rb +26 -0
  34. data/examples/example_sync.rb +59 -0
  35. data/examples/example_tiles.rb +41 -0
  36. data/examples/example_trace.rb +22 -0
  37. data/examples/example_transparent.rb +28 -0
  38. data/examples/example_transparent2.rb +24 -0
  39. data/examples/example_transparent3.rb +20 -0
  40. data/examples/example_turtle.rb +39 -0
  41. data/examples/example_weird.rb +22 -0
  42. data/examples/example_window_render_to_image.rb +41 -0
  43. data/examples/example_window_to_blob.rb +35 -0
  44. data/examples/media/bird.png +0 -0
  45. data/examples/media/body.png +0 -0
  46. data/examples/media/empty2.png +0 -0
  47. data/examples/media/face.png +0 -0
  48. data/examples/media/gob.png +0 -0
  49. data/examples/media/gosu.png +0 -0
  50. data/examples/media/green.png +0 -0
  51. data/examples/media/logo.png +0 -0
  52. data/examples/media/maria.png +0 -0
  53. data/examples/media/object.png +0 -0
  54. data/examples/media/rose.bmp +0 -0
  55. data/examples/media/sand1.png +0 -0
  56. data/examples/media/sunset.png +0 -0
  57. data/examples/media/texplay.png +0 -0
  58. data/ext/texplay/actions.c +1006 -0
  59. data/ext/texplay/actions.h +60 -0
  60. data/ext/texplay/bindings.c +1125 -0
  61. data/ext/texplay/bindings.h +46 -0
  62. data/ext/texplay/cache.c +118 -0
  63. data/ext/texplay/cache.h +24 -0
  64. data/ext/texplay/compat.h +27 -0
  65. data/ext/texplay/extconf.rb +38 -0
  66. data/ext/texplay/graphics_utils.c +1313 -0
  67. data/ext/texplay/graphics_utils.h +22 -0
  68. data/ext/texplay/texplay.c +201 -0
  69. data/ext/texplay/texplay.h +153 -0
  70. data/ext/texplay/utils.c +891 -0
  71. data/ext/texplay/utils.h +153 -0
  72. data/ext/texplay/vendor/freeglut/include/GL/freeglut.h +22 -0
  73. data/ext/texplay/vendor/freeglut/include/GL/freeglut_ext.h +236 -0
  74. data/ext/texplay/vendor/freeglut/include/GL/freeglut_std.h +628 -0
  75. data/ext/texplay/vendor/freeglut/include/GL/glut.h +21 -0
  76. data/lib/texplay-contrib.rb +147 -0
  77. data/lib/texplay.rb +347 -0
  78. data/lib/texplay/1.8/texplay.so +0 -0
  79. data/lib/texplay/1.9/texplay.so +0 -0
  80. data/lib/texplay/alone.rb +20 -0
  81. data/lib/texplay/c_function_docs.rb +178 -0
  82. data/lib/texplay/live.rb +84 -0
  83. data/lib/texplay/version.rb +3 -0
  84. data/live/live.rb +85 -0
  85. data/test/image_spec.rb +45 -0
  86. data/test/texplay_spec.rb +144 -0
  87. metadata +179 -0
@@ -0,0 +1,20 @@
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require "#{direc}/../texplay"
4
+
5
+ module TexPlay
6
+ Win = Gosu::Window.new(100, 100, false)
7
+
8
+ set_options :sync_mode => :no_sync
9
+
10
+ class << self
11
+ def load(name)
12
+ Gosu::Image.new(Win, name)
13
+ end
14
+
15
+ alias_method :original_create_image, :create_image
16
+ def create_image(width, height, options={})
17
+ original_create_image(Win, width, height, options)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,178 @@
1
+ # -*- coding: iso-8859-1 -*-
2
+ # This code is never run; it is just here so we can document the C functions.
3
+
4
+
5
+ module TexPlay
6
+ # Draw a bezier curve.
7
+ #
8
+ # @param (see #polyline)
9
+ # @option (see #polyline)
10
+ # @return [Gosu::Image]
11
+ def bezier(points, options = {})
12
+ end
13
+
14
+ # Draw a circle.
15
+ #
16
+ # @note :thickness not implemented for circle.
17
+ #
18
+ # @param [Number] center_x Horizontal center.
19
+ # @param [Number] center_y Vertical center.
20
+ # @param [Number] radius Radius.
21
+ # @option (see #set_pixel)
22
+ # @option options [Boolean] :fill (false) Whether to fill in the shape.
23
+ # @option options [Boolean] :filled (false) Synonym for +:fill+
24
+ # @return [Gosu::Image]
25
+ def circle(center_x, center_y, radius, options = {})
26
+ end
27
+
28
+ # Make a copy of the image.
29
+ #
30
+ # @return [Gosu::Image] Deep copy of the image.
31
+ def clone()
32
+ end
33
+
34
+ # (see #clone)
35
+ def dup()
36
+ end
37
+
38
+ # Iterate through every pixel of the image, allowing modification of each pixels.
39
+ #
40
+ # @yield [color, x, y] Colour and position (arity == 3).
41
+ # @yield [color] Colour only (arity == 1).
42
+ # @yieldparam [Array<Float>] color RGBA colour array. This can be modified to affect the image directly.
43
+ # @yieldparam [Integer] x X position of the pixel.
44
+ # @yieldparam [Integer] y Y position of the pixel.
45
+ def each(&block)
46
+ end
47
+
48
+ # Perform a Flood Fill at a given position.
49
+ #
50
+ # @param [Number] x
51
+ # @param [Number] y
52
+ # @option options [Gosu::Color, Array<Float>, Symbol] :color (:white) Colour to apply to the drawing action.
53
+ # @option options [Proc, Hash] :color_control Effect to apply to the drawing action.
54
+ # @return [Gosu::Image]
55
+ def fill(x, y, options = {})
56
+ end
57
+
58
+ # Force synchronisation of the image (send from RAM to VRAM).
59
+ #
60
+ # @param [Array<Number>] rectangle Area to synchronise.
61
+ # @return [Gosu::Image]
62
+ def force_sync(rectangle = [0, 0, width, height])
63
+ end
64
+
65
+ # Get the colour of an individual pixel.
66
+ #
67
+ # @param [Number] x Horizontal position.
68
+ # @param [Number] y Vertical position.
69
+ # @return [Array<Float>] 4-element, RGBA colour array.
70
+ def get_pixel(x, y)
71
+ end
72
+
73
+ # @param [Number] x1 X position of start of line.
74
+ # @param [Number] y1 Y position of start of line.
75
+ # @param [Number] x2 X position of end of line.
76
+ # @param [Number] y2 Y position of end of line.
77
+ # @option (see #set_pixel)
78
+ # @option options [Number] :thickness (1) Thickness of the line.
79
+ # @option options [Hash] :trace Trace
80
+ # @return [Gosu::Image]
81
+ def line(x1, y1, x2, y2, options = {})
82
+ end
83
+
84
+ # Draw an n-sided polygon.
85
+ #
86
+ # @param (see #circle)
87
+ # @param [Integer] sides Number of sides for the polygon.
88
+ # @option (see #circle)
89
+ # @return [Gosu::Image]
90
+ def ngon(center_x, center_y, radius, sides, options = {})
91
+ end
92
+
93
+ # Offset all future drawing actions.
94
+ #
95
+ # The offset is non-stacking.
96
+ #
97
+ # Can also use +offset(:default)+ to reset offset to (0, 0).
98
+ #
99
+ # @param [Number] x
100
+ # @param [Number] y
101
+ # @return [Gosu::Image]
102
+ def offset(x, y)
103
+ end
104
+
105
+ # Perform drawing operations in the context of the image using _lazy_ syncing.
106
+ #
107
+ # A peculiarity of paint blocks is how they sync the drawing actions (syncing will be discussed in greater depth
108
+ # later on). The drawing actions in a Paint Block are not sync�d until the very end of the Paint Block and are then
109
+ # sync'd to video memory all in one go (This style of syncing is called _lazy_ syncing in TexPlay)
110
+ #
111
+ # @example Drawing to the image within a paint block
112
+ # image1.paint do
113
+ # circle 10, 10, 20, :color => :green
114
+ # bezier [0, 0, 10, 10, 50, 0], :closed => true
115
+ # end
116
+ #
117
+ # @option options [Symbol] :sync_mode (:lazy_sync) One of +:lazy_sync+, +:no_sync+ or +:eager_sync+
118
+ # @yield Block evaluated as the image.
119
+ # @return [Gosu::Image]
120
+ def paint(options = {}, &block)
121
+ end
122
+
123
+ # Draw a series of connected lines.
124
+ #
125
+ # @param [Array<Number, TPPoint>] points Series of points (either [x1, y1, x2, y2, ...] or [point1, point2]).
126
+ # @option (see #rect)
127
+ # @option options [Boolean] :closed Whether the last point is linked to the first.
128
+ # @return [Gosu::Image]
129
+ def polyline(points, options = {})
130
+ end
131
+
132
+ # Draw a rectangle.
133
+ #
134
+ # @param [Number] x1 Top of the rectangle.
135
+ # @param [Number] y1 Left of the rectangle.
136
+ # @param [Number] x2 Right of the rectangle.
137
+ # @param [Number] y2 Bottom of the rectangle.
138
+ # @option (see #circle)
139
+ # @option options [Number] :thickness (1) Thickness of the line.
140
+ # @return [Gosu::Image]
141
+ def rect(x1, y1, x2, y2, options = {})
142
+ end
143
+ alias_method :box, :rect
144
+
145
+ # Set the colour of an individual pixel.
146
+ #
147
+ # @param [Number] x
148
+ # @param [Number] y
149
+ # @option (see #fill)
150
+ # @option options [Boolean] :alpha_blend (false) Alpha-blend instead of overwrite.
151
+ # @option options [Gosu::Image] :texture Texture to use instead of a flat colour.
152
+ # @option options [Symbol] :mode (:copy) Drawing mode to use.
153
+ # @return [Gosu::Image]
154
+ def set_pixel(x, y, options = {})
155
+ end
156
+ alias_method :pixel, :set_pixel
157
+
158
+ # Copy an image into another image.
159
+ #
160
+ # @param [Number] x Horizontal position to splice at.
161
+ # @param [Number] y Vertical position to splice at.
162
+ # @param [Gosu::Image] source Image to copy from.
163
+ # @option options [Gosu::Color, Array<Float>, Symbol] :chroma_key Colour to treat as transparent (only other colour pixels will be spliced).
164
+ # @option options [Gosu::Color, Array<Float>, Symbol] :chroma_key_not Colour to copy (other colours won't be spliced).
165
+ # @option options [Array<Float>] :crop ([0, 0, source.width - 1, source.height - 1]) Area of the source image to splice.
166
+ # @return [Gosu::Image]
167
+ def splice(x, y, source, options = {})
168
+ end
169
+ alias_method :composite, :splice
170
+
171
+ # Generate binary data from the image.
172
+ #
173
+ # @note This method is usually overridden by the default Gosu::Image#to_blob.
174
+ # @note This method causes a segmentation fault in Windows.
175
+ # @return [String] Raw binary data (blob) in RGBA byte order.
176
+ def to_blob
177
+ end
178
+ end
@@ -0,0 +1,84 @@
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require "#{direc}/../texplay"
4
+ require 'pry'
5
+
6
+ WIDTH = 640
7
+ HEIGHT = 480
8
+
9
+ class Gosu::Image
10
+ attr_accessor :x, :y
11
+
12
+ alias_method :orig_init, :initialize
13
+ def initialize(*args)
14
+ @x = WIDTH / 2
15
+ @y = HEIGHT / 2
16
+ orig_init(*args)
17
+ end
18
+ end
19
+
20
+ class WinClass < Gosu::Window
21
+
22
+ class View
23
+ attr_accessor :zoom, :rotate
24
+
25
+ def initialize
26
+ @zoom = 1
27
+ @rotate = 0
28
+ end
29
+
30
+ def reset
31
+ @zoom = 1
32
+ @rotate = 0
33
+ end
34
+ end
35
+
36
+ attr_reader :images, :view
37
+
38
+ def initialize
39
+ super(WIDTH, HEIGHT, false)
40
+ Gosu.enable_undocumented_retrofication
41
+
42
+ @images = []
43
+ @view = View.new
44
+ @pry_instance = Pry.new :prompt => [Proc.new { "(live)> " }, Proc.new { "(live)* " }]
45
+
46
+ @img = TexPlay.create_image(self, 200, 200)
47
+ @img.rect 0, 0, @img.width - 1, @img.height - 1
48
+
49
+ images << @img
50
+ @binding = binding
51
+ end
52
+
53
+ def create_image(width, height, options={})
54
+ TexPlay.create_image(self, width, height, options)
55
+ end
56
+
57
+ def load_image(file)
58
+ Gosu::Image.new(self, file)
59
+ end
60
+
61
+ def show_image(image)
62
+ images << image
63
+ end
64
+
65
+ def hide_image(image)
66
+ images.delete(image)
67
+ end
68
+
69
+ def draw
70
+ images.uniq!
71
+ images.each do |v|
72
+ v.draw_rot(v.x, v.y, 1, view.rotate, 0.5, 0.5, view.zoom, view.zoom)
73
+ end
74
+ end
75
+
76
+ def update
77
+ @pry_instance.rep(@binding)
78
+ end
79
+ end
80
+
81
+ w = WinClass.new
82
+
83
+ w.show
84
+
@@ -0,0 +1,3 @@
1
+ module TexPlay
2
+ VERSION = "0.4.3"
3
+ end
@@ -0,0 +1,85 @@
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require "#{direc}/../lib/texplay"
5
+ require 'pry'
6
+
7
+ WIDTH = 640
8
+ HEIGHT = 480
9
+
10
+ class Gosu::Image
11
+ attr_accessor :x, :y
12
+
13
+ alias_method :orig_init, :initialize
14
+ def initialize(*args)
15
+ @x = WIDTH / 2
16
+ @y = HEIGHT / 2
17
+ orig_init(*args)
18
+ end
19
+ end
20
+
21
+ class WinClass < Gosu::Window
22
+
23
+ class View
24
+ attr_accessor :zoom, :rotate
25
+
26
+ def initialize
27
+ @zoom = 1
28
+ @rotate = 0
29
+ end
30
+
31
+ def reset
32
+ @zoom = 1
33
+ @rotate = 0
34
+ end
35
+ end
36
+
37
+ attr_reader :images, :view
38
+
39
+ def initialize
40
+ super(WIDTH, HEIGHT, false)
41
+ Gosu.enable_undocumented_retrofication
42
+
43
+ @images = []
44
+ @view = View.new
45
+ @pry_instance = Pry.new :prompt => [Proc.new { "(live)> " }, Proc.new { "(live)* " }]
46
+
47
+ @img = TexPlay.create_image(self, 200, 200)
48
+ @img.rect 0, 0, @img.width - 1, @img.height - 1
49
+
50
+ images << @img
51
+ @binding = binding
52
+ end
53
+
54
+ def create_image(width, height, options={})
55
+ TexPlay.create_image(self, width, height, options)
56
+ end
57
+
58
+ def load_image(file)
59
+ Gosu::Image.new(self, file)
60
+ end
61
+
62
+ def show_image(image)
63
+ images << image
64
+ end
65
+
66
+ def hide_image(image)
67
+ images.delete(image)
68
+ end
69
+
70
+ def draw
71
+ images.uniq!
72
+ images.each do |v|
73
+ v.draw_rot(v.x, v.y, 1, view.rotate, 0.5, 0.5, view.zoom, view.zoom)
74
+ end
75
+ end
76
+
77
+ def update
78
+ @pry_instance.rep(@binding)
79
+ end
80
+ end
81
+
82
+ w = WinClass.new
83
+
84
+ w.show
85
+
@@ -0,0 +1,45 @@
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require "#{direc}/../lib/texplay"
4
+
5
+ class Module
6
+ public :remove_const
7
+ end
8
+
9
+ describe Gosu::Image do
10
+ before do
11
+ @window = Gosu::Window.new(640, 480, false)
12
+ NormalImageSize = [Gosu::MAX_TEXTURE_SIZE - 2, Gosu::MAX_TEXTURE_SIZE - 2]
13
+ TooLargeImageSize = [2000, 2000]
14
+ end
15
+
16
+ after do
17
+ Object.remove_const(:NormalImageSize)
18
+ Object.remove_const(:TooLargeImageSize)
19
+ end
20
+
21
+ describe "Gosu::Image#new (patched by TexPlay)" do
22
+ describe "caching option" do
23
+ it "should not cache image if :caching => false" do
24
+ source_image = TexPlay.create_image(@window, *NormalImageSize)
25
+ source_image.quad_cached?.should == false
26
+
27
+ image = Gosu::Image.new(@window, source_image, :caching => false)
28
+ image.width.should == NormalImageSize[0]
29
+ image.height.should == NormalImageSize[1]
30
+
31
+ image.quad_cached?.should == false
32
+ end
33
+
34
+ it "should cache the image if :caching => true" do
35
+ source_image = TexPlay.create_image(@window, *NormalImageSize)
36
+
37
+ image = Gosu::Image.new(@window, source_image, :caching => true)
38
+ image.width.should == NormalImageSize[0]
39
+ image.height.should == NormalImageSize[1]
40
+
41
+ image.quad_cached?.should == true
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,144 @@
1
+ $LOAD_PATH.unshift File.join(File.expand_path(__FILE__), '..', 'lib','texplay')
2
+ direc = File.dirname(__FILE__)
3
+
4
+ require "#{direc}/../lib/texplay"
5
+
6
+ describe TexPlay do
7
+ described_class = TexPlay
8
+
9
+ before do
10
+ @window = Gosu::Window.new(640, 480, false)
11
+ end
12
+
13
+ describe "#create_image" do
14
+ it "should create a blank image of the correct size" do
15
+ width, height = 30, 10
16
+ image = described_class.create_image(@window, width, height)
17
+
18
+ image.width.should == width
19
+ image.height.should == height
20
+
21
+ width.times do |x|
22
+ height.times do |y|
23
+ image.get_pixel(x, y).should == [0.0, 0.0, 0.0, 0.0]
24
+ end
25
+ end
26
+ end
27
+
28
+ it "should create a coloured image of the correct size" do
29
+ width, height = 10, 30
30
+ color = [1.0, 1.0, 0.0, 1.0]
31
+ image = described_class.create_image(@window, width, height, :color => color)
32
+
33
+ image.width.should == width
34
+ image.height.should == height
35
+
36
+ width.times do |x|
37
+ height.times do |y|
38
+ image.get_pixel(x, y).should == color
39
+ end
40
+ end
41
+ end
42
+
43
+ it "should raise an error if an image dimension is 0 or less" do
44
+ lambda { described_class.create_image(@window, 0, 0)}.should raise_error(ArgumentError)
45
+ end
46
+
47
+ # TODO: Should probably be an ArgumentError.
48
+ it "should raise an ArgumentError if the image would be too large" do
49
+ too_big = TexPlay::TP_MAX_QUAD_SIZE + 1
50
+ [[too_big, 5], [10, too_big], [too_big, too_big]].each do |width, height|
51
+ puts "WIDTH: #{width.inspect}, HEIGHT: #{height.inspect}"
52
+ lambda {
53
+ described_class.create_image(@window, width, height)
54
+ }.should raise_error(ArgumentError)
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "#clear" do
60
+ it "should clear an image to the correct color" do
61
+ img = described_class.create_image(@window, 10, 10)
62
+ img.clear :color => :red
63
+ (0...img.width).each do |x|
64
+ (0...img.height).each do |y|
65
+ img.get_pixel(x,y).should == [1,0,0,1]
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ describe "#from_blob" do
72
+ # it "should create an image with the requested pixel data and size" do
73
+ # # 4 x 3, with columns of red, blue, green, transparent.
74
+ # gosu_colors = [[255, 0, 0, 255], [0, 255, 0, 255], [0, 0, 255, 255], [0, 0, 0, 0]]
75
+ # texplay_colors = gosu_colors.map {|a| a.map {|c| c / 255.0 } }
76
+ # width, height = gosu_colors.size, 3
77
+
78
+ # image = described_class.from_blob(@window, (gosu_colors * height).flatten.pack('C*'), width, height)
79
+
80
+ # image.width.should == width
81
+ # image.height.should == height
82
+
83
+ # texplay_colors.each_with_index do |color, x|
84
+ # 3.times do |y|
85
+ # image.get_pixel(x, y).should == color
86
+ # end
87
+ # end
88
+ # end
89
+
90
+ it "should raise an error if the image size is not correct for the blob data" do
91
+ lambda { described_class.from_blob(@window, [1, 1, 1, 1].pack("C*"), 2, 1) }.should raise_error(ArgumentError)
92
+ end
93
+
94
+ it "should raise an error if an image dimension is 0 or less" do
95
+ lambda { described_class.from_blob(@window, '', 0, 0) }.should raise_error(ArgumentError)
96
+ end
97
+ end
98
+
99
+ describe "alpha_blend" do
100
+ it "should alpha blend using source alpha and not fixing alpha" do
101
+ img1 = described_class.create_image(@window, 10, 10).clear :color => [1, 0, 0, 1]
102
+ img1.clear :color => [0, 0, 1, 0.5], :alpha_blend => :source
103
+ img1.get_pixel(5, 5).should == [0.5, 0, 0.5, 0.75]
104
+ end
105
+
106
+ it "hash params true and :source should be equivalent" do
107
+ img1 = described_class.create_image(@window, 10, 10).clear :color => [1, 0, 0, 1]
108
+ img2 = img1.dup
109
+ img1.clear :color => [0, 0, 1, 0.5], :alpha_blend => :source
110
+ img2.clear :color => [0, 0, 1, 0.5], :alpha_blend => true
111
+
112
+ img1.get_pixel(5, 5).should == [0.5, 0, 0.5, 0.75]
113
+ img2.get_pixel(5, 5).should == [0.5, 0, 0.5, 0.75]
114
+ end
115
+
116
+ it "false or nil should prevent alpha blending" do
117
+ img1 = described_class.create_image(@window, 10, 10).clear :color => [1, 0, 0, 1]
118
+ img2 = img1.dup
119
+ img1.clear :color => [0, 0, 1, 0.5], :alpha_blend => false
120
+ img2.clear :color => [0, 0, 1, 0.5], :alpha_blend => nil
121
+
122
+ img1.get_pixel(5, 5).should == [0, 0, 1, 0.5]
123
+ img2.get_pixel(5, 5).should == [0, 0, 1, 0.5]
124
+ end
125
+
126
+ it "should alpha blend using dest alpha and not fixing alpha" do
127
+ img1 = described_class.create_image(@window, 10, 10).clear :color => [1, 0, 0, 0.5]
128
+ img1.clear :color => [0, 0, 1, 1], :alpha_blend => :dest
129
+ img1.get_pixel(5, 5).should == [0.5, 0, 0.5, 0.75]
130
+ end
131
+
132
+ it "should alpha blend using source alpha and fixing alpha" do
133
+ img1 = described_class.create_image(@window, 10, 10).clear :color => [1, 0, 0, 1]
134
+ img1.clear :color => [0, 0, 1, 0.5], :alpha_blend => :source_with_fixed_alpha
135
+ img1.get_pixel(5, 5).should == [0.5, 0, 0.5, 1]
136
+ end
137
+
138
+ it "should alpha blend using dest alpha and fixing alpha" do
139
+ img1 = described_class.create_image(@window, 10, 10).clear :color => [1, 0, 0, 0.5]
140
+ img1.clear :color => [0, 0, 1, 1], :alpha_blend => :dest_with_fixed_alpha
141
+ img1.get_pixel(5, 5).should == [0.5, 0, 0.5, 0.5]
142
+ end
143
+ end
144
+ end