green_shoes 0.179.0 → 0.189.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/shoes/app.rb +57 -16
- data/lib/shoes/basic.rb +2 -1
- data/lib/shoes/helper_methods.rb +1 -0
- data/lib/shoes/main.rb +1 -3
- data/lib/shoes/ruby.rb +72 -7
- data/samples/sample24.rb +1 -0
- data/static/man-ele-image.png +0 -0
- data/static/man-ele-progress.png +0 -0
- data/static/man-ele-shape.png +0 -0
- data/static/man-ele-textblock.png +0 -0
- data/static/manual-en.txt +119 -53
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.189.0
|
data/lib/shoes/app.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
class Shoes
|
2
2
|
class App
|
3
|
-
include Types
|
4
3
|
include Mod2
|
5
4
|
|
6
5
|
def initialize args={}
|
@@ -134,6 +133,7 @@ class Shoes
|
|
134
133
|
|
135
134
|
def image name, args={}
|
136
135
|
args = basic_attributes args
|
136
|
+
args[:full_width] = args[:full_height] = 0
|
137
137
|
if name =~ /^(http|https):\/\//
|
138
138
|
tmpname = File.join(Dir.tmpdir, "__green_shoes_#{Time.now.to_f}.png")
|
139
139
|
d = download name, save: tmpname
|
@@ -143,10 +143,11 @@ class Shoes
|
|
143
143
|
img = Gtk::Image.new name
|
144
144
|
downloading = false
|
145
145
|
end
|
146
|
+
|
146
147
|
if (!args[:width].zero? or !args[:height].zero?) and !downloading
|
147
|
-
|
148
|
-
args[:width] =
|
149
|
-
args[:height] =
|
148
|
+
args[:full_width], args[:full_height] = imagesize(name)
|
149
|
+
args[:width] = args[:full_width] if args[:width].zero?
|
150
|
+
args[:height] = args[:full_height] if args[:height].zero?
|
150
151
|
img = Gtk::Image.new img.pixbuf.scale(args[:width], args[:height])
|
151
152
|
end
|
152
153
|
@canvas.put img, args[:left], args[:top]
|
@@ -312,6 +313,8 @@ class Shoes
|
|
312
313
|
args[:width].zero? ? (args[:width] = args[:radius] * 2) : (args[:radius] = args[:width]/2.0)
|
313
314
|
args[:height] = args[:width] if args[:height].zero?
|
314
315
|
args[:strokewidth] = ( args[:strokewidth] or strokewidth or 1 )
|
316
|
+
args[:angle1] ||= 0
|
317
|
+
args[:angle2] ||= 2*Math::PI
|
315
318
|
|
316
319
|
w, h, mx, my = set_rotate_angle(args)
|
317
320
|
my *= args[:width]/args[:height].to_f
|
@@ -324,7 +327,7 @@ class Shoes
|
|
324
327
|
if pat = (args[:fill] or fill)
|
325
328
|
gp = gradient pat, args[:width], args[:height], args[:angle]
|
326
329
|
context.set_source gp
|
327
|
-
context.arc args[:radius]+mx, args[:radius]-my, args[:radius],
|
330
|
+
context.arc args[:radius]+mx, args[:radius]-my, args[:radius], args[:angle1], args[:angle2]
|
328
331
|
context.fill
|
329
332
|
end
|
330
333
|
|
@@ -332,7 +335,8 @@ class Shoes
|
|
332
335
|
gp = gradient pat, args[:width], args[:height], args[:angle]
|
333
336
|
context.set_source gp
|
334
337
|
context.set_line_width args[:strokewidth]
|
335
|
-
context.arc args[:radius]+mx, args[:radius]-my, args[:radius]-args[:strokewidth]/2.0,
|
338
|
+
context.arc args[:radius]+mx, args[:radius]-my, args[:radius]-args[:strokewidth]/2.0, args[:angle1], args[:angle2]
|
339
|
+
context.set_line_cap cap
|
336
340
|
context.stroke
|
337
341
|
|
338
342
|
img = create_tmp_png surface
|
@@ -343,6 +347,10 @@ class Shoes
|
|
343
347
|
Oval.new args
|
344
348
|
end
|
345
349
|
|
350
|
+
def arc l, t, w, h, a1, a2
|
351
|
+
oval l, t, w, h, angle1: a1, angle2: a2
|
352
|
+
end
|
353
|
+
|
346
354
|
def rect *attrs
|
347
355
|
args = attrs.last.class == Hash ? attrs.pop : {}
|
348
356
|
case attrs.length
|
@@ -393,8 +401,10 @@ class Shoes
|
|
393
401
|
end
|
394
402
|
sx, sy, ex, ey = args[:sx], args[:sy], args[:ex], args[:ey]
|
395
403
|
sw = args[:strokewidth] = ( args[:strokewidth] or strokewidth or 1 )
|
396
|
-
hsw = sw*0.5
|
404
|
+
cw = hsw = sw*0.5
|
397
405
|
args[:width], args[:height] = (sx - ex).abs, (sy - ey).abs
|
406
|
+
args[:width] += cw
|
407
|
+
args[:height] += cw
|
398
408
|
|
399
409
|
args = basic_attributes args
|
400
410
|
surface = Cairo::ImageSurface.new Cairo::FORMAT_ARGB32, args[:width]+sw, args[:height]+sw
|
@@ -406,23 +416,23 @@ class Shoes
|
|
406
416
|
context.set_line_width args[:strokewidth]
|
407
417
|
|
408
418
|
if ((sx - ex) < 0 and (sy - ey) < 0) or ((sx - ex) > 0 and (sy - ey) > 0)
|
409
|
-
context.move_to hsw, hsw
|
419
|
+
context.move_to cw+hsw, cw+hsw
|
410
420
|
context.line_to args[:width]+hsw, args[:height]+hsw
|
411
421
|
args[:left] = (sx - ex) < 0 ? sx - hsw : ex - hsw
|
412
422
|
args[:top] = (sy - ey) < 0 ? sy - hsw : ey - hsw
|
413
423
|
elsif ((sx - ex) < 0 and (sy - ey) > 0) or ((sx - ex) > 0 and (sy - ey) < 0)
|
414
|
-
context.move_to hsw, args[:height]
|
415
|
-
context.line_to args[:width]+hsw, hsw
|
424
|
+
context.move_to cw+hsw, args[:height]+hsw
|
425
|
+
context.line_to args[:width]+hsw, cw+hsw
|
416
426
|
args[:left] = (sx - ex) < 0 ? sx - hsw : ex - hsw
|
417
427
|
args[:top] = (sy - ey) < 0 ? sy - hsw : ey - hsw
|
418
428
|
elsif !(sx - ex).zero? and (sy - ey).zero?
|
419
|
-
context.move_to
|
420
|
-
context.line_to args[:width], hsw
|
429
|
+
context.move_to cw, cw+hsw
|
430
|
+
context.line_to args[:width], cw+hsw
|
421
431
|
args[:left] = (sx - ex) < 0 ? sx : ex
|
422
432
|
args[:top] = (sy - ey) < 0 ? sy - hsw : ey - hsw
|
423
433
|
elsif (sx - ex).zero? and !(sy - ey).zero?
|
424
|
-
context.move_to hsw,
|
425
|
-
context.line_to hsw, args[:height]
|
434
|
+
context.move_to cw+hsw, cw
|
435
|
+
context.line_to cw+hsw, args[:height]
|
426
436
|
args[:left] = (sx - ex) < 0 ? sx - hsw : ex - hsw
|
427
437
|
args[:top] = (sy - ey) < 0 ? sy : ey
|
428
438
|
else
|
@@ -432,9 +442,10 @@ class Shoes
|
|
432
442
|
args[:top] = sy
|
433
443
|
end
|
434
444
|
|
445
|
+
context.set_line_cap cap
|
435
446
|
context.stroke
|
436
447
|
img = create_tmp_png surface
|
437
|
-
@canvas.put img, args[:left], args[:top]
|
448
|
+
@canvas.put img, (args[:left]-=cw), (args[:top]-=cw)
|
438
449
|
img.show_now
|
439
450
|
args[:real], args[:app] = img, self
|
440
451
|
Line.new args
|
@@ -531,7 +542,19 @@ class Shoes
|
|
531
542
|
@fill = false
|
532
543
|
end
|
533
544
|
|
534
|
-
def gradient
|
545
|
+
def gradient *attrs
|
546
|
+
case attrs.length
|
547
|
+
when 1, 2
|
548
|
+
pat1, pat2 = attrs
|
549
|
+
pat2 = pat1 unless pat2
|
550
|
+
return tr_color(pat1)..tr_color(pat2)
|
551
|
+
when 3, 4
|
552
|
+
pat, w, h, angle = attrs
|
553
|
+
angle = 0 unless angle
|
554
|
+
else
|
555
|
+
return black..black
|
556
|
+
end
|
557
|
+
|
535
558
|
pat = tr_color pat
|
536
559
|
color = case pat
|
537
560
|
when Range; [tr_color(pat.first), tr_color(pat.last)]
|
@@ -665,5 +688,23 @@ class Shoes
|
|
665
688
|
top_slot.send m, *args, &blk
|
666
689
|
end
|
667
690
|
end
|
691
|
+
|
692
|
+
def gray *attrs
|
693
|
+
g, a = attrs
|
694
|
+
g ? rgb(g*255, g*255, g*255, a) : rgb(128, 128, 128)[0..2]
|
695
|
+
end
|
696
|
+
|
697
|
+
def cap *line_cap
|
698
|
+
@line_cap = case line_cap.first
|
699
|
+
when :curve
|
700
|
+
Cairo::LineCap::ROUND
|
701
|
+
when :rect
|
702
|
+
Cairo::LineCap::BUTT
|
703
|
+
when :project
|
704
|
+
Cairo::LineCap::SQUARE
|
705
|
+
else
|
706
|
+
@line_cap ||= Cairo::LineCap::BUTT
|
707
|
+
end
|
708
|
+
end
|
668
709
|
end
|
669
710
|
end
|
data/lib/shoes/basic.rb
CHANGED
@@ -52,6 +52,7 @@ class Shoes
|
|
52
52
|
|
53
53
|
def remove
|
54
54
|
@app.canvas.remove @real unless @hided
|
55
|
+
@hided = true if self.is_a?(ShapeBase)
|
55
56
|
end
|
56
57
|
|
57
58
|
def hide
|
@@ -234,7 +235,7 @@ class Shoes
|
|
234
235
|
end
|
235
236
|
|
236
237
|
def text=(s)
|
237
|
-
@textview.buffer.text = s
|
238
|
+
@textview.buffer.text = s.to_s
|
238
239
|
end
|
239
240
|
|
240
241
|
def move2 x, y
|
data/lib/shoes/helper_methods.rb
CHANGED
@@ -317,6 +317,7 @@ class Shoes
|
|
317
317
|
if d.finished?
|
318
318
|
app.canvas.remove e.real
|
319
319
|
img = Gtk::Image.new tmpname
|
320
|
+
e.full_width, e.full_height = img.size_request
|
320
321
|
unless args[:width].zero? and args[:height].zero?
|
321
322
|
img = Gtk::Image.new img.pixbuf.scale(args[:width], args[:height])
|
322
323
|
end
|
data/lib/shoes/main.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
class Shoes
|
2
|
-
include Types
|
3
2
|
@apps = []
|
4
3
|
$urls = {}
|
5
4
|
APPS = []
|
@@ -20,8 +19,7 @@ class Shoes
|
|
20
19
|
|
21
20
|
app.top_slot = Flow.new app.slot_attributes(app: app, left: 0, top: 0)
|
22
21
|
|
23
|
-
win =
|
24
|
-
win.icon = Gdk::Pixbuf.new File.join(DIR, '../static/gshoes-icon.png')
|
22
|
+
win = get_win
|
25
23
|
win.title = args[:title]
|
26
24
|
win.set_default_size args[:width], args[:height]
|
27
25
|
|
data/lib/shoes/ruby.rb
CHANGED
@@ -6,33 +6,92 @@ class Range
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class Object
|
9
|
+
include Types
|
9
10
|
def alert msg
|
10
11
|
dialog = Gtk::MessageDialog.new(
|
11
|
-
|
12
|
+
get_win,
|
12
13
|
Gtk::Dialog::MODAL,
|
13
14
|
Gtk::MessageDialog::INFO,
|
14
15
|
Gtk::MessageDialog::BUTTONS_OK,
|
15
16
|
msg
|
16
17
|
)
|
17
|
-
dialog.title = "Shoes says:"
|
18
|
+
dialog.title = "Green Shoes says:"
|
18
19
|
dialog.run
|
19
20
|
dialog.destroy
|
20
21
|
end
|
22
|
+
|
23
|
+
def confirm msg
|
24
|
+
dialog = Gtk::Dialog.new(
|
25
|
+
"Green Shoes asks:",
|
26
|
+
get_win,
|
27
|
+
Gtk::Dialog::MODAL | Gtk::Dialog::DESTROY_WITH_PARENT,
|
28
|
+
[Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT],
|
29
|
+
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_REJECT]
|
30
|
+
)
|
31
|
+
dialog.vbox.add Gtk::Label.new msg
|
32
|
+
dialog.set_size_request 300, 100
|
33
|
+
dialog.show_all
|
34
|
+
ret = dialog.run == Gtk::Dialog::RESPONSE_ACCEPT ? true : false
|
35
|
+
dialog.destroy
|
36
|
+
ret
|
37
|
+
end
|
38
|
+
|
39
|
+
def ask msg
|
40
|
+
dialog = Gtk::Dialog.new(
|
41
|
+
"Green Shoes asks:",
|
42
|
+
get_win,
|
43
|
+
Gtk::Dialog::MODAL | Gtk::Dialog::DESTROY_WITH_PARENT,
|
44
|
+
[Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT],
|
45
|
+
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_REJECT]
|
46
|
+
)
|
47
|
+
dialog.vbox.add Gtk::Label.new msg
|
48
|
+
dialog.vbox.add(el = Gtk::Entry.new)
|
49
|
+
dialog.set_size_request 300, 100
|
50
|
+
dialog.show_all
|
51
|
+
ret = dialog.run == Gtk::Dialog::RESPONSE_ACCEPT ? el.text : nil
|
52
|
+
dialog.destroy
|
53
|
+
ret
|
54
|
+
end
|
21
55
|
|
22
56
|
def ask_open_file
|
57
|
+
dialog_chooser "Open File...", Gtk::FileChooser::ACTION_OPEN, Gtk::Stock::OPEN
|
58
|
+
end
|
59
|
+
|
60
|
+
def ask_save_file
|
61
|
+
dialog_chooser "Save File...", Gtk::FileChooser::ACTION_SAVE, Gtk::Stock::SAVE
|
62
|
+
end
|
63
|
+
|
64
|
+
def ask_open_folder
|
65
|
+
dialog_chooser "Open Folder...", Gtk::FileChooser::ACTION_SELECT_FOLDER, Gtk::Stock::OPEN
|
66
|
+
end
|
67
|
+
|
68
|
+
def ask_save_folder
|
69
|
+
dialog_chooser "Save Folder...", Gtk::FileChooser::ACTION_CREATE_FOLDER, Gtk::Stock::SAVE
|
70
|
+
end
|
71
|
+
|
72
|
+
def dialog_chooser title, action, button
|
23
73
|
dialog = Gtk::FileChooserDialog.new(
|
24
|
-
|
25
|
-
|
26
|
-
|
74
|
+
title,
|
75
|
+
get_win,
|
76
|
+
action,
|
27
77
|
nil,
|
28
78
|
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
|
29
|
-
[
|
79
|
+
[button, Gtk::Dialog::RESPONSE_ACCEPT]
|
30
80
|
)
|
31
81
|
ret = dialog.run == Gtk::Dialog::RESPONSE_ACCEPT ? dialog.filename : nil
|
32
82
|
dialog.destroy
|
33
83
|
ret
|
34
84
|
end
|
35
|
-
|
85
|
+
|
86
|
+
def ask_color title = 'Pick a color...'
|
87
|
+
dialog = Gtk::ColorSelectionDialog.new title
|
88
|
+
dialog.icon = Gdk::Pixbuf.new File.join(DIR, '../static/gshoes-icon.png')
|
89
|
+
dialog.run
|
90
|
+
ret = dialog.colorsel.current_color.to_a.map{|c| c / 65535.0}
|
91
|
+
dialog.destroy
|
92
|
+
ret
|
93
|
+
end
|
94
|
+
|
36
95
|
def exit
|
37
96
|
Shoes.APPS.length.times {|i| timer(0.01*i){Gtk.main_quit}}
|
38
97
|
File.delete Shoes::TMP_PNG_FILE if File.exist? Shoes::TMP_PNG_FILE
|
@@ -41,6 +100,12 @@ class Object
|
|
41
100
|
def to_s
|
42
101
|
super.gsub('<', '[').gsub('>', ']')
|
43
102
|
end
|
103
|
+
|
104
|
+
def get_win
|
105
|
+
Gtk::Window.new.tap do |s|
|
106
|
+
s.icon = Gdk::Pixbuf.new File.join(DIR, '../static/gshoes-icon.png')
|
107
|
+
end
|
108
|
+
end
|
44
109
|
end
|
45
110
|
|
46
111
|
class String
|
data/samples/sample24.rb
CHANGED
data/static/man-ele-image.png
CHANGED
Binary file
|
data/static/man-ele-progress.png
CHANGED
Binary file
|
data/static/man-ele-shape.png
CHANGED
Binary file
|
Binary file
|
data/static/manual-en.txt
CHANGED
@@ -599,10 +599,7 @@ But these are built-in methods (also called: Kernel methods.) Which means no dot
|
|
599
599
|
A common one is `alert`:
|
600
600
|
|
601
601
|
{{{
|
602
|
-
|
603
|
-
Shoes.app do
|
604
|
-
alert "No dots in sight"
|
605
|
-
end
|
602
|
+
alert "No dots in sight"
|
606
603
|
}}}
|
607
604
|
|
608
605
|
Compare that to the method `reverse`, which isn't a Kernel method and is only
|
@@ -632,6 +629,8 @@ are trying to sniff out what release of Green Shoes is running.
|
|
632
629
|
|
633
630
|
'''FONTS''' is a complete list of fonts available to the app.
|
634
631
|
|
632
|
+
'''VERSION''' is a Green Shoes version.
|
633
|
+
|
635
634
|
{{{
|
636
635
|
Shoes.app do
|
637
636
|
para VERSION
|
@@ -648,7 +647,7 @@ Pops up a window containing a short message.
|
|
648
647
|
|
649
648
|
{{{
|
650
649
|
#!ruby
|
651
|
-
|
650
|
+
alert "I'm afraid I must interject!"
|
652
651
|
}}}
|
653
652
|
|
654
653
|
Please use alerts sparingly, as they are incredibly annoying! If you are using
|
@@ -662,8 +661,9 @@ their name.
|
|
662
661
|
|
663
662
|
{{{
|
664
663
|
#!ruby
|
665
|
-
|
666
|
-
|
664
|
+
if name = ask("Please, enter your name:")
|
665
|
+
Shoes.app{para "Welcome, #{name}!"}
|
666
|
+
end
|
667
667
|
}}}
|
668
668
|
|
669
669
|
When the above script is run, the person at the computer will see a window with
|
@@ -678,10 +678,9 @@ use this color.
|
|
678
678
|
|
679
679
|
{{{
|
680
680
|
#!ruby
|
681
|
-
|
682
|
-
backcolor = ask_color("Pick a background")
|
681
|
+
backcolor = ask_color "Pick a background"
|
683
682
|
Shoes.app do
|
684
|
-
|
683
|
+
background backcolor
|
685
684
|
end
|
686
685
|
}}}
|
687
686
|
|
@@ -693,8 +692,8 @@ file.
|
|
693
692
|
|
694
693
|
{{{
|
695
694
|
#!ruby
|
695
|
+
filename = ask_open_file
|
696
696
|
Shoes.app do
|
697
|
-
filename = ask_open_file
|
698
697
|
para File.read(filename)
|
699
698
|
end
|
700
699
|
}}}
|
@@ -706,8 +705,10 @@ previously.
|
|
706
705
|
|
707
706
|
{{{
|
708
707
|
#!ruby
|
709
|
-
# Not yet available
|
710
708
|
save_as = ask_save_file
|
709
|
+
Shoes.app do
|
710
|
+
para save_as
|
711
|
+
end
|
711
712
|
}}}
|
712
713
|
|
713
714
|
=== ask_open_folder() » a string ===
|
@@ -718,7 +719,6 @@ the folder.
|
|
718
719
|
|
719
720
|
{{{
|
720
721
|
#!ruby
|
721
|
-
# Not yet available
|
722
722
|
folder = ask_open_folder
|
723
723
|
Shoes.app do
|
724
724
|
para Dir.entries(folder)
|
@@ -728,13 +728,14 @@ the folder.
|
|
728
728
|
=== ask_save_folder() » a string ===
|
729
729
|
|
730
730
|
Pops up a "Save folder..." window, similiar to `ask_open_folder`, described
|
731
|
-
previously.
|
732
|
-
`ask_open_folder`.
|
731
|
+
previously.
|
733
732
|
|
734
733
|
{{{
|
735
734
|
#!ruby
|
736
|
-
# Not yet available
|
737
735
|
save_to = ask_save_folder
|
736
|
+
Shoes.app do
|
737
|
+
para save_to
|
738
|
+
end
|
738
739
|
}}}
|
739
740
|
|
740
741
|
|
@@ -745,9 +746,8 @@ you'll get back a `true`. If not, you'll get back `false`.
|
|
745
746
|
|
746
747
|
{{{
|
747
748
|
#!ruby
|
748
|
-
# Not yet available
|
749
749
|
if confirm("Draw a circle?")
|
750
|
-
Shoes.app{ oval :
|
750
|
+
Shoes.app{ oval top: 0, left: 0, radius: 50 }
|
751
751
|
end
|
752
752
|
}}}
|
753
753
|
|
@@ -786,31 +786,46 @@ available to you on this platform. You can check for a certain font by using
|
|
786
786
|
`include?`.
|
787
787
|
|
788
788
|
{{{
|
789
|
-
Shoes.
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
end
|
795
|
-
end
|
789
|
+
if Shoes::FONTS.include? "Coolvetica"
|
790
|
+
alert "Coolvetica is available on this system."
|
791
|
+
else
|
792
|
+
alert "You do not have the Coolvetica font."
|
793
|
+
end
|
796
794
|
}}}
|
797
795
|
|
798
796
|
If you have trouble with fonts showing up, make sure your app loads the font
|
799
797
|
before it is used. Especially on OS X, if fonts are used before they are
|
800
798
|
loaded, the font cache will tend to ignore loaded fonts.
|
801
799
|
|
802
|
-
===
|
800
|
+
=== gradient(color1, color2) » a range of RGB array ===
|
801
|
+
|
802
|
+
Builds a linear gradient from two colors. For each color, you may pass in
|
803
|
+
a color/rgb method or a string describing the color. The `gradient(green, red)` is
|
804
|
+
the same as `green..red` for example. Also possible to use different kind of args
|
805
|
+
like this: `gradient(green, '#FA3')`
|
806
|
+
|
807
|
+
{{{
|
808
|
+
Shoes.app do
|
809
|
+
oval 100, 100, 100, fill: gradient(green, '#FA3'), angle: 45
|
810
|
+
end
|
811
|
+
}}}
|
812
|
+
|
813
|
+
=== gray(the numbers: darkness, alpha) » a RGB array ===
|
803
814
|
|
804
815
|
Create a grayscale color from a level of darkness and, optionally, an alpha
|
805
816
|
level.
|
806
817
|
|
807
818
|
{{{
|
808
|
-
|
809
|
-
|
810
|
-
|
819
|
+
Shoes.app do
|
820
|
+
nostroke
|
821
|
+
11.times do |i|
|
822
|
+
y = x = 50 + 10 * i
|
823
|
+
r = 200 - 10 * i
|
824
|
+
oval x, y, r, fill: gray(1-i*0.1)
|
825
|
+
end
|
826
|
+
end
|
811
827
|
}}}
|
812
828
|
|
813
|
-
|
814
829
|
=== rgb(red, green, blue, alpha) » an array of decimal numbers ===
|
815
830
|
|
816
831
|
Create a color from red, green and blue components. An alpha level (indicating
|
@@ -1729,14 +1744,28 @@ allows images and gradients to be used for drawing lines and filling in shapes.
|
|
1729
1744
|
Shoes also borrows some animation ideas from Processing and will continue to
|
1730
1745
|
closely consult Processing's methods as it expands.
|
1731
1746
|
|
1732
|
-
=== arc(left, top, width, height, angle1, angle2) » Shoes::
|
1747
|
+
=== arc(left, top, width, height, angle1, angle2) » Shoes::Oval ===
|
1733
1748
|
|
1734
1749
|
Draws an arc shape (a section of an oval) at coordinates (left, top). This
|
1735
1750
|
method just give you a bit more control than [[oval]], by offering the
|
1736
1751
|
`:angle1` and `:angle2` styles. (In fact, you can mimick the `oval` method by
|
1737
|
-
setting `:angle1` to 0 and `:angle2` to `
|
1752
|
+
setting `:angle1` to 0 and `:angle2` to `2*Math::PI`.)
|
1738
1753
|
|
1739
|
-
|
1754
|
+
{{{
|
1755
|
+
Shoes.app do
|
1756
|
+
fill yellow..green
|
1757
|
+
stroke red..blue
|
1758
|
+
strokewidth 10
|
1759
|
+
cap :curve
|
1760
|
+
|
1761
|
+
a = animate 12 do |i|
|
1762
|
+
@e.remove if @e
|
1763
|
+
r = i * (Math::PI * 0.01)
|
1764
|
+
@e = arc 100, 50, 180, 360, 0, i * (Math::PI * 0.01)
|
1765
|
+
a.stop if r >= 2*Math::PI
|
1766
|
+
end
|
1767
|
+
end
|
1768
|
+
}}}
|
1740
1769
|
|
1741
1770
|
=== arrow(left, top, width) » Shoes::Shape ===
|
1742
1771
|
|
@@ -1750,7 +1779,25 @@ Sets the line cap, which is the shape at the end of every line you draw. If
|
|
1750
1779
|
set to `:curve`, the end is rounded. The default is `:rect`, a line which ends
|
1751
1780
|
abruptly flat. The `:project` cap is also fat, but sticks out a bit longer.
|
1752
1781
|
|
1753
|
-
|
1782
|
+
{{{
|
1783
|
+
Shoes.app do
|
1784
|
+
nofill
|
1785
|
+
strokewidth 20
|
1786
|
+
stroke green
|
1787
|
+
cap :curve
|
1788
|
+
line 100, 100, 300, 100
|
1789
|
+
line 100, 250, 300, 300
|
1790
|
+
cap :rect
|
1791
|
+
line 100, 150, 300, 150
|
1792
|
+
stroke blue
|
1793
|
+
cap :project
|
1794
|
+
line 100, 200, 300, 200
|
1795
|
+
line 200, 100, 200, 300
|
1796
|
+
strokewidth 1
|
1797
|
+
stroke red
|
1798
|
+
rect 100, 100, 200, 200
|
1799
|
+
end
|
1800
|
+
}}}
|
1754
1801
|
|
1755
1802
|
=== fill(pattern) » pattern ===
|
1756
1803
|
|
@@ -3239,7 +3286,7 @@ Fills the edit line with the characters of `a string`.
|
|
3239
3286
|
|
3240
3287
|
== Image ==
|
3241
3288
|
|
3242
|
-
An image is a picture in PNG, JPEG or GIF format. Shoes can resize images or
|
3289
|
+
An image is a picture in PNG, JPEG or GIF format. Green Shoes can resize images or
|
3243
3290
|
flow them in with text. Images can be loaded from a file or directly off the
|
3244
3291
|
web. !{:margin_left => 100}man-ele-image.png!
|
3245
3292
|
|
@@ -3253,7 +3300,7 @@ To create an image, use the `image` method in a slot:
|
|
3253
3300
|
end
|
3254
3301
|
}}}
|
3255
3302
|
|
3256
|
-
When you load any image into Shoes, it is cached in memory. This means that if
|
3303
|
+
When you load any image into Green Shoes, it is cached in memory. This means that if
|
3257
3304
|
you load up many image elements from the same file, it'll only really load the
|
3258
3305
|
file once.
|
3259
3306
|
|
@@ -3271,7 +3318,9 @@ in memory. This prevents a repeat download unless the image has changed. (In
|
|
3271
3318
|
case you're wondering: Shoes keeps track of modification times and etags just
|
3272
3319
|
like a browser would.)
|
3273
3320
|
|
3274
|
-
Shoes
|
3321
|
+
'''Note:''' Green Shoes doesn't support the hard drive cache management feature like Red Shoes.
|
3322
|
+
|
3323
|
+
Green Shoes also loads remote images in the background using system threads. So,
|
3275
3324
|
using remote images will not block Ruby or any intense graphical displays you
|
3276
3325
|
may have going on.
|
3277
3326
|
|
@@ -3294,10 +3343,14 @@ explanation of why you might use this method rather than [[Common.width]].
|
|
3294
3343
|
|
3295
3344
|
The URL or file name of the image.
|
3296
3345
|
|
3346
|
+
'''Note:''' Green Shoes doesn't support `path` method.
|
3347
|
+
|
3297
3348
|
=== path = a string ===
|
3298
3349
|
|
3299
3350
|
Swaps the image with a different one, loaded from a file or URL.
|
3300
3351
|
|
3352
|
+
'''Note:''' Green Shoes doesn't support `path=` method.
|
3353
|
+
|
3301
3354
|
== ListBox ==
|
3302
3355
|
|
3303
3356
|
List boxes (also called "combo boxes" or "drop-down boxes" or "select boxes" in
|
@@ -3376,12 +3429,14 @@ now. If nothing is selected, `nil` will be the reply.
|
|
3376
3429
|
== Progress ==
|
3377
3430
|
|
3378
3431
|
Progress bars show you how far along you are in an activity. Usually, a
|
3379
|
-
progress bar represents a percentage (from 0% to 100%.) Shoes thinks of
|
3432
|
+
progress bar represents a percentage (from 0% to 100%.) Green Shoes thinks of
|
3380
3433
|
progress in terms of the decimal numbers 0.0 to 1.0. !{:margin_left =>
|
3381
3434
|
100}man-ele-progress.png!
|
3382
3435
|
|
3383
|
-
A simple progress bar is
|
3384
|
-
(as with all Shoes elements) to lengthen it.
|
3436
|
+
A simple progress bar is 150 pixels wide, but you can use the `:width` style
|
3437
|
+
(as with all Green Shoes elements) to lengthen it.
|
3438
|
+
|
3439
|
+
'''Note:''' The minimum size is 150 pixels wide in Green Shoes.
|
3385
3440
|
|
3386
3441
|
{{{
|
3387
3442
|
Shoes.app do
|
@@ -3495,6 +3550,8 @@ Clicks are sent for both marking and unmarking the radio.
|
|
3495
3550
|
Moves focus to the radio. The radio will be highlighted and, if the user hits
|
3496
3551
|
Enter, the radio will be toggled between its marked and unmarked states.
|
3497
3552
|
|
3553
|
+
'''Note:''' Green Shoes doesn't support `focus` method.
|
3554
|
+
|
3498
3555
|
== Shape ==
|
3499
3556
|
|
3500
3557
|
A shape is a path outline usually created by drawing methods like `oval` and
|
@@ -3507,7 +3564,7 @@ See the [[Common]] methods page. Shapes respond to all of those methods.
|
|
3507
3564
|
The TextBlock object represents a group of text organized as a single element.
|
3508
3565
|
A paragraph containing bolded text, for example. A caption containing links and
|
3509
3566
|
bolded text. (So, a `caption` is a TextBlock type. However, `link` and
|
3510
|
-
`strong` are
|
3567
|
+
`strong` are Text types.) !{:margin_left => 100}man-ele-textblock.png!
|
3511
3568
|
|
3512
3569
|
All of the various types of TextBlock are found on the [[Element Element
|
3513
3570
|
Creation]] page.
|
@@ -3524,6 +3581,8 @@ Creation]] page.
|
|
3524
3581
|
|
3525
3582
|
Lists all of the strings and styled text objects inside this block.
|
3526
3583
|
|
3584
|
+
'''Note:''' Green Shoes doesn't support `contents` method.
|
3585
|
+
|
3527
3586
|
=== replace(a string) ===
|
3528
3587
|
|
3529
3588
|
Replaces the text of the entire block with the characters of `a string`.
|
@@ -3543,30 +3602,35 @@ Replaces the text of the entire block with the characters of `a string`.
|
|
3543
3602
|
An alias for [[TextBlock.text]]. Returns a flattened string of all of this
|
3544
3603
|
TextBlock's contents.
|
3545
3604
|
|
3605
|
+
'''Note:''' Green Shoes doesn't support `to_s` method.
|
3606
|
+
|
3546
3607
|
== Timers ==
|
3547
3608
|
|
3548
|
-
Shoes contains three
|
3549
|
-
|
3550
|
-
start.
|
3609
|
+
Green Shoes contains three timers: the animate, every and
|
3610
|
+
timer. Both animate and every loop over and over after they
|
3611
|
+
start. The timer happens once. A one-shot timer.
|
3551
3612
|
|
3552
|
-
|
3553
|
-
|
3613
|
+
The animate and every are basically the same thing. The difference is that
|
3614
|
+
the animate usually happen many, many times per second. And the every happens only
|
3554
3615
|
once every few seconds or rarely.
|
3555
3616
|
|
3617
|
+
The animate and every automatically start themselves.
|
3618
|
+
|
3556
3619
|
=== start() » self ===
|
3557
3620
|
|
3558
3621
|
Both types of timers automatically start themselves, so there's no need to use
|
3559
3622
|
this normally. But if you [[Timers.stop]] a timer and would like to start it up
|
3560
3623
|
again, then by all means: use this!
|
3561
3624
|
|
3625
|
+
'''Note:''' Green Shoes doesn't support `start` method.
|
3626
|
+
|
3562
3627
|
=== stop() » self ===
|
3563
3628
|
|
3564
|
-
|
3565
|
-
happened, it's already stopped and this method will have no effect.
|
3629
|
+
Stops the animate or every loop.
|
3566
3630
|
|
3567
|
-
===
|
3631
|
+
=== pause() » self ===
|
3568
3632
|
|
3569
|
-
If the
|
3633
|
+
Pauses the animate or every loop. If the animate or every loop is stopped, it is started. Otherwise, if it is
|
3570
3634
|
already running, it is stopped.
|
3571
3635
|
|
3572
3636
|
== Video ==
|
@@ -3574,7 +3638,9 @@ already running, it is stopped.
|
|
3574
3638
|
Shoes supports embedding of QuickTime, Flash video (FLV), DivX, Xvid and
|
3575
3639
|
various other popular video formats. This is all thanks to VideoLAN and ffmpeg,
|
3576
3640
|
two sensational open source libraries. Use the `video` method on a slot to
|
3577
|
-
setup a Shoes::Video object.
|
3641
|
+
setup a Shoes::Video object.
|
3642
|
+
|
3643
|
+
'''Note:''' Green Shoes doesn't support any video formats. !{:margin_left => 100}man-ele-video.png!
|
3578
3644
|
|
3579
3645
|
In addition to video formats, some audio formats are also supported, such as
|
3580
3646
|
MP3, WAV and Ogg Vorbis.
|
@@ -3666,5 +3732,5 @@ Have fun!
|
|
3666
3732
|
Hope this helps:
|
3667
3733
|
|
3668
3734
|
* You can join [[http://librelist.com/browser/shoes/ Shoes ML]] and feel free ask your questions.
|
3669
|
-
* [[
|
3670
|
-
* [[http://
|
3735
|
+
* [[https://github.com/ashbb/green_shoes/ Current Source Code]] is on GitHub.
|
3736
|
+
* Green Shoes Gem is on [[http://rubygems.org/gems/green_shoes RubyGems.org]].
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 189
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.189.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- ashbb
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-17 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|