green_shoes 1.0.337 → 1.1.348
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/gshoes +57 -0
- data/bin/gshoes.bat +2 -0
- data/bin/gshoes.ico +0 -0
- data/lib/green_shoes.rb +2 -0
- data/lib/shoes/app.rb +1 -1
- data/lib/shoes/help.rb +1 -1
- data/lib/shoes/helper_methods.rb +2 -2
- data/lib/shoes/minitar.rb +986 -0
- data/lib/shoes/shy.rb +130 -0
- data/samples/sample1.rb +2 -2
- data/samples/sample10.rb +1 -1
- data/samples/sample11.rb +1 -1
- data/samples/sample12.rb +1 -1
- data/samples/sample13.rb +1 -1
- data/samples/sample14-1.rb +1 -1
- data/samples/sample14.rb +1 -1
- data/samples/sample15.rb +2 -2
- data/samples/sample16.rb +1 -1
- data/samples/sample17.rb +1 -1
- data/samples/sample18.rb +2 -2
- data/samples/sample19.rb +1 -1
- data/samples/sample2.rb +6 -5
- data/samples/sample20.rb +5 -5
- data/samples/sample21.rb +2 -2
- data/samples/sample22.rb +1 -1
- data/samples/sample23.rb +2 -2
- data/samples/sample24.rb +2 -2
- data/samples/sample25.rb +2 -2
- data/samples/sample26.rb +1 -1
- data/samples/sample27.rb +1 -1
- data/samples/sample28.rb +1 -1
- data/samples/sample29.rb +1 -1
- data/samples/sample3.rb +1 -1
- data/samples/sample30.rb +2 -2
- data/samples/sample31.rb +1 -1
- data/samples/sample32.rb +1 -1
- data/samples/sample33.rb +1 -1
- data/samples/sample34.rb +1 -1
- data/samples/sample35.rb +3 -3
- data/samples/sample36.rb +2 -2
- data/samples/sample37.rb +1 -1
- data/samples/sample38.rb +1 -1
- data/samples/sample39.rb +2 -2
- data/samples/sample4.rb +1 -1
- data/samples/sample40.rb +1 -1
- data/samples/sample41.rb +1 -1
- data/samples/sample42.rb +1 -1
- data/samples/sample43.rb +1 -1
- data/samples/sample44.rb +1 -1
- data/samples/sample45.rb +1 -1
- data/samples/sample46.rb +1 -1
- data/samples/sample47.rb +2 -2
- data/samples/sample48.rb +1 -1
- data/samples/sample49.rb +1 -1
- data/samples/sample5.rb +2 -2
- data/samples/sample50.rb +1 -1
- data/samples/sample51.rb +2 -2
- data/samples/sample52.rb +1 -1
- data/samples/sample53.rb +1 -1
- data/samples/sample54.rb +2 -2
- data/samples/sample55.rb +1 -1
- data/samples/sample56.rb +1 -1
- data/samples/sample57.rb +1 -1
- data/samples/sample58.rb +2 -2
- data/samples/sample6.rb +1 -1
- data/samples/sample7.rb +1 -1
- data/samples/sample8.rb +2 -2
- data/samples/sample9.rb +2 -2
- data/samples/sample99.rb +1 -1
- data/static/manual-en.txt +27 -2
- data/static/manual-ja.txt +26 -2
- metadata +11 -6
- data/samples/potato_chopping/1258_s060.gif +0 -0
data/lib/shoes/shy.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
#
|
2
|
+
# lib/shoes/shy.rb
|
3
|
+
# Shy, the Shoes YAML archive format
|
4
|
+
#
|
5
|
+
require 'digest/md5'
|
6
|
+
require 'zlib'
|
7
|
+
require 'find'
|
8
|
+
require 'tmpdir'
|
9
|
+
require 'yaml'
|
10
|
+
|
11
|
+
class Shy
|
12
|
+
VERSION = 0x0001
|
13
|
+
MAGIC = "_shy".freeze
|
14
|
+
LAYOUT = "A4vV".freeze #Force to Little Endian for all platforms
|
15
|
+
|
16
|
+
yaml_as 'tag:hackety.org,2007:shy'
|
17
|
+
attr_accessor :name, :creator, :version, :launch
|
18
|
+
|
19
|
+
def self.launchable(d)
|
20
|
+
if File.directory? d
|
21
|
+
Dir["#{d}/**/*.rb"].map do |path|
|
22
|
+
path.gsub(%r!#{Regexp::quote(d)}/!, '')
|
23
|
+
end
|
24
|
+
else
|
25
|
+
[File.basename(d)]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.__hdr__(f)
|
30
|
+
hdr = f.read(10).unpack(LAYOUT)
|
31
|
+
raise IOError, "Invalid header" if hdr[0] != MAGIC and hdr[1] > VERSION
|
32
|
+
YAML.load(f.read(hdr[2]))
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def self.du(root)
|
37
|
+
size = 0
|
38
|
+
Find.find(root) do |path|
|
39
|
+
if FileTest.directory?(path)
|
40
|
+
if File.basename(path)[0] == ?.
|
41
|
+
Find.prune
|
42
|
+
else
|
43
|
+
next
|
44
|
+
end
|
45
|
+
else
|
46
|
+
size += FileTest.size(path)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
size
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.meta(path, d = ".")
|
53
|
+
File.open(path, 'rb') do |f|
|
54
|
+
shy = __hdr__(f)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.x(path, d = ".")
|
59
|
+
File.open(path, 'rb') do |f|
|
60
|
+
shy = __hdr__(f)
|
61
|
+
inp = Zlib::GzipReader.new(f)
|
62
|
+
Archive::Tar::Minitar.unpack(inp, d)
|
63
|
+
shy
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.c(path, shy, d, &blk)
|
68
|
+
path = File.expand_path(path)
|
69
|
+
meta = shy.to_yaml
|
70
|
+
File.open(path, "wb") do |f|
|
71
|
+
f << [MAGIC, VERSION, meta.length].pack(LAYOUT)
|
72
|
+
f << meta
|
73
|
+
self.czf(f, d, &blk)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.progress(total, &blk)
|
78
|
+
if blk
|
79
|
+
last, left = 0.0, total
|
80
|
+
proc do |action, name, stats|
|
81
|
+
if action == :file_progress
|
82
|
+
left -= stats[:currinc]
|
83
|
+
prg = 1.0 - (left.to_f / total.to_f)
|
84
|
+
blk[name, (last = prg), left] if prg - last > 0.02
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.czf(f, d, &blk)
|
91
|
+
total = du(d)
|
92
|
+
out = Zlib::GzipWriter.new(f)
|
93
|
+
files = ["."]
|
94
|
+
unless File.directory? d
|
95
|
+
files = [File.basename(d)]
|
96
|
+
d = File.dirname(d)
|
97
|
+
end
|
98
|
+
Dir.chdir(d) do
|
99
|
+
Archive::Tar::Minitar.pack(files, out, &blk)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.xzf(f, d, &blk)
|
104
|
+
gz = Zlib::GzipReader.new(f)
|
105
|
+
Archive::Tar::Minitar.unpack(gz, d, &blk)
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.md5sum(path)
|
109
|
+
digest = Digest::MD5.new
|
110
|
+
File.open(path, "rb") do |f|
|
111
|
+
digest.update f.read(8192) until f.eof
|
112
|
+
end
|
113
|
+
digest.hexdigest
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.hrun(f)
|
117
|
+
b, i = 0, 1
|
118
|
+
last = 65535
|
119
|
+
while i < last
|
120
|
+
case f.readline
|
121
|
+
when /OLDSKIP=(\d+)/
|
122
|
+
last = $1.to_i
|
123
|
+
when /FULLSIZE=(\d+)/
|
124
|
+
b = $1.to_i
|
125
|
+
end
|
126
|
+
i += 1
|
127
|
+
end
|
128
|
+
b
|
129
|
+
end
|
130
|
+
end
|
data/samples/sample1.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'green_shoes'
|
2
2
|
|
3
3
|
xspeed, yspeed = 10, 6
|
4
4
|
xdir, ydir = 1, 1
|
@@ -10,7 +10,7 @@ Shoes.app width: 300, height: 300 do
|
|
10
10
|
button('stop'){a.stop}
|
11
11
|
button('move'){p.move 200, 30}
|
12
12
|
button('remove'){p.clear}
|
13
|
-
img = image '../static/gshoes-icon.png'
|
13
|
+
img = image File.join(DIR, '../static/gshoes-icon.png')
|
14
14
|
img.click{alert "You're soooo quick!"}
|
15
15
|
|
16
16
|
x, y = 150, 150
|
data/samples/sample10.rb
CHANGED
data/samples/sample11.rb
CHANGED
data/samples/sample12.rb
CHANGED
data/samples/sample13.rb
CHANGED
data/samples/sample14-1.rb
CHANGED
data/samples/sample14.rb
CHANGED
data/samples/sample15.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'green_shoes'
|
2
2
|
|
3
3
|
TEXT =<<EOS
|
4
4
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, \
|
@@ -17,4 +17,4 @@ Shoes.app do
|
|
17
17
|
para lines[0], NL
|
18
18
|
para lines[1], NL, justify: true
|
19
19
|
para lines[2], NL, leading: -5
|
20
|
-
end
|
20
|
+
end
|
data/samples/sample16.rb
CHANGED
data/samples/sample17.rb
CHANGED
data/samples/sample18.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require "
|
1
|
+
require "green_shoes"
|
2
2
|
|
3
3
|
Shoes.app width: 700, height: 600 do
|
4
4
|
title "Shoes is a ", link("tiny"){alert "Cool!"}, " graphics toolkit. "
|
5
5
|
|
6
6
|
flow width: 0.4 do
|
7
|
-
img = image '../static/gshoes-icon.png'
|
7
|
+
img = image File.join(DIR, '../static/gshoes-icon.png')
|
8
8
|
img.click{alert "You're soooo quick!"}
|
9
9
|
end
|
10
10
|
|
data/samples/sample19.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# almost the same code as sample58 on (Red) Shoes Tutorial Note:
|
2
2
|
# http://shoes-tutorial-note.heroku.com/html/00704_Assignment_4_Pong_in_Shoes.html
|
3
|
-
require '
|
3
|
+
require 'green_shoes'
|
4
4
|
|
5
5
|
Shoes.app :width => 400, :height => 400, :resizable => false do
|
6
6
|
vx, vy = 3, 4
|
data/samples/sample2.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
require '
|
1
|
+
require 'green_shoes'
|
2
2
|
|
3
3
|
Shoes.app title: 'Green Shoes New Logo Icon!', width: 300, height: 420 do
|
4
4
|
stack do
|
5
|
-
|
5
|
+
path = File.join(DIR, '../static/gshoes-icon.png')
|
6
|
+
image path
|
6
7
|
flow do
|
7
|
-
image
|
8
|
-
image
|
8
|
+
image path
|
9
|
+
image path
|
9
10
|
end
|
10
|
-
image
|
11
|
+
image path
|
11
12
|
para ' ' * 30, 'Created by Zak'
|
12
13
|
end
|
13
14
|
end
|
data/samples/sample20.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# This is a tiny flip book (aka Para-Para Manga in Japanese)
|
2
2
|
# original is http://www.paraman.net/play/preview/1258
|
3
3
|
#
|
4
|
-
require '
|
4
|
+
require 'green_shoes'
|
5
5
|
|
6
6
|
Shoes.app title: 'potacho', width: 175, height: 160 do
|
7
7
|
background tan
|
8
8
|
|
9
9
|
@imgs = []
|
10
|
-
1.upto
|
11
|
-
@imgs << image("
|
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
12
|
end
|
13
13
|
|
14
14
|
@imgs.first.show
|
15
15
|
|
16
16
|
def potacho
|
17
|
-
@imgs[
|
17
|
+
@imgs[58].hide
|
18
18
|
a = animate 12 do |i|
|
19
19
|
@imgs[i].show
|
20
20
|
@imgs[i-1].hide if i > 0
|
21
|
-
a.stop if i >
|
21
|
+
a.stop if i > 57
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
data/samples/sample21.rb
CHANGED
data/samples/sample22.rb
CHANGED
data/samples/sample23.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'green_shoes'
|
2
2
|
|
3
3
|
Shoes.app width: 300, height: 300 do
|
4
|
-
fname = '../static/gshoes-icon.png'
|
4
|
+
fname = File.join(DIR, '../static/gshoes-icon.png')
|
5
5
|
background yellow..orange, angle: 90
|
6
6
|
border fname, strokewidth: 20, curve: 100
|
7
7
|
fill fname
|
data/samples/sample24.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'green_shoes'
|
2
2
|
|
3
3
|
Shoes.app width: 400, height: 400 do
|
4
4
|
cap [:rect, :curve, :project][rand 3]
|
@@ -8,7 +8,7 @@ Shoes.app width: 400, height: 400 do
|
|
8
8
|
rect 200, 200, 100, 100
|
9
9
|
rect 0, 200, 100, 100
|
10
10
|
rect 200, 0, 100, 100
|
11
|
-
stroke '../static/gshoes-icon.png'
|
11
|
+
stroke File.join(DIR, '../static/gshoes-icon.png')
|
12
12
|
strokewidth 10
|
13
13
|
line 355, 180, 5, 111, strokewidth: 20
|
14
14
|
stroke red
|
data/samples/sample25.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'green_shoes'
|
2
2
|
|
3
3
|
Shoes.app width: 305, height: 460 do
|
4
4
|
background lightskyblue
|
@@ -11,7 +11,7 @@ Shoes.app width: 305, height: 460 do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
image '../static/gshoes-icon.png', margin: 20, margin_left: 80
|
14
|
+
image File.join(DIR, '../static/gshoes-icon.png'), margin: 20, margin_left: 80
|
15
15
|
tagline fg(em(strong('A sample for margin style.')), maroon),
|
16
16
|
margin: [30, 0, 0, 30]
|
17
17
|
|
data/samples/sample26.rb
CHANGED
data/samples/sample27.rb
CHANGED
data/samples/sample28.rb
CHANGED
data/samples/sample29.rb
CHANGED
data/samples/sample3.rb
CHANGED
data/samples/sample30.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Almost same code as sample22.rb : http://shoes-tutorial-note.heroku.com/html/00508_The_Widget_class.html
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'green_shoes'
|
4
4
|
|
5
5
|
class Answer < Shoes::Widget
|
6
6
|
attr_reader :mark
|
7
7
|
def initialize word
|
8
8
|
flow do
|
9
9
|
para word, width: 70
|
10
|
-
@mark = image('
|
10
|
+
@mark = image(File.join(DIR, '../samples/loogink.png'), width: 20, height: 20).hide
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/samples/sample31.rb
CHANGED
data/samples/sample32.rb
CHANGED
data/samples/sample33.rb
CHANGED