texplay 0.2.975-i386-mswin32 → 0.2.980-i386-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +8 -0
- data/README.markdown +1 -1
- data/examples/example_cache.rb +23 -0
- data/examples/example_color_transform_circle.rb +18 -43
- data/examples/example_tiles.rb +43 -0
- data/examples/media/body.png +0 -0
- data/examples/media/face.png +0 -0
- data/lib/1.8/texplay.so +0 -0
- data/lib/1.9/texplay.so +0 -0
- data/lib/texplay.rb +60 -15
- data/lib/texplay/version.rb +1 -1
- metadata +8 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
16/8/10
|
2
|
+
version 0.2.980
|
3
|
+
* added :caching option to TexPlay.set_options, and Gosu::Image.new. For
|
4
|
+
control over whether images are cached or not. (accepts true and
|
5
|
+
false values)
|
6
|
+
* TexPlay.create_image() no longer calls refresh_cache
|
7
|
+
* added new TexPlay#clear() method, just draws a filled rect over image.
|
8
|
+
|
1
9
|
14/8/10
|
2
10
|
version 0.2.975
|
3
11
|
* fixed :tolerance bug (was in special_cmp_color_with_tolerance, was checking color1.alpha <= tolerance instead of color2.alpha <= tolerance)
|
data/README.markdown
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'common'
|
3
|
+
require 'gosu'
|
4
|
+
require 'texplay'
|
5
|
+
|
6
|
+
class W < Gosu::Window
|
7
|
+
def initialize
|
8
|
+
super(400, 300, false, 20)
|
9
|
+
TexPlay.set_options :caching => true
|
10
|
+
@img = Gosu::Image.new(self, "#{Common::MEDIA}/object.png", :caching => false)
|
11
|
+
|
12
|
+
@img.clear :color => :red, :dest_select => :transparent, :tolerance => 0.9
|
13
|
+
end
|
14
|
+
|
15
|
+
def draw
|
16
|
+
@img.draw 100, 100, 1
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
w = W.new
|
23
|
+
w.show
|
@@ -2,55 +2,17 @@ require 'rubygems'
|
|
2
2
|
require 'common'
|
3
3
|
require 'gosu'
|
4
4
|
require 'texplay'
|
5
|
-
#require 'devil/gosu'
|
6
5
|
|
7
6
|
class W < Gosu::Window
|
8
7
|
def initialize
|
9
|
-
super(500,
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
|
14
|
-
@x2 = 400
|
15
|
-
@y2 = 100
|
16
|
-
@rad = 70
|
17
|
-
@s = true
|
18
|
-
|
19
|
-
@copy = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
|
20
|
-
@copy2 = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
|
8
|
+
super(500, 300, false, 20)
|
9
|
+
@spritesheet = Gosu::Image.new(self, "body.png", false)
|
10
|
+
@spritesheet.splice(Gosu::Image.new(self, "face.png", false), 0,0, :alpha_blend => true)
|
11
|
+
@sprite_array = Gosu::Image::load_tiles(self, @spritesheet, 40, 80, false)
|
21
12
|
end
|
22
13
|
|
23
14
|
def draw
|
24
|
-
|
25
|
-
|
26
|
-
@x += 3
|
27
|
-
@y += 3
|
28
|
-
|
29
|
-
@x2 -= 3
|
30
|
-
@y2 += 3
|
31
|
-
|
32
|
-
@copy2.splice @img, 0, 0, :crop => [@x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad], :sync_mode => :no_sync
|
33
|
-
@copy.splice @img, 0, 0, :crop => [@x - @rad, @y - @rad, @x + @rad, @y + @rad], :sync_mode => :no_sync
|
34
|
-
|
35
|
-
@img.circle @x, @y, @rad, :fill => true, :mode => :overlay, :color => :red
|
36
|
-
|
37
|
-
@img.rect @x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad, :fill => true, :mode => :overlay, :color => :blue
|
38
|
-
|
39
|
-
# @img.force_sync [0,0, @img.width, @img.height]
|
40
|
-
|
41
|
-
@img.draw 10, 10,1
|
42
|
-
|
43
|
-
if button_down?(Gosu::KbEscape)
|
44
|
-
exit
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def update
|
50
|
-
@img.splice @copy, @x - @rad, @y - @rad if !@s
|
51
|
-
@img.splice @copy2, @x2 - @rad, @y2 - @rad if !@s
|
52
|
-
@s = nil if @s
|
53
|
-
|
15
|
+
@sprite_array[0].draw(200,200,0)
|
54
16
|
end
|
55
17
|
|
56
18
|
end
|
@@ -59,3 +21,16 @@ end
|
|
59
21
|
w = W.new
|
60
22
|
w.show
|
61
23
|
|
24
|
+
|
25
|
+
# require 'rubygems'
|
26
|
+
# require 'gosu'
|
27
|
+
# require 'texplay'
|
28
|
+
# class Game_Window < Gosu::Window
|
29
|
+
# def initialize
|
30
|
+
# super(500, 400, false)
|
31
|
+
# self.caption = "Image Test"
|
32
|
+
# end
|
33
|
+
|
34
|
+
# def draw
|
35
|
+
# end
|
36
|
+
# end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'common'
|
3
|
+
require 'gosu'
|
4
|
+
require 'texplay'
|
5
|
+
|
6
|
+
class Gosu::Image
|
7
|
+
# so we can use the old TexPlay to_blob -- appears to segfault?!
|
8
|
+
remove_method :to_blob
|
9
|
+
end
|
10
|
+
|
11
|
+
class W < Gosu::Window
|
12
|
+
def initialize
|
13
|
+
super(500, 300, false, 20)
|
14
|
+
@spritesheet = Gosu::Image.new(self, "#{Common::MEDIA}/body.png", false)
|
15
|
+
@spritesheet.splice(Gosu::Image.new(self, "#{Common::MEDIA}/face.png", false), 0,0, :alpha_blend => true)
|
16
|
+
@sprite_array = Gosu::Image::load_tiles(self, @spritesheet, 40, 80, false)
|
17
|
+
end
|
18
|
+
|
19
|
+
def draw
|
20
|
+
@spritesheet.draw(200,200,0)
|
21
|
+
# @sprite_array[0].draw(200,200,0)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
w = W.new
|
28
|
+
w.show
|
29
|
+
|
30
|
+
|
31
|
+
# require 'rubygems'
|
32
|
+
# require 'gosu'
|
33
|
+
# require 'texplay'
|
34
|
+
# class Game_Window < Gosu::Window
|
35
|
+
# def initialize
|
36
|
+
# super(500, 400, false)
|
37
|
+
# self.caption = "Image Test"
|
38
|
+
# end
|
39
|
+
|
40
|
+
# def draw
|
41
|
+
# end
|
42
|
+
|
43
|
+
# end
|
Binary file
|
Binary file
|
data/lib/1.8/texplay.so
CHANGED
Binary file
|
data/lib/1.9/texplay.so
CHANGED
Binary file
|
data/lib/texplay.rb
CHANGED
@@ -30,15 +30,38 @@ module TexPlay
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def create_image(window, width, height, options={})
|
34
|
+
options = {
|
35
|
+
:color => :alpha,
|
36
|
+
:caching => false,
|
37
|
+
}.merge!(options)
|
34
38
|
|
35
|
-
img = Gosu::Image.new(window, EmptyImageStub.new(width, height))
|
36
|
-
img.rect 0, 0, img.width - 1, img.height - 1, :color => options[:color], :fill => true
|
39
|
+
img = Gosu::Image.new(window, EmptyImageStub.new(width, height), :caching => options[:caching])
|
40
|
+
img.rect 0, 0, img.width - 1, img.height - 1, :color => options[:color], :fill => true
|
37
41
|
|
38
42
|
img
|
39
43
|
end
|
40
44
|
|
41
|
-
alias_method :
|
45
|
+
alias_method :create_blank_image, :create_image
|
46
|
+
|
47
|
+
def set_options(options = {})
|
48
|
+
@options.merge!(options)
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_options
|
52
|
+
@options
|
53
|
+
end
|
54
|
+
|
55
|
+
# default values defined here
|
56
|
+
def set_defaults
|
57
|
+
@options = {
|
58
|
+
:caching => true
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
def init
|
63
|
+
set_defaults
|
64
|
+
end
|
42
65
|
end
|
43
66
|
|
44
67
|
module Colors
|
@@ -58,6 +81,23 @@ module TexPlay
|
|
58
81
|
Tyrian = [0.4, 0.007, 0.235, 1]
|
59
82
|
end
|
60
83
|
include Colors
|
84
|
+
|
85
|
+
# extra instance methods defined in Ruby
|
86
|
+
|
87
|
+
# clear an image (with an optional clear color)
|
88
|
+
def clear(options = {})
|
89
|
+
options = {
|
90
|
+
:color => :alpha,
|
91
|
+
:fill => true
|
92
|
+
}.merge!(options)
|
93
|
+
|
94
|
+
capture {
|
95
|
+
rect 0, 0, width - 1, height - 1, options
|
96
|
+
}
|
97
|
+
|
98
|
+
self
|
99
|
+
end
|
100
|
+
|
61
101
|
end
|
62
102
|
|
63
103
|
# credit to philomory for this class
|
@@ -108,35 +148,39 @@ module Gosu
|
|
108
148
|
|
109
149
|
def new(*args, &block)
|
110
150
|
|
151
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
111
152
|
# invoke old behaviour
|
112
153
|
obj = original_new(*args, &block)
|
113
154
|
|
114
|
-
prepare_image(obj,
|
155
|
+
prepare_image(obj, args.first, options)
|
115
156
|
end
|
116
157
|
|
117
158
|
alias_method :original_from_text, :from_text
|
118
159
|
|
119
160
|
def from_text(*args, &block)
|
120
161
|
|
162
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
121
163
|
# invoke old behaviour
|
122
164
|
obj = original_from_text(*args, &block)
|
123
165
|
|
124
|
-
prepare_image(obj,
|
166
|
+
prepare_image(obj, args.first, options)
|
125
167
|
end
|
126
168
|
|
127
|
-
def prepare_image(obj,
|
128
|
-
|
169
|
+
def prepare_image(obj, window, options={})
|
170
|
+
options = {
|
171
|
+
:caching => TexPlay.get_options[:caching]
|
172
|
+
}.merge!(options)
|
173
|
+
|
129
174
|
# refresh the TexPlay image cache
|
130
175
|
if obj.width <= (TexPlay::TP_MAX_QUAD_SIZE) &&
|
131
|
-
|
132
|
-
|
133
|
-
obj.refresh_cache
|
176
|
+
obj.height <= (TexPlay::TP_MAX_QUAD_SIZE) && obj.quad_cached? then
|
177
|
+
obj.refresh_cache if options[:caching]
|
134
178
|
end
|
135
|
-
|
179
|
+
|
136
180
|
# run custom setup
|
137
181
|
TexPlay.setup(obj)
|
138
|
-
|
139
|
-
obj.instance_variable_set(:@__window__,
|
182
|
+
|
183
|
+
obj.instance_variable_set(:@__window__, window)
|
140
184
|
|
141
185
|
obj
|
142
186
|
end
|
@@ -157,5 +201,6 @@ class Proc
|
|
157
201
|
end
|
158
202
|
|
159
203
|
|
160
|
-
|
204
|
+
# initialize TP (at the moment just setting some default settings)
|
205
|
+
TexPlay.init
|
161
206
|
|
data/lib/texplay/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: texplay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1983
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 980
|
10
|
+
version: 0.2.980
|
11
11
|
platform: i386-mswin32
|
12
12
|
authors:
|
13
13
|
- John Mair (banisterfiend)
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-16 00:00:00 +12:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- examples/example_alpha_blend.rb
|
56
56
|
- examples/example_bezier.rb
|
57
57
|
- examples/example_blank.rb
|
58
|
+
- examples/example_cache.rb
|
58
59
|
- examples/example_color_control.rb
|
59
60
|
- examples/example_color_transform.rb
|
60
61
|
- examples/example_color_transform_circle.rb
|
@@ -80,6 +81,7 @@ files:
|
|
80
81
|
- examples/example_simple.rb
|
81
82
|
- examples/example_splice.rb
|
82
83
|
- examples/example_sync.rb
|
84
|
+
- examples/example_tiles.rb
|
83
85
|
- examples/example_trace.rb
|
84
86
|
- examples/example_transparent.rb
|
85
87
|
- examples/example_transparent2.rb
|
@@ -87,7 +89,9 @@ files:
|
|
87
89
|
- examples/example_turtle.rb
|
88
90
|
- examples/example_weird.rb
|
89
91
|
- examples/media/bird.png
|
92
|
+
- examples/media/body.png
|
90
93
|
- examples/media/empty2.png
|
94
|
+
- examples/media/face.png
|
91
95
|
- examples/media/gob.png
|
92
96
|
- examples/media/gosu.png
|
93
97
|
- examples/media/green.png
|