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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
require 'ruby2d'
# set width: 1280, height: 770
Quad.new(x3: 125, x4: 25)
Rectangle.new(y: 125)
Square.new(y: 250)
Line.new(x1: 5, y1: 375, x2: 95, y2: 475, width: 5)
Triangle.new(x1: 325, y1: 0, x2: 375, y2: 100, x3: 275, y3: 100)
Circle.new(x: 400, y: 175)
render do
Quad.draw(
x1: 125, y1: 0,
x2: 225, y2: 0,
x3: 250, y3: 100,
x4: 150, y4: 100,
color: [
[0.8, 0.3, 0.7, 0.8],
[0.1, 0.9, 0.1, 1.0],
[0.8, 0.5, 0.8, 1.0],
[0.6, 0.4, 0.1, 1.0]
]
)
Rectangle.draw(
x: 225, y: 125, width: 100, height: 100,
color: [
[0.8, 0.3, 0.7, 0.8],
[0.1, 0.9, 0.1, 1.0],
[0.8, 0.5, 0.8, 1.0],
[0.6, 0.4, 0.1, 1.0]
]
)
Square.draw(
x: 125, y: 250, size: 100,
color: [
[0.8, 0.3, 0.7, 0.8],
[0.1, 0.9, 0.1, 1.0],
[0.8, 0.5, 0.8, 1.0],
[0.6, 0.4, 0.1, 1.0]
]
)
Line.draw(
x1: 130, y1: 375, x2: 220, y2: 475, width: 5,
color: [
[0.8, 0.3, 0.7, 0.8],
[0.1, 0.9, 0.1, 1.0],
[0.8, 0.5, 0.8, 1.0],
[0.6, 0.4, 0.1, 1.0]
]
)
Triangle.draw(
x1: 450, y1: 0, x2: 500, y2: 100, x3: 400, y3: 100,
color: [
[0.8, 0.3, 0.7, 0.8],
[0.1, 0.9, 0.1, 1.0],
[0.8, 0.5, 0.8, 1.0]
]
)
Pixel.draw(x: 550, y: 50, size: 10, color: [1.0, 0.0, 0.0, 1.0])
Circle.draw(
x: 525, y: 175, radius: 50, sectors: 30,
color: [0.8, 0.3, 0.7, 0.8]
)
end
show
|