purple_shoes 0.0.101
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +56 -0
- data/VERSION +1 -0
- data/bin/pshoes +23 -0
- data/bin/pshoes.bat +2 -0
- data/lib/plugins/video.rb +88 -0
- data/lib/purple_shoes.rb +51 -0
- data/lib/shoes/anim.rb +47 -0
- data/lib/shoes/app.rb +688 -0
- data/lib/shoes/basic.rb +254 -0
- data/lib/shoes/colors.rb +149 -0
- data/lib/shoes/download.rb +26 -0
- data/lib/shoes/help.rb +473 -0
- data/lib/shoes/helper_methods.rb +295 -0
- data/lib/shoes/main.rb +96 -0
- data/lib/shoes/manual.rb +6 -0
- data/lib/shoes/ruby.rb +61 -0
- data/lib/shoes/slot.rb +104 -0
- data/lib/shoes/style.rb +41 -0
- data/lib/shoes/text.rb +46 -0
- data/lib/shoes/url.rb +14 -0
- data/lib/shoes/widget.rb +23 -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/sample1.rb +30 -0
- data/samples/sample10.rb +11 -0
- data/samples/sample11.rb +12 -0
- data/samples/sample12.rb +22 -0
- data/samples/sample13.rb +15 -0
- data/samples/sample14.rb +75 -0
- data/samples/sample15.rb +20 -0
- data/samples/sample16.rb +12 -0
- data/samples/sample17.rb +12 -0
- data/samples/sample18.rb +24 -0
- data/samples/sample19.rb +39 -0
- data/samples/sample2.rb +16 -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 +22 -0
- data/samples/sample25.rb +22 -0
- data/samples/sample27.rb +19 -0
- data/samples/sample28.rb +64 -0
- data/samples/sample29.rb +12 -0
- data/samples/sample3.rb +10 -0
- data/samples/sample30.rb +30 -0
- data/samples/sample31.rb +24 -0
- data/samples/sample34.rb +29 -0
- data/samples/sample35.rb +33 -0
- data/samples/sample36.rb +48 -0
- data/samples/sample37.rb +10 -0
- data/samples/sample38.rb +14 -0
- data/samples/sample4.rb +9 -0
- data/samples/sample40.rb +19 -0
- data/samples/sample42.rb +15 -0
- data/samples/sample43.rb +26 -0
- data/samples/sample44.rb +57 -0
- data/samples/sample45.rb +12 -0
- data/samples/sample46.rb +35 -0
- data/samples/sample47.rb +20 -0
- data/samples/sample48.rb +33 -0
- data/samples/sample49.rb +33 -0
- data/samples/sample5.rb +8 -0
- data/samples/sample50.rb +326 -0
- data/samples/sample58.rb +19 -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/sounds/102719__sarge4267__explosion.mp3 +0 -0
- data/samples/sounds/145622__andybrannan__train-fog-horn-long-wyomming.aiff +0 -0
- data/samples/sounds/46492__phreaksaccount__shields1.ogg +0 -0
- data/samples/sounds/61847__simon-rue__boink-v3.wav +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.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/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/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/sample4.png +0 -0
- data/snapshots/sample40.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/sample46.png +0 -0
- data/snapshots/sample47.png +0 -0
- data/snapshots/sample48.png +0 -0
- data/snapshots/sample49.png +0 -0
- data/snapshots/sample5.png +0 -0
- data/snapshots/sample50.png +0 -0
- data/snapshots/sample58.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
- data/static/code_highlighter.js +188 -0
- data/static/code_highlighter_ruby.js +26 -0
- data/static/man-editor-notepad.png +0 -0
- data/static/man-editor-osx.png +0 -0
- data/static/man-ele-background.png +0 -0
- data/static/man-ele-border.png +0 -0
- data/static/man-ele-button.png +0 -0
- data/static/man-ele-check.png +0 -0
- data/static/man-ele-editbox.png +0 -0
- data/static/man-ele-editline.png +0 -0
- data/static/man-ele-image.png +0 -0
- data/static/man-ele-listbox.png +0 -0
- data/static/man-ele-progress.png +0 -0
- data/static/man-ele-radio.png +0 -0
- data/static/man-ele-shape.png +0 -0
- data/static/man-ele-textblock.png +0 -0
- data/static/man-ele-video.png +0 -0
- data/static/man-shot1.png +0 -0
- data/static/manual-en.txt +3969 -0
- data/static/manual-ja.txt +3882 -0
- data/static/manual.css +184 -0
- data/static/purple_shoes-icon.png +0 -0
- data/static/rshoes-icon.png +0 -0
- data/static/shoes-manual-apps.png +0 -0
- data/static/sound_jars/jl1.0.1.jar +0 -0
- data/static/sound_jars/jogg-0.0.7.jar +0 -0
- data/static/sound_jars/jorbis-0.0.15.jar +0 -0
- data/static/sound_jars/mp3spi1.9.5.jar +0 -0
- data/static/sound_jars/tritonus_share.jar +0 -0
- data/static/sound_jars/vorbisspi1.0.3.jar +0 -0
- metadata +271 -0
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 'purple_shoes'
|
5
|
+
|
6
|
+
Shoes.app title: 'potacho', width: 175, height: 160 do
|
7
|
+
background tan
|
8
|
+
|
9
|
+
@imgs = []
|
10
|
+
1.upto 59 do |i|
|
11
|
+
@imgs << image(File.join(DIR, "../samples/potato_chopping/1258_s#{"%03d" % i}.gif")).hide.move(10, 10)
|
12
|
+
end
|
13
|
+
|
14
|
+
@imgs.first.show
|
15
|
+
|
16
|
+
def potacho
|
17
|
+
@imgs[58].hide
|
18
|
+
a = animate 12 do |i|
|
19
|
+
@imgs[i].show
|
20
|
+
@imgs[i-1].hide if i > 0
|
21
|
+
a.stop if i > 57
|
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 'purple_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
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 300, height: 300 do
|
4
|
+
fname = File.join(DIR, '../static/purple_shoes-icon.png')
|
5
|
+
background yellow..orange, angle: 90
|
6
|
+
border fname, strokewidth: 20, curve: 100
|
7
|
+
fill fname
|
8
|
+
nostroke
|
9
|
+
oval 100, 100, 100, 100
|
10
|
+
end
|
data/samples/sample24.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 400, height: 400 do
|
4
|
+
#cap [:rect, :curve, :project][rand 3]
|
5
|
+
background yellow
|
6
|
+
rect 0, 0, 100, 100
|
7
|
+
rect 100, 100, 100, 100
|
8
|
+
rect 200, 200, 100, 100
|
9
|
+
rect 0, 200, 100, 100
|
10
|
+
rect 200, 0, 100, 100
|
11
|
+
stroke File.join(DIR, '../static/purple_shoes-icon.png')
|
12
|
+
strokewidth 10
|
13
|
+
line 355, 180, 5, 111, strokewidth: 20
|
14
|
+
stroke red
|
15
|
+
line 0, 0, 100, 0
|
16
|
+
line 0, 100, 0, 0
|
17
|
+
line 300, 200, 200, 200
|
18
|
+
line 100, 200, 200, 100
|
19
|
+
stroke white
|
20
|
+
line 200, 200, 200, 300
|
21
|
+
line 300, 200, 200, 100
|
22
|
+
end
|
data/samples/sample25.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'purple_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 File.join(DIR, '../static/purple_shoes-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/sample27.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'purple_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 'purple 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 'purple_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, false do
|
29
|
+
check_food
|
30
|
+
go dir
|
31
|
+
@score.text = "Score: #{@snake.length * 10}"
|
32
|
+
brick? @snake[0]
|
33
|
+
end
|
34
|
+
keypress{|k| k = k[6..-1].to_s.downcase.to_sym; dir = k if @pos.keys.include? k}
|
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].style stroke: white if n > 0
|
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,12 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
Shoes.app do
|
4
|
+
lb = list_box items: COLORS.keys.map(&:to_s), choose: 'red' do |s|
|
5
|
+
@o.style fill: eval(s.text)
|
6
|
+
@p.text = s.text
|
7
|
+
end.move(300, 0)
|
8
|
+
@p = para
|
9
|
+
nostroke
|
10
|
+
@o = oval 100, 100, 100, 100
|
11
|
+
button('print'){para lb.text; flush}.move(500, 0)
|
12
|
+
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 'purple_shoes'
|
4
|
+
#require 'green_shoes'
|
5
|
+
class Answer < Shoes::Widget
|
6
|
+
attr_reader :mark
|
7
|
+
def initialize word
|
8
|
+
flow do
|
9
|
+
para word, width: 70
|
10
|
+
@mark = image(File.join(DIR, '../samples/loogink.png'), width: 20, height: 20).hide
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Shoes.app width: 200, height: 80 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
|
data/samples/sample31.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
Shoes.app do
|
4
|
+
strokewidth 3
|
5
|
+
eles = []
|
6
|
+
eles << oval(0, 0, 300, angle: 90)
|
7
|
+
eles << rect(50, 50, 350, 350, curve: 10)
|
8
|
+
eles << star(300, 300, 30, 200, 180)
|
9
|
+
eles << shape(left: 200, top: 150, width: 300, height: 300, rotate: [45, 300, 300]){
|
10
|
+
move_to 200, 200
|
11
|
+
line_to 200, 100
|
12
|
+
quad_to 100, 100, 20, 200
|
13
|
+
line_to 20, 100
|
14
|
+
}
|
15
|
+
eles << line(100, 100, 480, 480)
|
16
|
+
|
17
|
+
button 'change colors' do
|
18
|
+
eles.each do |ele|
|
19
|
+
colors = []
|
20
|
+
4.times{colors << send(COLORS.keys[rand(COLORS.keys.size)])}
|
21
|
+
ele.style fill: colors[0]..colors[1], stroke: colors[2]..colors[3]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/samples/sample34.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Refer to NKS (Nobody Knows Shoes) page 21.
|
2
|
+
|
3
|
+
require 'purple_shoes'
|
4
|
+
|
5
|
+
Shoes.app width: 280, height: 350 do
|
6
|
+
flow width: 1.0, margin: 10 do
|
7
|
+
flow do
|
8
|
+
background gold, curve: 10
|
9
|
+
stack width: 1.0 do
|
10
|
+
banner "A POEM"
|
11
|
+
end
|
12
|
+
stack width: 80 do
|
13
|
+
para "Goes like:"
|
14
|
+
end
|
15
|
+
stack width: 180 do
|
16
|
+
para "the sun.\n",
|
17
|
+
"a lemon.\n",
|
18
|
+
"the goalie.\n",
|
19
|
+
"a fireplace.\n\n",
|
20
|
+
"i want to write\n",
|
21
|
+
"a poem for the\n",
|
22
|
+
"kids who haven't\n",
|
23
|
+
"even heard one yet.\n\n",
|
24
|
+
"and the goalie guards\n",
|
25
|
+
"the fireplace."
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/samples/sample35.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# original code is http://shoes-tutorial-note.heroku.com/html/00409_No.9_Shoes.url.html
|
2
|
+
|
3
|
+
require 'purple_shoes'
|
4
|
+
|
5
|
+
class PhotoFrame < Shoes
|
6
|
+
url '/', :index
|
7
|
+
url '/loogink', :loogink
|
8
|
+
url '/cy', :cy
|
9
|
+
|
10
|
+
def index
|
11
|
+
eval(['loogink', 'cy'][rand 2])
|
12
|
+
end
|
13
|
+
|
14
|
+
def loogink
|
15
|
+
background tomato
|
16
|
+
image File.join(DIR, '../samples/loogink.png'), margin: [70, 10, 0, 0]
|
17
|
+
para fg(strong('She is Loogink.'), white),
|
18
|
+
'->', link(strong('Cy')){visit '/cy'},
|
19
|
+
margin: 10
|
20
|
+
p location
|
21
|
+
end
|
22
|
+
|
23
|
+
def cy
|
24
|
+
background paleturquoise
|
25
|
+
image File.join(DIR, '../samples/cy.png'), margin: [70, 10, 0, 0]
|
26
|
+
para fg(strong('He is Cy.'), gray), ' ->',
|
27
|
+
link(strong('loogink')){visit '/loogink'},
|
28
|
+
margin: 10
|
29
|
+
p location
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Shoes.app width: 200, height: 120, title: 'Photo Frame'
|
data/samples/sample36.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# original code is Red Shoes class-book.rb by _why
|
2
|
+
require 'purple_shoes'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
class Book < Shoes
|
6
|
+
url '/', :index
|
7
|
+
url '/incidents/(\d+)', :incident
|
8
|
+
|
9
|
+
def index
|
10
|
+
incident 0
|
11
|
+
end
|
12
|
+
|
13
|
+
INCIDENTS = YAML.load_file File.join(DIR, '../samples/class-book.yaml')
|
14
|
+
|
15
|
+
def table_of_contents
|
16
|
+
toc = []
|
17
|
+
INCIDENTS.each_with_index do |(title, story), i|
|
18
|
+
toc.push "(#{i + 1}) ",
|
19
|
+
link(title){visit "/incidents/#{i}"},
|
20
|
+
" / "
|
21
|
+
end
|
22
|
+
toc[0...-1] << "\n"*5
|
23
|
+
end
|
24
|
+
|
25
|
+
def incident num
|
26
|
+
self.scroll_top = 0
|
27
|
+
num = num.to_i
|
28
|
+
stack margin_left: 200 do
|
29
|
+
banner "Incident", margin: [0, 10, 0, 30]
|
30
|
+
para strong("No. #{num + 1}: #{INCIDENTS[num][0]}"), margin_bottom: 5
|
31
|
+
end
|
32
|
+
|
33
|
+
flow do
|
34
|
+
flow width: 180, margin_left: 10 do
|
35
|
+
#pinning para( *table_of_contents, size: 8 )
|
36
|
+
para *table_of_contents, size: 8
|
37
|
+
end
|
38
|
+
|
39
|
+
stack width: -180, margin: [20, 0, 10, 0] do
|
40
|
+
INCIDENTS[num][1].split(/\n\n+/).each do |p|
|
41
|
+
para p
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Shoes.app width: 640, height: 700, title: "Incidents, a Book"
|
data/samples/sample37.rb
ADDED
data/samples/sample38.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'purple_shoes'
|
2
|
+
|
3
|
+
Shoes.app width: 250, height: 250 do
|
4
|
+
nofill
|
5
|
+
r = rect 50, 50, 50, 20, stroke: green
|
6
|
+
o = oval 150, 100, 50, 20, stroke: red
|
7
|
+
s = star 50, 150, 5, 30, 10, stroke: blue
|
8
|
+
|
9
|
+
animate do |i|
|
10
|
+
r.rotate = [10*i, 75, 60]
|
11
|
+
o.rotate = [10*i, 175, 110]
|
12
|
+
s.rotate = [10*i, 50, 150]
|
13
|
+
end
|
14
|
+
end
|
data/samples/sample4.rb
ADDED
data/samples/sample40.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# For Christmas
|
2
|
+
require 'purple_shoes'
|
3
|
+
|
4
|
+
Shoes.app width: 330, height: 300 do
|
5
|
+
nostroke
|
6
|
+
background black
|
7
|
+
data, stars = [], []
|
8
|
+
5.times{data << [30+rand(10), 20+rand(200), 20+rand(200)]}
|
9
|
+
5.times{|j| stars << star(data[j][1], data[j][2], 5, data[j][0], data[j][0]/2.0, fill: gold..white, angle: 45)}
|
10
|
+
msg = para fg(strong('Merry Christmas'), white), size: 48
|
11
|
+
msg.hide
|
12
|
+
|
13
|
+
a = animate do |i|
|
14
|
+
rotate i*5
|
15
|
+
stars.each_with_index{|s, j| s.rotate = [i*5, data[j][1], data[j][2]]}
|
16
|
+
msg.show if i > 30
|
17
|
+
a.stop if i > 50
|
18
|
+
end
|
19
|
+
end
|