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
|
# File 'lib/demo.rb', line 11
def setup
render_mode(P2D)
no_loop
background(0,0,0)
color_mode(RGB, 1.0)
stroke(1,1,0,1)
@highlight_block = lambda do |original, mapped, s|
s.in_basis do
rect_mode(CENTER)
stroke(1,0,0)
fill(1,0,0)
rect(original[:x], original[:y], 3, 3)
end
end
points = []
200.times {|n|points << {:x => n, :y => random(300)}}
@basis = CoordinateSystem.standard({:minimum => 0, :maximum => 200}, {:minimum => 0, :maximum => 300}, self, {:x => "X-Axis", :y => "Y-Axis"})
screen_transform = Transform.new({:x => 2, :y => -2}, {:x => 300, :y => 900})
@screen = Screen.new(screen_transform, self, @basis)
@screen.draw_axes(10,10, :gridlines => false)
stroke(1,1,0,1)
fill(1,1,0)
rect_mode(CENTER)
@screen.plot(points, :track => true) do |original, mapped, s|
s.in_basis do
rect(original[:x], original[:y], 3, 3)
end
end
end
|