summaryrefslogtreecommitdiff
path: root/ext/tk/sample/tcltklib/lines4.rb
blob: 37ffc0ee743f64f9f0f0f9c8184e591acd0e1f44 (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
#! /usr/local/bin/ruby
# frozen_string_literal: false

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
#      TkCore::INTERP.__invoke($a.path, "create", "line", i.to_s, '0', '0', (500 - i).to_s, "-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
      TkCore::INTERP.__invoke($a.path, "create", "line", i.to_s, '0', '0', (500 - i).to_s, "-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