1#!/usr/bin/env ruby 2 3require 'tk' 4require 'tkextlib/vu/charts' 5 6####################################### 7 8Tk.root.geometry('+30+30') 9 10delay = 2000 11 12c = TkCanvas.new.pack 13 14begin 15 st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10) 16rescue 17 Tk.messageBox(:type=>'ok', :title=>"No sticker Item", 18 :message=>"This build of vu does not include the sticker item") 19 exit 20end 21#st.delete 22 23steps = [] 24 25steps << proc{ 26 # I used a 75dpi screen for testing, but others should make no difference! 27 puts 'You\'ll see a small upright rectangle with "He" inside.' 28 st = Tk::Vu::TkcSticker.new(c, '6m', '10m', '13m', '27m', :text=>'Hello') 29} 30 31steps << proc{ 32 puts 'You\'ll see the whole "Hello" drawn rotated 90 degrees.' 33 st[:orient] = :vertical 34} 35 36steps << proc{ 37 puts 'The rectangle shrinks and the text is clipped to "Hell"' 38 #st.coords('6m', '10m', '13m', '20m') 39 st.coords('6m', '10m', '13m', '17m') 40} 41 42steps << proc{ 43 puts 'Now you\'ll read "ello"' 44 st[:lefttrunc] = true 45} 46 47steps << proc{ 48 puts 'Enlarging the rectangle shows the complete "Hello" again' 49 st.scale(0, 0, 3, 3) 50} 51 52steps << proc{ 53 puts 'This time the text is repeated: "Hello", approx. 5mm space, "Hello"' 54 st[:space] = '5m' 55} 56 57steps << proc{ 58 puts 'A vertical bar appears in the lower right region and text jumps to the left.' 59 st.configure(:anchor=>:n, :relw=>0.3, :relh=>0.7, 60 :relx=>0.6, :rely=>0.3, :bar=>'red') 61} 62 63steps << proc{ 64 puts 'Paint the backgound.' 65 st[:fill] = 'yellow' 66} 67 68steps << proc{ 69 puts "Let's test stippling." 70 st[:stipple] = 'gray25' 71} 72 73steps << proc{ 74 puts 'Finally a large outline forces a single "Hello" and shrinks the bar.' 75 st[:width] = '6m' 76} 77 78Tk.root.bind('q', proc{exit}) 79 80TkTimer.new(delay, 1, *steps).start 81 82Tk.mainloop 83