summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/tk/sample/tkextlib/vu/canvSticker.rb
blob: 85713ebcf30bde716efbc9a0c368a740a3e34c13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env ruby

require 'tk'
require 'tkextlib/vu/charts'

#######################################

Tk.root.geometry('+30+30')

delay = 2000

c = TkCanvas.new.pack

begin
  st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10)
rescue
  Tk.messageBox(:type=>'ok', :title=>"No sticker Item",
                :message=>"This build of vu does not include the sticker item")
  exit
end
#st.delete

steps = []

steps << proc{
  # I used a 75dpi screen for testing, but others should make no difference!
  puts 'You\'ll see a small upright rectangle with "He" inside.'
  st = Tk::Vu::TkcSticker.new(c, '6m', '10m', '13m', '27m', :text=>'Hello')
}

steps << proc{
  puts 'You\'ll see the whole "Hello" drawn rotated 90 degrees.'
  st[:orient] = :vertical
}

steps << proc{
  puts 'The rectangle shrinks and the text is clipped to "Hell"'
  #st.coords('6m', '10m', '13m', '20m')
  st.coords('6m', '10m', '13m', '17m')
}

steps << proc{
  puts 'Now you\'ll read "ello"'
  st[:lefttrunc] = true
}

steps << proc{
  puts 'Enlarging the rectangle shows the complete "Hello" again'
  st.scale(0, 0, 3, 3)
}

steps << proc{
  puts 'This time the text is repeated: "Hello", approx. 5mm space, "Hello"'
  st[:space] = '5m'
}

steps << proc{
  puts 'A vertical bar appears in the lower right region and text jumps to the left.'
  st.configure(:anchor=>:n, :relw=>0.3, :relh=>0.7,
               :relx=>0.6, :rely=>0.3, :bar=>'red')
}

steps << proc{
  puts 'Paint the backgound.'
  st[:fill] = 'yellow'
}

steps << proc{
  puts "Let's test stippling."
  st[:stipple] = 'gray25'
}

steps << proc{
  puts 'Finally a large outline forces a single "Hello" and shrinks the bar.'
  st[:width] = '6m'
}

Tk.root.bind('q', proc{exit})

TkTimer.new(delay, 1, *steps).start

Tk.mainloop