~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to ext/tk/sample/tkextlib/blt/graph7a.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
require 'tk'
 
3
require 'tkextlib/blt'
 
4
 
 
5
file = File.join(File.dirname(File.expand_path(__FILE__)), 
 
6
                 'images', 'buckskin.gif')
 
7
bgTexture = TkPhotoImage.new(:file=>file)
 
8
 
 
9
TkOption.add('*Graph.Tile', bgTexture)
 
10
TkOption.add('*Label.Tile', bgTexture)
 
11
TkOption.add('*Frame.Tile', bgTexture)
 
12
TkOption.add('*Htext.Tile', bgTexture)
 
13
TkOption.add('*TileOffset', 0)
 
14
TkOption.add('*HighlightThickness',   0)
 
15
TkOption.add('*Element.ScaleSybols',  false)
 
16
TkOption.add('*Element.Smooth',       :linear)
 
17
TkOption.add('*activeLine.Color',     'yellow4')
 
18
TkOption.add('*activeLine.Fill',      'yellow')
 
19
TkOption.add('*activeLine.LineWidth', 0)
 
20
TkOption.add('*Element.Pixels',       3)
 
21
TkOption.add('*Graph.halo',           '7i')
 
22
 
 
23
if Tk.root.winfo_screenvisual != 'staticgray'
 
24
  TkOption.add('*print.background', 'yellow')
 
25
  TkOption.add('*quit.background',  'red')
 
26
end
 
27
 
 
28
length = 250000
 
29
graph = Tk::BLT::Graph.new(:title=>"Scatter Plot\n#{length} points")
 
30
graph.xaxis_configure(:loose=>false, :title=>'X Axis Label')
 
31
graph.yaxis_configure(:title=>'Y Axis Label')
 
32
graph.legend_configure(:activerelief=>:sunken, :background=>'')
 
33
 
 
34
Tk::BLT::Table.add(Tk.root, graph, [0,0], :fill=>:both)
 
35
 
 
36
v_x = Tk::BLT::Vector.new(length)
 
37
v_y = Tk::BLT::Vector.new(length)
 
38
v_x.expr("random(#{v_x})")
 
39
v_y.expr("random(#{v_y})")
 
40
v_x.sort(v_y)
 
41
 
 
42
plot = Tk::BLT::PlotComponent::Element.new(graph, :symbol=>:square, 
 
43
                                           :color=>'green4', :fill=>'green2', 
 
44
                                           :linewidth=>0, :outlinewidth=>1, 
 
45
                                           :pixels=>4, :label=>'plot', 
 
46
                                           :xdata=>v_x, :ydata=>v_y)
 
47
 
 
48
Tk.root.minsize(0, 0)
 
49
 
 
50
#graph.zoom_stack
 
51
#graph.crosshairs
 
52
#graph.active_legend
 
53
#graph.closest_point
 
54
Tk::BLT.zoom_stack(graph)
 
55
Tk::BLT.crosshairs(graph)
 
56
Tk::BLT.active_legend(graph)
 
57
Tk::BLT.closest_point(graph)
 
58
 
 
59
Tk::BLT::Busy.hold(graph)
 
60
Tk.update
 
61
Tk::BLT::Busy.release(graph)
 
62
 
 
63
Tk.mainloop