texplay 0.2.710 → 0.2.722
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 +4 -0
- data/README.markdown +0 -0
- data/Rakefile +31 -25
- data/examples/example_color_transform.rb +3 -3
- data/examples/example_lsystem.rb +3 -3
- data/examples/example_splice.rb +27 -33
- data/examples/example_weird.rb +29 -0
- data/examples/media/bird.png +0 -0
- data/examples/media/gob.png +0 -0
- data/examples/media/green.png +0 -0
- data/examples/media/maria.png +0 -0
- data/examples/media/rose.bmp +0 -0
- data/ext/texplay/actions.c +13 -419
- data/ext/texplay/bindings.c +1 -0
- data/ext/texplay/extconf.rb +3 -5
- data/ext/texplay/gen_eval.c +0 -0
- data/ext/texplay/gen_eval.h +0 -0
- data/ext/texplay/graphics_utils.c +660 -0
- data/ext/texplay/graphics_utils.h +23 -0
- data/ext/texplay/utils.c +35 -258
- data/ext/texplay/utils.h +2 -2
- data/lib/texplay-contrib.rb +0 -0
- data/lib/texplay.rb +0 -0
- data/lib/texplay/version.rb +1 -1
- metadata +58 -44
- data/examples/example_blur.rb +0 -59
- data/examples/example_fill_test.rb +0 -106
- data/examples/example_modify.rb +0 -40
- data/examples/example_sine.rb +0 -55
- data/examples/media/platform.png +0 -0
data/examples/example_blur.rb
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'common'
|
|
3
|
-
require 'gosu'
|
|
4
|
-
require 'texplay'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class W < Gosu::Window
|
|
8
|
-
def initialize
|
|
9
|
-
super(1024, 768, false, 20)
|
|
10
|
-
@img = Gosu::Image.new(self, "#{Common::MEDIA}/logo.png")
|
|
11
|
-
#@img.rect 0,0, @img.width - 1, @img.height - 1
|
|
12
|
-
@img2 = TexPlay::create_blank_image(self, @img.width, @img.height)
|
|
13
|
-
@img2.rect 0,0, 1000, 100, :fill => true
|
|
14
|
-
|
|
15
|
-
TexPlay::create_macro(:blur) do |*options|
|
|
16
|
-
options = options.first ? options.first : {}
|
|
17
|
-
|
|
18
|
-
radius = options[:blur_radius] || 1
|
|
19
|
-
|
|
20
|
-
self.each(options) { |c,x,y|
|
|
21
|
-
total = [0, 0, 0, 0]
|
|
22
|
-
for ky in (-radius..radius)
|
|
23
|
-
for kx in (-radius..radius)
|
|
24
|
-
v = get_pixel(x + kx, y + ky);
|
|
25
|
-
if v
|
|
26
|
-
total[0] += v[0]
|
|
27
|
-
total[1] += v[1]
|
|
28
|
-
total[2] += v[2]
|
|
29
|
-
total[3] += v[3]
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
c[0] = total[0] / (radius * 2 + 1) ** 2
|
|
35
|
-
c[1] = total[1] / (radius * 2 + 1) ** 2
|
|
36
|
-
c[2] = total[2] / (radius * 2 + 1) ** 2
|
|
37
|
-
c[3] = total[3] / (radius * 2 + 1) ** 2
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
self
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
@img.blur :blur_radius => 4, :region => [0, 0, @img.width/2, @img.height]
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def draw
|
|
47
|
-
x = @img.width * rand
|
|
48
|
-
y = @img.height * rand
|
|
49
|
-
|
|
50
|
-
@img2.draw 100, 50,1
|
|
51
|
-
@img.draw 100, 50,1
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
w = W.new
|
|
58
|
-
w.show
|
|
59
|
-
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'common'
|
|
3
|
-
require 'texplay'
|
|
4
|
-
require 'devil/gosu'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class W < Gosu::Window
|
|
8
|
-
WIDTH = 1000
|
|
9
|
-
HEIGHT = 800
|
|
10
|
-
def initialize
|
|
11
|
-
super(1024, 768, false, 20)
|
|
12
|
-
@img = TexPlay::create_blank_image(self, WIDTH, HEIGHT)
|
|
13
|
-
@tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
|
|
14
|
-
@gosu = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
image = TexPlay::create_blank_image(self, WIDTH, HEIGHT)
|
|
18
|
-
image2 = TexPlay::create_blank_image(self, WIDTH, HEIGHT)
|
|
19
|
-
|
|
20
|
-
puts "..created blank!"
|
|
21
|
-
puts "..starting drawing!"
|
|
22
|
-
|
|
23
|
-
# now let's create the landscape
|
|
24
|
-
points = []
|
|
25
|
-
(0..WIDTH + 120).step(90) { |x|
|
|
26
|
-
p = TexPlay::TPPoint.new
|
|
27
|
-
p.x = x
|
|
28
|
-
p.y = HEIGHT - rand * 600
|
|
29
|
-
if p.y >= HEIGHT - 1
|
|
30
|
-
p.y = HEIGHT - 1
|
|
31
|
-
end
|
|
32
|
-
points << p
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
points.first.y = 600
|
|
36
|
-
points.last.x = WIDTH + 200
|
|
37
|
-
|
|
38
|
-
points.last.y = 600
|
|
39
|
-
|
|
40
|
-
mag = rand(50) + 10
|
|
41
|
-
rough = 2 + rand(20)
|
|
42
|
-
spike = 2 + rand(14)
|
|
43
|
-
period = 2 * rand + 0.2
|
|
44
|
-
image.move_to(points.first.x, points.first.y)
|
|
45
|
-
|
|
46
|
-
image.rect 200, 200, 300, 300, :color => :green, :fill => true
|
|
47
|
-
image.rect 300, 200, 400, 300, :color => :green, :fill => false
|
|
48
|
-
#image.line 200, 200, 300, 300, :color => :green, :fill => true#, :thickness => 3
|
|
49
|
-
# image.pixel 300,300, :color => :white
|
|
50
|
-
# image.line 200, 300, 300, 300, :color => :white, :sync_mode => :eager_sync
|
|
51
|
-
|
|
52
|
-
#
|
|
53
|
-
image.rect 0, 0, image.width - 1, image.height - 1, :color => :white
|
|
54
|
-
image.circle image.width, 0, 10, :color => :red, :fill => true
|
|
55
|
-
# image.rect 0, 400, image.width - 1, 600, :color => :green
|
|
56
|
-
|
|
57
|
-
# plain beziers are boring, so let's augment it with a randomized sine wave
|
|
58
|
-
image.bezier points, :color => :white, :color_control => proc { |c, t, y|
|
|
59
|
-
y += mag * Math::sin(t * period * Math::PI / 180)
|
|
60
|
-
if (t % rough == 0 ) then
|
|
61
|
-
image.line_to(t, y + rand * spike - (spike / 2), :texture => @gosu)
|
|
62
|
-
end
|
|
63
|
-
:none
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
#image.bezier [rand(500), 700, rand(100), 800, rand(800), 900, rand(300), 850 ], :closed => true
|
|
67
|
-
image.fill 300, 760, :color => :red #:texture => @gosu
|
|
68
|
-
image.rect 0,0, image.width - 1, image.height - 1, :fill => true, :color => :blue
|
|
69
|
-
image2.fill 300, 300, :color => :red
|
|
70
|
-
|
|
71
|
-
@img = image
|
|
72
|
-
@img2 = image2
|
|
73
|
-
# @img.circle 10, image.height / 2, 50, :color => :red, :fill => true
|
|
74
|
-
#@img.rect 0,100, 100, 200, :color => :red, :fill => true
|
|
75
|
-
#@img.line -1, 100, 100, 100, :color => :blue, :fill => true
|
|
76
|
-
|
|
77
|
-
# @img.line 0,100, 0, 200, :color => :red, :fill => true
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
# @img.force_sync [0,0, image.width, image.height]
|
|
81
|
-
# @img.rect -10, image.height / 2, 50, image.height / 2 + 50, :color => :red, :fill => true
|
|
82
|
-
# @img.line 0,0, 0, image.height - 1, :color => :red
|
|
83
|
-
|
|
84
|
-
@bunk = TexPlay.create_blank_image(self, 100, 100)
|
|
85
|
-
@bunk.circle 50, 50, 50, :color => :rand, :fill => true
|
|
86
|
-
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def draw
|
|
90
|
-
@img.draw 0, 600,1
|
|
91
|
-
@img2.draw 50, 600, 1
|
|
92
|
-
@bunk.draw 500, 500, 1
|
|
93
|
-
|
|
94
|
-
if button_down?(Gosu::KbEscape)
|
|
95
|
-
Devil.from_blob(self.to_blob, self.width, self.height).save("hello.jpg")
|
|
96
|
-
#screenshot.crop(100, 100, 500, 500).save("hello.jpg")
|
|
97
|
-
exit
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
w = W.new
|
|
105
|
-
w.show
|
|
106
|
-
|
data/examples/example_modify.rb
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'common'
|
|
3
|
-
require 'gosu'
|
|
4
|
-
require 'texplay'
|
|
5
|
-
require 'devil/gosu'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class W < Gosu::Window
|
|
9
|
-
def initialize
|
|
10
|
-
super(1024, 768, false, 20)
|
|
11
|
-
@img = Gosu::Image.new(self, "#{Common::MEDIA}/platform.png")
|
|
12
|
-
|
|
13
|
-
# each can accept a block of two types of arity:
|
|
14
|
-
# arity 1 - yields just the pixel color
|
|
15
|
-
# arity 3 - yield the pixel color, and the x and y
|
|
16
|
-
|
|
17
|
-
# max out the blue component of every pixel
|
|
18
|
-
@img.each { |v|
|
|
19
|
-
if v[0] > 0.7 && v[1] > 0.6 && v[2] < 0.6 then
|
|
20
|
-
v[1] = 0.0
|
|
21
|
-
v[2] = 0.0
|
|
22
|
-
end
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
#@img.save("/home/john/Desktop/red.png")
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def draw
|
|
31
|
-
|
|
32
|
-
@img.draw 100, 50,1
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
w = W.new
|
|
39
|
-
w.show
|
|
40
|
-
|
data/examples/example_sine.rb
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'common'
|
|
3
|
-
require 'texplay'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class W < Gosu::Window
|
|
7
|
-
NUM_WAVES = 10
|
|
8
|
-
|
|
9
|
-
def initialize
|
|
10
|
-
super(1024, 768, false, 20)
|
|
11
|
-
@img = TexPlay::create_blank_image(self, 1022, 800)
|
|
12
|
-
@tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
|
|
13
|
-
@gosu = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
|
|
14
|
-
|
|
15
|
-
points = []
|
|
16
|
-
|
|
17
|
-
# NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or y
|
|
18
|
-
# NOTE: current maximum points for a bezier is 13
|
|
19
|
-
(0..@img.width + 90).step(185) { |x|
|
|
20
|
-
p = TexPlay::TPPoint.new
|
|
21
|
-
p.x = x
|
|
22
|
-
p.y = @img.height * rand
|
|
23
|
-
|
|
24
|
-
points << p
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
waves = []
|
|
28
|
-
NUM_WAVES.times {
|
|
29
|
-
waves.push({ :amp => rand(100), :freq => rand(1000).to_f })
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@img.move_to 0, 300
|
|
33
|
-
(0..1100).step(10) { |x|
|
|
34
|
-
y = 300
|
|
35
|
-
waves.each { |w|
|
|
36
|
-
y += w[:amp] * Math::sin((x / w[:freq]) * Math::PI * 2)
|
|
37
|
-
}
|
|
38
|
-
@img.line_to(x, y)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
# NOTE: the :texture hash argument works on ALL drawing actions; not just fills
|
|
42
|
-
@img.fill 300, 650, :texture => @gosu
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def draw
|
|
47
|
-
@img.draw 10, 10,1
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
w = W.new
|
|
54
|
-
w.show
|
|
55
|
-
|
data/examples/media/platform.png
DELETED
|
Binary file
|