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
|
require 'ruby2d'
# set title: "Hello Triangle"
#
# Triangle.new(
# x1: 320, y1: 50,
# x2: 540, y2: 430,
# x3: 100, y3: 430,
# color: ['red', 'green', 'blue']
# )
set width: 1280, height: 770
# # Runs at 6 fps
# 120.times do |i|
# 160.times do |j|
# s = Square.new(x: j*10, y: i*10, size: 10, color: 'random')
# end
# end
# Runs at 11 fps
# 128.times do |i|
# 77.times do |j|
# s = Square.new(x: i*10, y: j*10, size: 10, color: 'random')
# end
# end
fps = Text.new 'fps'
update do
fps.text = Window.fps
end
render do
# # 120.times do |i|
# # 160.times do |j|
# # Quad.draw(j*10, i*10)
# # end
# # end
#
# # 19200.times do
# # Quad.draw(0, 0)
# # end
#
# 120.times do |i|
# 20.times do |j|
# Quad.draw(j*10, i*10 + 20, rand)
# end
# end
#
128.times do |i|
77.times do |j|
Quad.draw(i*10, j*10 + 20, rand)
end
end
end
show
|