green_shoes 0.131.0 → 0.138.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -2
- data/lib/shoes/app.rb +6 -3
- data/lib/shoes/help.rb +21 -0
- data/lib/shoes/helper_methods.rb +2 -2
- data/lib/shoes/main.rb +1 -0
- data/lib/shoes/widget.rb +1 -1
- data/samples/akatsukiface.png +0 -0
- data/samples/class-book.yaml +387 -0
- data/samples/cy.png +0 -0
- data/samples/loogink.png +0 -0
- data/samples/potato_chopping/1258_s001.gif +0 -0
- data/samples/potato_chopping/1258_s002.gif +0 -0
- data/samples/potato_chopping/1258_s003.gif +0 -0
- data/samples/potato_chopping/1258_s004.gif +0 -0
- data/samples/potato_chopping/1258_s005.gif +0 -0
- data/samples/potato_chopping/1258_s006.gif +0 -0
- data/samples/potato_chopping/1258_s007.gif +0 -0
- data/samples/potato_chopping/1258_s008.gif +0 -0
- data/samples/potato_chopping/1258_s009.gif +0 -0
- data/samples/potato_chopping/1258_s010.gif +0 -0
- data/samples/potato_chopping/1258_s011.gif +0 -0
- data/samples/potato_chopping/1258_s012.gif +0 -0
- data/samples/potato_chopping/1258_s013.gif +0 -0
- data/samples/potato_chopping/1258_s014.gif +0 -0
- data/samples/potato_chopping/1258_s015.gif +0 -0
- data/samples/potato_chopping/1258_s016.gif +0 -0
- data/samples/potato_chopping/1258_s017.gif +0 -0
- data/samples/potato_chopping/1258_s018.gif +0 -0
- data/samples/potato_chopping/1258_s019.gif +0 -0
- data/samples/potato_chopping/1258_s020.gif +0 -0
- data/samples/potato_chopping/1258_s021.gif +0 -0
- data/samples/potato_chopping/1258_s022.gif +0 -0
- data/samples/potato_chopping/1258_s023.gif +0 -0
- data/samples/potato_chopping/1258_s024.gif +0 -0
- data/samples/potato_chopping/1258_s025.gif +0 -0
- data/samples/potato_chopping/1258_s026.gif +0 -0
- data/samples/potato_chopping/1258_s027.gif +0 -0
- data/samples/potato_chopping/1258_s028.gif +0 -0
- data/samples/potato_chopping/1258_s029.gif +0 -0
- data/samples/potato_chopping/1258_s030.gif +0 -0
- data/samples/potato_chopping/1258_s031.gif +0 -0
- data/samples/potato_chopping/1258_s032.gif +0 -0
- data/samples/potato_chopping/1258_s033.gif +0 -0
- data/samples/potato_chopping/1258_s034.gif +0 -0
- data/samples/potato_chopping/1258_s035.gif +0 -0
- data/samples/potato_chopping/1258_s036.gif +0 -0
- data/samples/potato_chopping/1258_s037.gif +0 -0
- data/samples/potato_chopping/1258_s038.gif +0 -0
- data/samples/potato_chopping/1258_s039.gif +0 -0
- data/samples/potato_chopping/1258_s040.gif +0 -0
- data/samples/potato_chopping/1258_s041.gif +0 -0
- data/samples/potato_chopping/1258_s042.gif +0 -0
- data/samples/potato_chopping/1258_s043.gif +0 -0
- data/samples/potato_chopping/1258_s044.gif +0 -0
- data/samples/potato_chopping/1258_s045.gif +0 -0
- data/samples/potato_chopping/1258_s046.gif +0 -0
- data/samples/potato_chopping/1258_s047.gif +0 -0
- data/samples/potato_chopping/1258_s048.gif +0 -0
- data/samples/potato_chopping/1258_s049.gif +0 -0
- data/samples/potato_chopping/1258_s050.gif +0 -0
- data/samples/potato_chopping/1258_s051.gif +0 -0
- data/samples/potato_chopping/1258_s052.gif +0 -0
- data/samples/potato_chopping/1258_s053.gif +0 -0
- data/samples/potato_chopping/1258_s054.gif +0 -0
- data/samples/potato_chopping/1258_s055.gif +0 -0
- data/samples/potato_chopping/1258_s056.gif +0 -0
- data/samples/potato_chopping/1258_s057.gif +0 -0
- data/samples/potato_chopping/1258_s058.gif +0 -0
- data/samples/potato_chopping/1258_s059.gif +0 -0
- data/samples/potato_chopping/1258_s060.gif +0 -0
- data/samples/sample1.rb +32 -0
- data/samples/sample10.rb +10 -0
- data/samples/sample11.rb +12 -0
- data/samples/sample12.rb +21 -0
- data/samples/sample13.rb +17 -0
- data/samples/sample14-1.rb +38 -0
- data/samples/sample14.rb +64 -0
- data/samples/sample15.rb +17 -0
- data/samples/sample16.rb +12 -0
- data/samples/sample17.rb +12 -0
- data/samples/sample18.rb +23 -0
- data/samples/sample19.rb +39 -0
- data/samples/sample2.rb +13 -0
- data/samples/sample20.rb +26 -0
- data/samples/sample21.rb +7 -0
- data/samples/sample22.rb +13 -0
- data/samples/sample23.rb +10 -0
- data/samples/sample24.rb +21 -0
- data/samples/sample25.rb +22 -0
- data/samples/sample26.rb +21 -0
- data/samples/sample27.rb +19 -0
- data/samples/sample28.rb +64 -0
- data/samples/sample29.rb +13 -0
- data/samples/sample3.rb +10 -0
- data/samples/sample30.rb +30 -0
- data/samples/sample31.rb +24 -0
- data/samples/sample32.rb +25 -0
- data/samples/sample33.rb +19 -0
- data/samples/sample34.rb +29 -0
- data/samples/sample35.rb +31 -0
- data/samples/sample36.rb +46 -0
- data/samples/sample37.rb +10 -0
- data/samples/sample38.rb +13 -0
- data/samples/sample39.rb +18 -0
- data/samples/sample4.rb +9 -0
- data/samples/sample40.rb +19 -0
- data/samples/sample41.rb +8 -0
- data/samples/sample42.rb +15 -0
- data/samples/sample43.rb +26 -0
- data/samples/sample44.rb +63 -0
- data/samples/sample45.rb +13 -0
- data/samples/sample5.rb +8 -0
- data/samples/sample6.rb +11 -0
- data/samples/sample7.rb +5 -0
- data/samples/sample8.rb +9 -0
- data/samples/sample9.rb +12 -0
- data/samples/sample99.rb +4 -0
- data/samples/splash-hand.png +0 -0
- data/snapshots/helloworld.png +0 -0
- data/snapshots/mini-hh.png +0 -0
- data/snapshots/sample1.png +0 -0
- data/snapshots/sample10.png +0 -0
- data/snapshots/sample11.png +0 -0
- data/snapshots/sample12.png +0 -0
- data/snapshots/sample13.png +0 -0
- data/snapshots/sample14-1.png +0 -0
- data/snapshots/sample14.png +0 -0
- data/snapshots/sample15.png +0 -0
- data/snapshots/sample16.png +0 -0
- data/snapshots/sample17.png +0 -0
- data/snapshots/sample18.png +0 -0
- data/snapshots/sample19.png +0 -0
- data/snapshots/sample2.png +0 -0
- data/snapshots/sample20.png +0 -0
- data/snapshots/sample21.png +0 -0
- data/snapshots/sample22.png +0 -0
- data/snapshots/sample23.png +0 -0
- data/snapshots/sample24.png +0 -0
- data/snapshots/sample25.png +0 -0
- data/snapshots/sample26.png +0 -0
- data/snapshots/sample27.png +0 -0
- data/snapshots/sample28.png +0 -0
- data/snapshots/sample29.png +0 -0
- data/snapshots/sample3-osx.png +0 -0
- data/snapshots/sample3.png +0 -0
- data/snapshots/sample30.png +0 -0
- data/snapshots/sample31.png +0 -0
- data/snapshots/sample32.png +0 -0
- data/snapshots/sample33.png +0 -0
- data/snapshots/sample34.png +0 -0
- data/snapshots/sample35.png +0 -0
- data/snapshots/sample36.png +0 -0
- data/snapshots/sample37.png +0 -0
- data/snapshots/sample38.png +0 -0
- data/snapshots/sample39.png +0 -0
- data/snapshots/sample4.png +0 -0
- data/snapshots/sample40.png +0 -0
- data/snapshots/sample41.png +0 -0
- data/snapshots/sample42.png +0 -0
- data/snapshots/sample43.png +0 -0
- data/snapshots/sample44-linux.png +0 -0
- data/snapshots/sample44.png +0 -0
- data/snapshots/sample45.png +0 -0
- data/snapshots/sample5.png +0 -0
- data/snapshots/sample6.png +0 -0
- data/snapshots/sample7.png +0 -0
- data/snapshots/sample8.png +0 -0
- data/snapshots/sample9.png +0 -0
- data/snapshots/sample99.png +0 -0
- metadata +166 -3
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/samples/sample1.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
xspeed, yspeed = 10, 6
|
4
|
+
xdir, ydir = 1, 1
|
5
|
+
|
6
|
+
Shoes.app width: 300, height: 300 do
|
7
|
+
a = nil
|
8
|
+
p = para 'Hello', ' World!', top: 30
|
9
|
+
button('pause'){a.pause}
|
10
|
+
button('stop'){a.stop}
|
11
|
+
button('move'){p.move 200, 30}
|
12
|
+
button('remove'){p.clear}
|
13
|
+
img = image '../static/gshoes-icon.png'
|
14
|
+
img.click{alert "You're soooo quick!"}
|
15
|
+
|
16
|
+
x, y = 150, 150
|
17
|
+
size = [128, 128]
|
18
|
+
pause = 0
|
19
|
+
|
20
|
+
a = animate(24, false) do |n|
|
21
|
+
unless pause == n
|
22
|
+
x += xspeed * xdir
|
23
|
+
y += yspeed * ydir
|
24
|
+
|
25
|
+
xdir *= -1 if x > 300 - size[0] or x < 0
|
26
|
+
ydir *= -1 if y > 300 - size[1] or y < 0
|
27
|
+
|
28
|
+
img.move x.to_i, y.to_i
|
29
|
+
end
|
30
|
+
pause = n
|
31
|
+
end
|
32
|
+
end
|
data/samples/sample10.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 300, height: 300 do
|
4
|
+
flow do
|
5
|
+
10.times do |i|
|
6
|
+
flow(width: 0.5, height: 30){background forestgreen.push(0.1*(i+1)); para 'green'}
|
7
|
+
flow(width: 0.5, height: 30){background orangered.push(1.0 - 0.1*i); para 'shoes'}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/samples/sample11.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Same snippet as http://shoes.heroku.com/manual/Events.html#motion{|left,top|...}
|
2
|
+
|
3
|
+
require '../lib/green_shoes'
|
4
|
+
|
5
|
+
Shoes.app width: 200, height: 200 do
|
6
|
+
background black
|
7
|
+
fill white
|
8
|
+
@circ = oval 0, 0, 100, 100
|
9
|
+
motion do |top, left|
|
10
|
+
@circ.move top - 50, left - 50
|
11
|
+
end
|
12
|
+
end
|
data/samples/sample12.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 300, height: 300 do
|
4
|
+
background cadetblue
|
5
|
+
r = rect 100, 10, 100, fill: red, strokewidth: 5, curve: 10, stroke: pink
|
6
|
+
r.click{alert 'Yay!'}
|
7
|
+
o = oval 100, 110, 100, 100, fill: green, strokewidth: 10, stroke: white
|
8
|
+
para 'Green Shoes!!', left: 100, top: 70
|
9
|
+
|
10
|
+
size = COLORS.keys.size
|
11
|
+
j = 0
|
12
|
+
a = animate 1 do |i|
|
13
|
+
unless j == i
|
14
|
+
r.style fill: send(COLORS.keys[rand size]), stroke: send(COLORS.keys[rand size])
|
15
|
+
o.style fill: send(COLORS.keys[rand size]), stroke: send(COLORS.keys[rand size])
|
16
|
+
j = i
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
button('pause'){a.pause}
|
21
|
+
end
|
data/samples/sample13.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
# The same as sample60.rb on Shoes Tutorial Note
|
4
|
+
Shoes.app :width => 300, :height => 300 do
|
5
|
+
i = 45
|
6
|
+
button 'new'do
|
7
|
+
i += 5
|
8
|
+
box = rand(2) == 0 ? rect(i, i, 20) : oval(i, i, 10)
|
9
|
+
box.style :fill => send(COLORS.keys[rand(COLORS.keys.size)])
|
10
|
+
|
11
|
+
@flag = false
|
12
|
+
box.click{@flag = true; @box = box}
|
13
|
+
box.release{@flag = false}
|
14
|
+
motion{|left, top| @box.move(left-10, top-10) if @flag}
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 520, height: 520 do
|
4
|
+
def mk_ovals degree, color, size, mx, my, n, n1, n2, n3
|
5
|
+
ret = []
|
6
|
+
n.times do |i|
|
7
|
+
current_size = n1 + size
|
8
|
+
d = (i * n2 - degree) * Math::PI / 180
|
9
|
+
rx = Math::cos(d) * n3
|
10
|
+
ry = Math::sin(d) * n3
|
11
|
+
left = -current_size/2 + rx + mx
|
12
|
+
top = -current_size/2 + ry + my
|
13
|
+
ret << oval(left, top, current_size, current_size, fill: color).hide
|
14
|
+
end
|
15
|
+
ret
|
16
|
+
end
|
17
|
+
|
18
|
+
degree, color, size = 0, 0.1, 0
|
19
|
+
mx = my = 520 / 2
|
20
|
+
blue_ovals, red_ovals = [], []
|
21
|
+
|
22
|
+
nostroke
|
23
|
+
background pink
|
24
|
+
|
25
|
+
150.times do |j|
|
26
|
+
degree += 1
|
27
|
+
color += 0.002
|
28
|
+
size += 1
|
29
|
+
red_ovals << mk_ovals(-degree, red.push(color), size, mx, my, 6, 100, 60, 100)
|
30
|
+
blue_ovals << mk_ovals(degree, blue.push(color), size, mx, my, 12, 50, 30, 150)
|
31
|
+
end
|
32
|
+
|
33
|
+
animate 24 do |i|
|
34
|
+
i %= 150
|
35
|
+
red_ovals[i-1].each &:hide; red_ovals[i].each &:show
|
36
|
+
blue_ovals[i-1].each &:hide; blue_ovals[i].each &:show
|
37
|
+
end
|
38
|
+
end
|
data/samples/sample14.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# This is from http://github.com/shoes/shoes-contrib/blob/master/animation/flowers.rb
|
2
|
+
# Edited a little for Green Shoes by ashbb
|
3
|
+
#
|
4
|
+
###############################################
|
5
|
+
#
|
6
|
+
# This is from juixe "Running with Shoes - 2D Examples"
|
7
|
+
# http://juixe.com/techknow/index.php/2007/10/19/running-with-shoes-2d-examples/
|
8
|
+
#
|
9
|
+
# This is an animation of two concentric sets of circles moving in different
|
10
|
+
# directions. As the circles move they change size and color.
|
11
|
+
#
|
12
|
+
|
13
|
+
require '../lib/green_shoes'
|
14
|
+
|
15
|
+
degree = 0
|
16
|
+
color = 0
|
17
|
+
size = 0
|
18
|
+
|
19
|
+
Shoes.app :width => 537, :height => 500 do
|
20
|
+
# Convert degrees to radians
|
21
|
+
def to_radians(deg)
|
22
|
+
deg * Math::PI / 180
|
23
|
+
end
|
24
|
+
|
25
|
+
mx, my = (500/2).to_i, (537/2).to_i
|
26
|
+
animate(2) do
|
27
|
+
clear do
|
28
|
+
# Manage color
|
29
|
+
nostroke
|
30
|
+
#background rgb(1.0, 0.5, 1.0, 1.0)
|
31
|
+
# Update some variables
|
32
|
+
degree += 1
|
33
|
+
size += 1
|
34
|
+
degree = 0 if(degree >= 360)
|
35
|
+
size = 0 if(size >= 100)
|
36
|
+
color = 0.0 if(color >= 1.0)
|
37
|
+
color += 0.05 if(degree % 10 == 0)
|
38
|
+
|
39
|
+
# Draw inner circle
|
40
|
+
fill red.push(color)
|
41
|
+
10.times do |i|
|
42
|
+
current_size = 100 + size
|
43
|
+
d = to_radians(i * 60 + degree)
|
44
|
+
rx = Math::cos(d) * 100
|
45
|
+
ry = Math::sin(d) * 100
|
46
|
+
center_x = -current_size/2 + rx + mx
|
47
|
+
center_y = -current_size/2 + ry + my
|
48
|
+
oval center_x, center_y, current_size, current_size
|
49
|
+
end
|
50
|
+
|
51
|
+
# Draw outer circle
|
52
|
+
fill blue.push(color)
|
53
|
+
20.times do |i|
|
54
|
+
current_size = 50 + size
|
55
|
+
d = to_radians(i * 30 - degree)
|
56
|
+
rx = Math::cos(d) * 150
|
57
|
+
ry = Math::sin(d) * 150
|
58
|
+
center_x = -current_size/2 + rx + mx
|
59
|
+
center_y = -current_size/2 + ry + my
|
60
|
+
oval center_x, center_y, current_size, current_size
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/samples/sample15.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
TEXT =<<EOS
|
4
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, \
|
5
|
+
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
6
|
+
|
7
|
+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris \
|
8
|
+
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in \
|
9
|
+
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
10
|
+
|
11
|
+
Excepteur sint occaecat cupidatat non proident, sunt in \
|
12
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
13
|
+
EOS
|
14
|
+
|
15
|
+
Shoes.app do
|
16
|
+
para TEXT
|
17
|
+
end
|
data/samples/sample16.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Same snippet as http://shoes-tutorial-note.heroku.com/html/00402_No.1_para.html
|
2
|
+
|
3
|
+
require '../lib/green_shoes'
|
4
|
+
|
5
|
+
Shoes.app :width => 240, :height => 95 do
|
6
|
+
para 'Testing, test, test. ',
|
7
|
+
strong('Breadsticks. '),
|
8
|
+
em('Breadsticks. '),
|
9
|
+
code('Breadsticks. '),
|
10
|
+
strong(ins('EVEN BETTER.')),
|
11
|
+
sub('fine!')
|
12
|
+
end
|
data/samples/sample17.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Add new method bg and fg to sample17
|
2
|
+
|
3
|
+
require '../lib/green_shoes'
|
4
|
+
|
5
|
+
Shoes.app :width => 240, :height => 95 do
|
6
|
+
para 'Testing, test, test. ',
|
7
|
+
strong('Breadsticks. '),
|
8
|
+
em('Breadsticks. '),
|
9
|
+
code('Breadsticks. '),
|
10
|
+
bg(fg(strong(ins('EVEN BETTER.')), white), rgb(255, 0, 192)),
|
11
|
+
sub('fine!')
|
12
|
+
end
|
data/samples/sample18.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "../lib/green_shoes"
|
2
|
+
|
3
|
+
Shoes.app width: 700, height: 600 do
|
4
|
+
title "Shoes is a ", link("tiny"){alert "Cool!"}, " graphics toolkit. "
|
5
|
+
|
6
|
+
flow width: 0.4 do
|
7
|
+
img = image '../static/gshoes-icon.png'
|
8
|
+
img.click{alert "You're soooo quick!"}
|
9
|
+
end
|
10
|
+
|
11
|
+
flow width: 0.6 do
|
12
|
+
tagline "It's simple and straightforward. ",
|
13
|
+
link("Shoes "){alert "Yay!"},
|
14
|
+
"was born to be easy! ",
|
15
|
+
link("Shoes "){alert "Yay!"},
|
16
|
+
"was born to be easy! ",
|
17
|
+
link("Shoes "){alert "Yay!"},
|
18
|
+
"was born to be easy! ",
|
19
|
+
"Really, it was made for absolute beginners. "
|
20
|
+
end
|
21
|
+
|
22
|
+
subtitle link(strong em("There's ", fg(bg("really ", "really ", yellow), red), "nothing to it. ")){alert "Have fun!"}
|
23
|
+
end
|
data/samples/sample19.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# almost the same code as sample58 on (Red) Shoes Tutorial Note:
|
2
|
+
# http://shoes-tutorial-note.heroku.com/html/00704_Assignment_4_Pong_in_Shoes.html
|
3
|
+
require '../lib/green_shoes'
|
4
|
+
|
5
|
+
Shoes.app :width => 400, :height => 400, :resizable => false do
|
6
|
+
vx, vy = 3, 4
|
7
|
+
|
8
|
+
nostroke
|
9
|
+
@ball = oval 0, 0, 20, 20, :fill => forestgreen
|
10
|
+
@comp = rect 0, 0, 75, 4, :curve => 2
|
11
|
+
@you = rect 0, 396, 75, 4, :curve => 2
|
12
|
+
|
13
|
+
@anim = animate 32 do
|
14
|
+
nx, ny = @ball.left + vx.to_i, @ball.top + vy.to_i
|
15
|
+
|
16
|
+
if @ball.top + 20 < 0 or @ball.top > 400
|
17
|
+
para "<span font_desc='32'>", strong('GAME OVER'), "</span>\n",
|
18
|
+
@ball.top < 0 ? "You win!" : "Computer wins", :top => 140, :align => 'center'
|
19
|
+
@ball.clear and @anim.stop
|
20
|
+
end
|
21
|
+
|
22
|
+
vx = -vx if nx + 20 > 400 or nx < 0
|
23
|
+
|
24
|
+
if ny + 20 > 400 and nx + 20 > @you.left and nx < @you.left + 75
|
25
|
+
vy = -vy * 1.2
|
26
|
+
vx = (nx - @you.left - (75 / 2)) * 0.25
|
27
|
+
end
|
28
|
+
|
29
|
+
if ny < 0 and nx + 20 > @comp.left and nx < @comp.left + 75
|
30
|
+
vy = -vy * 1.2
|
31
|
+
vx = (nx - @comp.left - (75 / 2)) * 0.25
|
32
|
+
end
|
33
|
+
|
34
|
+
@ball.move nx, ny
|
35
|
+
@you.left = mouse[1] - (75 / 2)
|
36
|
+
@comp.left += 10 if @comp.left + 75 < @ball.left
|
37
|
+
@comp.left -= 10 if @ball.left + 20 < @comp.left
|
38
|
+
end
|
39
|
+
end
|
data/samples/sample2.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
Shoes.app title: 'Green Shoes New Logo Icon!', width: 300, height: 420 do
|
4
|
+
stack do
|
5
|
+
image '../static/gshoes-icon.png'
|
6
|
+
flow do
|
7
|
+
image '../static/gshoes-icon.png'
|
8
|
+
image '../static/gshoes-icon.png'
|
9
|
+
end
|
10
|
+
image '../static/gshoes-icon.png'
|
11
|
+
para ' ' * 30, 'Created by Zak'
|
12
|
+
end
|
13
|
+
end
|
data/samples/sample20.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# This is a tiny flip book (aka Para-Para Manga in Japanese)
|
2
|
+
# original is http://www.paraman.net/play/preview/1258
|
3
|
+
#
|
4
|
+
require '../lib/green_shoes'
|
5
|
+
|
6
|
+
Shoes.app title: 'potacho', width: 175, height: 160 do
|
7
|
+
background tan
|
8
|
+
|
9
|
+
@imgs = []
|
10
|
+
1.upto 60 do |i|
|
11
|
+
@imgs << image("./potato_chopping/1258_s#{"%03d" % i}.gif").hide.move(10, 10)
|
12
|
+
end
|
13
|
+
|
14
|
+
@imgs.first.show
|
15
|
+
|
16
|
+
def potacho
|
17
|
+
@imgs[59].hide
|
18
|
+
a = animate 12 do |i|
|
19
|
+
@imgs[i].show
|
20
|
+
@imgs[i-1].hide if i > 0
|
21
|
+
a.stop if i > 58
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
button(' start '){potacho}.move 10, 130
|
26
|
+
end
|
data/samples/sample21.rb
ADDED
data/samples/sample22.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
Shoes.app do
|
4
|
+
background chocolate..black, angle: 130
|
5
|
+
strokewidth 20
|
6
|
+
border deeppink..forestgreen, curve: 30
|
7
|
+
nostroke
|
8
|
+
fill crimson..cyan
|
9
|
+
oval 100, 100, 100, 100, angle: 45
|
10
|
+
nofill
|
11
|
+
strokewidth 50
|
12
|
+
rect 200, 200, 300, 200, stroke: darkblue..ivory, angle: 90
|
13
|
+
end
|
data/samples/sample23.rb
ADDED
data/samples/sample24.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 400, height: 400 do
|
4
|
+
background yellow
|
5
|
+
rect 0, 0, 100, 100
|
6
|
+
rect 100, 100, 100, 100
|
7
|
+
rect 200, 200, 100, 100
|
8
|
+
rect 0, 200, 100, 100
|
9
|
+
rect 200, 0, 100, 100
|
10
|
+
stroke '../static/gshoes-icon.png'
|
11
|
+
strokewidth 10
|
12
|
+
line 355, 180, 5, 111, strokewidth: 20
|
13
|
+
stroke red
|
14
|
+
line 0, 0, 100, 0
|
15
|
+
line 0, 100, 0, 0
|
16
|
+
line 300, 200, 200, 200
|
17
|
+
line 100, 200, 200, 100
|
18
|
+
stroke white
|
19
|
+
line 200, 200, 200, 300
|
20
|
+
line 300, 200, 200, 100
|
21
|
+
end
|
data/samples/sample25.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 305, height: 460 do
|
4
|
+
background lightskyblue
|
5
|
+
|
6
|
+
flow do
|
7
|
+
background green
|
8
|
+
3.times do
|
9
|
+
button 'button', margin: 5
|
10
|
+
edit_line margin_top: 5
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
image '../static/gshoes-icon.png', margin: 20, margin_left: 80
|
15
|
+
tagline fg(em(strong('A sample for margin style.')), maroon),
|
16
|
+
margin: [30, 0, 0, 30]
|
17
|
+
|
18
|
+
flow do
|
19
|
+
background gold
|
20
|
+
10.times{button 'button', margin: [10, 5, 0, 5]}
|
21
|
+
end
|
22
|
+
end
|
data/samples/sample26.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 450, height: 150 do
|
4
|
+
background black
|
5
|
+
strokewidth 4
|
6
|
+
|
7
|
+
paint_lines = proc do
|
8
|
+
20.times do |i|
|
9
|
+
stroke rgb((0.0..0.5).rand, (0.0..1.0).rand, (0.0..0.3).rand)
|
10
|
+
line 0, i * 5, 400, i * 8
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
s = stack do
|
15
|
+
mask do
|
16
|
+
title strong("<span size='#{82*1024}'>Shoes</span>"), left: 50
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
animate(5){s.clear{paint_lines.call}}
|
21
|
+
end
|
data/samples/sample27.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
Shoes.app do
|
4
|
+
button 'go' do
|
5
|
+
p = para 0, top: 30
|
6
|
+
a = every do |i|
|
7
|
+
j = i*20
|
8
|
+
p.text = i.to_s
|
9
|
+
para i.to_s, left: j*2, top: 30
|
10
|
+
oval 100+j, 100+j, 10, 10
|
11
|
+
a.stop if i > 8
|
12
|
+
end
|
13
|
+
|
14
|
+
timer 10 do
|
15
|
+
p.text = 'hello'
|
16
|
+
para 'green shoes', top: 200
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/samples/sample28.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# The Game Snake. Refer to Gallery No.7: http://shoes-tutorial-note.heroku.com/html/01120_Fancy_Gallery_6-10.html
|
2
|
+
require '../lib/green_shoes'
|
3
|
+
|
4
|
+
Shoes.app :title => 'Snake Game v0.1' do
|
5
|
+
background black
|
6
|
+
|
7
|
+
def game_start
|
8
|
+
@score = para fg('Score:', white)
|
9
|
+
@pos = {:up => [0, -10], :down => [0, 10], :left => [-10, 0], :right => [10, 0]}
|
10
|
+
@rx, @ry = proc{20 + 10*rand(56)}, proc{40 + 10*rand(44)}
|
11
|
+
|
12
|
+
@foods = []
|
13
|
+
stroke lime
|
14
|
+
50.times{@foods << rect(@rx[], @ry[], 10, 10)}
|
15
|
+
|
16
|
+
@bricks = []
|
17
|
+
stroke deepskyblue; fill blue
|
18
|
+
50.times{@bricks << rect(@rx[], @ry[], 10, 10)}
|
19
|
+
20.step(570, 10){|n| @bricks << rect(n, 40, 10, 10) << rect(n, 470, 10, 10)}
|
20
|
+
40.step(470, 10){|n| @bricks << rect(10, n, 10, 10) << rect(570, n, 10, 10)}
|
21
|
+
|
22
|
+
@snake = []
|
23
|
+
stroke white; nofill
|
24
|
+
@snake << rect(300, 100, 10, 10)
|
25
|
+
@snake[0].style stroke: red
|
26
|
+
|
27
|
+
dir = :left
|
28
|
+
@run = animate 5 do
|
29
|
+
keypress{|k| k = k.downcase.to_sym; dir = k if @pos.keys.include? k}
|
30
|
+
check_food
|
31
|
+
go dir
|
32
|
+
@score.text = fg("Score: #{@snake.length * 10}", white)
|
33
|
+
brick? @snake[0]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def go k
|
38
|
+
x, y = @pos[k]
|
39
|
+
@snake.unshift @snake.pop
|
40
|
+
n = @snake.length > 1 ? 1 : 0
|
41
|
+
@snake[0].move @snake[n].left + x, @snake[n].top + y
|
42
|
+
@snake[0].style stroke: red
|
43
|
+
@snake[1..-1].each{|s| s.style stroke: white}
|
44
|
+
end
|
45
|
+
|
46
|
+
def check_food
|
47
|
+
(@snake << rect(0, 0, 10, 10)) if eat? @snake[0]
|
48
|
+
end
|
49
|
+
|
50
|
+
def eat? s
|
51
|
+
@foods.each_with_index do |f, i|
|
52
|
+
(f.move @rx[], @ry[]; return true) if f.left == s.left and f.top == s.top
|
53
|
+
end
|
54
|
+
return false
|
55
|
+
end
|
56
|
+
|
57
|
+
def brick? s
|
58
|
+
@bricks.each do |b|
|
59
|
+
(@run.stop; alert 'Game Over. ') if b.left == s.left and b.top == s.top
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
game_start
|
64
|
+
end
|
data/samples/sample29.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
Shoes.app do
|
4
|
+
lb = list_box items: COLORS.keys.map(&:to_s), choose: 'red' do |item|
|
5
|
+
@o.style fill: eval(item)
|
6
|
+
@p.text = item
|
7
|
+
end.move(300, 0)
|
8
|
+
@p = para
|
9
|
+
nostroke
|
10
|
+
@o = oval 100, 100, 100, 100
|
11
|
+
i = 0
|
12
|
+
button('print'){para lb.text, top: 20*(i+=1)}.move(500, 0)
|
13
|
+
end
|
data/samples/sample3.rb
ADDED
data/samples/sample30.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Almost same code as sample22.rb : http://shoes-tutorial-note.heroku.com/html/00508_The_Widget_class.html
|
2
|
+
|
3
|
+
require '../lib/green_shoes'
|
4
|
+
|
5
|
+
class Answer < Shoes::Widget
|
6
|
+
attr_reader :mark
|
7
|
+
def initialize word
|
8
|
+
flow do
|
9
|
+
flow(width: 70){para word}
|
10
|
+
@mark = image('./loogink.png', width: 20, height: 20).hide
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Shoes.app width: 200, height: 100 do
|
16
|
+
stack width: 0.5 do
|
17
|
+
background palegreen
|
18
|
+
para '1. apple'
|
19
|
+
ans = answer '2. tomato'
|
20
|
+
para '3. orange'
|
21
|
+
button('Ans.'){ans.mark.toggle}
|
22
|
+
end
|
23
|
+
stack width: 0.5 do
|
24
|
+
background lightsteelblue
|
25
|
+
para '1. cat'
|
26
|
+
para '2. dog'
|
27
|
+
ans = answer '3. bird'
|
28
|
+
button('Ans.'){ans.mark.toggle}
|
29
|
+
end
|
30
|
+
end
|