texplay 0.2.800 → 0.2.900
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +138 -119
- data/README.markdown +43 -41
- data/Rakefile +68 -68
- data/examples/common.rb +8 -8
- data/examples/example_alpha_blend.rb +31 -31
- data/examples/example_bezier.rb +42 -42
- data/examples/example_color_control.rb +69 -69
- data/examples/example_color_transform.rb +64 -67
- data/examples/example_color_transform_circle.rb +65 -0
- data/examples/example_dup.rb +75 -75
- data/examples/example_each.rb +42 -42
- data/examples/example_effect.rb +35 -35
- data/examples/example_fill.rb +44 -44
- data/examples/example_fill_old.rb +49 -49
- data/examples/example_fluent.rb +31 -31
- data/examples/example_gen_eval.rb +34 -34
- data/examples/example_hash_arguments.rb +47 -47
- data/examples/example_light.rb +77 -0
- data/examples/example_lsystem.rb +61 -61
- data/examples/example_melt.rb +27 -27
- data/examples/example_meyet.rb +64 -0
- data/examples/example_polyline.rb +43 -43
- data/examples/example_scale.rb +29 -29
- data/examples/example_simple.rb +48 -38
- data/examples/example_sync.rb +60 -60
- data/examples/example_trace.rb +1 -1
- data/examples/example_turtle.rb +40 -40
- data/examples/example_weird.rb +3 -1
- data/examples/media/Thumbs.db +0 -0
- data/ext/texplay/actions.c +999 -1001
- data/ext/texplay/actions.h +60 -60
- data/ext/texplay/bindings.c +1162 -1149
- data/ext/texplay/bindings.h +46 -46
- data/ext/texplay/cache.c +118 -118
- data/ext/texplay/cache.h +24 -24
- data/ext/texplay/compat.h +27 -27
- data/ext/texplay/extconf.rb +28 -28
- data/ext/texplay/gen_eval.c +211 -211
- data/ext/texplay/gen_eval.h +20 -20
- data/ext/texplay/graphics_utils.c +188 -63
- data/ext/texplay/graphics_utils.h +0 -1
- data/ext/texplay/object2module.c +171 -171
- data/ext/texplay/object2module.h +11 -11
- data/ext/texplay/texplay.c +169 -169
- data/ext/texplay/texplay.h +147 -130
- data/ext/texplay/utils.c +816 -752
- data/ext/texplay/utils.h +151 -145
- data/lib/texplay-contrib.rb +171 -171
- data/lib/texplay.rb +162 -137
- data/lib/texplay/version.rb +1 -1
- metadata +9 -5
data/lib/texplay.rb
CHANGED
@@ -1,137 +1,162 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
require '
|
13
|
-
require
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@__init_procs__
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
require "#{direc}/texplay
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
1
|
+
|
2
|
+
# (C) John Mair 2009, under the MIT licence
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
|
9
|
+
direc = File.dirname(__FILE__)
|
10
|
+
|
11
|
+
# include gosu first
|
12
|
+
require 'rbconfig'
|
13
|
+
require 'gosu'
|
14
|
+
require "#{direc}/texplay/version"
|
15
|
+
|
16
|
+
module TexPlay
|
17
|
+
class << self
|
18
|
+
def on_setup(&block)
|
19
|
+
raise "need a block" if !block
|
20
|
+
|
21
|
+
@__init_procs__ ||= []
|
22
|
+
@__init_procs__.push(block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup(receiver)
|
26
|
+
if @__init_procs__ then
|
27
|
+
@__init_procs__.each do |init_proc|
|
28
|
+
receiver.instance_eval(&init_proc)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_blank_image(window, width, height, options={})
|
34
|
+
options = { :color => [0, 0, 0, 0] }.merge!(options)
|
35
|
+
|
36
|
+
img = Gosu::Image.new(window, EmptyImageStub.new(width, height))
|
37
|
+
img.rect 0, 0, img.width - 1, img.height - 1, :color => options[:color], :fill => true
|
38
|
+
|
39
|
+
img
|
40
|
+
end
|
41
|
+
|
42
|
+
alias_method :create_image, :create_blank_image
|
43
|
+
end
|
44
|
+
|
45
|
+
module Colors
|
46
|
+
Red = [1, 0, 0, 1]
|
47
|
+
Green = [0, 1, 0, 1]
|
48
|
+
Blue = [0, 0, 1, 1]
|
49
|
+
Black = [0, 0, 0, 1]
|
50
|
+
White = [1, 1, 1, 1]
|
51
|
+
Grey = [0.5, 0.5, 0.5, 1]
|
52
|
+
Alpha = [0, 0, 0, 0]
|
53
|
+
Purple = [1, 0, 1, 1]
|
54
|
+
Yellow = [1, 1, 0, 1]
|
55
|
+
Cyan = [0, 1, 1, 1]
|
56
|
+
Orange = [1, 0.5, 0, 1]
|
57
|
+
Brown = [0.39, 0.26, 0.13, 1]
|
58
|
+
Turquoise = [1, 0.6, 0.8, 1]
|
59
|
+
Tyrian = [0.4, 0.007, 0.235, 1]
|
60
|
+
end
|
61
|
+
include Colors
|
62
|
+
end
|
63
|
+
|
64
|
+
# credit to philomory for this class
|
65
|
+
class EmptyImageStub
|
66
|
+
def initialize(w, h)
|
67
|
+
@w, @h = w, h
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_blob
|
71
|
+
"\0" * @w * @h * 4
|
72
|
+
end
|
73
|
+
|
74
|
+
def rows
|
75
|
+
@h
|
76
|
+
end
|
77
|
+
|
78
|
+
def columns
|
79
|
+
@w
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# bring in user-defined extensions to TexPlay
|
84
|
+
direc = File.dirname(__FILE__)
|
85
|
+
dlext = Config::CONFIG['DLEXT']
|
86
|
+
begin
|
87
|
+
if RUBY_VERSION && RUBY_VERSION =~ /1.9/
|
88
|
+
require "#{direc}/1.9/texplay.#{dlext}"
|
89
|
+
else
|
90
|
+
require "#{direc}/1.8/texplay.#{dlext}"
|
91
|
+
end
|
92
|
+
rescue LoadError => e
|
93
|
+
require "#{direc}/texplay.#{dlext}"
|
94
|
+
end
|
95
|
+
|
96
|
+
require "#{direc}/texplay-contrib"
|
97
|
+
|
98
|
+
# monkey patching the Gosu::Image class to add image manipulation functionality
|
99
|
+
module Gosu
|
100
|
+
class Image
|
101
|
+
|
102
|
+
# bring in the TexPlay image manipulation methods
|
103
|
+
include TexPlay
|
104
|
+
|
105
|
+
attr_reader :__window__
|
106
|
+
|
107
|
+
class << self
|
108
|
+
alias_method :original_new, :new
|
109
|
+
|
110
|
+
def new(*args, &block)
|
111
|
+
|
112
|
+
# invoke old behaviour
|
113
|
+
obj = original_new(*args, &block)
|
114
|
+
|
115
|
+
prepare_image(*args, obj)
|
116
|
+
end
|
117
|
+
|
118
|
+
alias_method :original_from_text, :from_text
|
119
|
+
|
120
|
+
def from_text(*args, &block)
|
121
|
+
|
122
|
+
# invoke old behaviour
|
123
|
+
obj = original_from_text(*args, &block)
|
124
|
+
|
125
|
+
prepare_image(*args, obj)
|
126
|
+
end
|
127
|
+
|
128
|
+
def prepare_image(*args, obj)
|
129
|
+
|
130
|
+
# refresh the TexPlay image cache
|
131
|
+
if obj.width <= (TexPlay::TP_MAX_QUAD_SIZE) &&
|
132
|
+
obj.height <= (TexPlay::TP_MAX_QUAD_SIZE) && obj.quad_cached? then
|
133
|
+
|
134
|
+
obj.refresh_cache
|
135
|
+
end
|
136
|
+
|
137
|
+
# run custom setup
|
138
|
+
TexPlay.setup(obj)
|
139
|
+
|
140
|
+
obj.instance_variable_set(:@__window__, args.first)
|
141
|
+
|
142
|
+
obj
|
143
|
+
end
|
144
|
+
|
145
|
+
private :prepare_image
|
146
|
+
end
|
147
|
+
|
148
|
+
alias_method :rows, :height
|
149
|
+
alias_method :columns, :width
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# a bug in ruby 1.8.6 rb_eval_string() means i must define this here (rather than in texplay.c)
|
154
|
+
class Proc
|
155
|
+
def __context__
|
156
|
+
eval('self', self.binding)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
data/lib/texplay/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 900
|
9
|
+
version: 0.2.900
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- John Mair (banisterfiend)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-07 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,8 +27,8 @@ dependencies:
|
|
27
27
|
segments:
|
28
28
|
- 0
|
29
29
|
- 7
|
30
|
-
-
|
31
|
-
version: 0.7.
|
30
|
+
- 20
|
31
|
+
version: 0.7.20
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
description: TexPlay is a light-weight image manipulation framework for Ruby and Gosu
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- examples/example_bezier.rb
|
70
70
|
- examples/example_color_control.rb
|
71
71
|
- examples/example_color_transform.rb
|
72
|
+
- examples/example_color_transform_circle.rb
|
72
73
|
- examples/example_dup.rb
|
73
74
|
- examples/example_each.rb
|
74
75
|
- examples/example_effect.rb
|
@@ -77,8 +78,10 @@ files:
|
|
77
78
|
- examples/example_fluent.rb
|
78
79
|
- examples/example_gen_eval.rb
|
79
80
|
- examples/example_hash_arguments.rb
|
81
|
+
- examples/example_light.rb
|
80
82
|
- examples/example_lsystem.rb
|
81
83
|
- examples/example_melt.rb
|
84
|
+
- examples/example_meyet.rb
|
82
85
|
- examples/example_polyline.rb
|
83
86
|
- examples/example_scale.rb
|
84
87
|
- examples/example_simple.rb
|
@@ -98,6 +101,7 @@ files:
|
|
98
101
|
- examples/media/sand1.png
|
99
102
|
- examples/media/sunset.png
|
100
103
|
- examples/media/texplay.png
|
104
|
+
- examples/media/Thumbs.db
|
101
105
|
has_rdoc: true
|
102
106
|
homepage: http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
|
103
107
|
licenses: []
|