summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/tk/sample/tcltklib/lines3.rb
blob: caa50f92e7bf3755e2ea473bb14abacf900afd71 (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
#! /usr/local/bin/ruby

require "tk"

def drawlines()
  print Time.now, "\n"

  for j in 0 .. 99
    print "*"
    $stdout.flush
    if (j & 1) != 0
      col = "blue"
    else
      col = "red"
    end
    for i in 0 .. 99
#      $a.create(TkcLine, i, 0, 0, 500 - i, "fill"=>col)
    end
  end

  print Time.now, "\n"

  for j in 0 .. 99
    print "*"
    $stdout.flush
    if (j & 1) != 0
      col = "blue"
    else
      col = "red"
    end
    for i in 0 .. 99
      $a.create(TkcLine, i, 0, 0, 500 - i, "fill"=>col)
    end
  end

  print Time.now, "\n"
#  Tk.root.destroy
end

$a = TkCanvas.new{
  height(500)
  width(500)
}

$b = TkButton.new{
  text("draw")
  command(proc{drawlines()})
}

TkPack.configure($a, $b, {"side"=>"left"})

Tk.mainloop

# eof