-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello_world.rb
executable file
·42 lines (31 loc) · 931 Bytes
/
hello_world.rb
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
#! /usr/bin/ruby
require 'rubygems'
require 'bundler/setup'
require 'gosu'
require 'texplay'
class W < Gosu::Window
def initialize
super(500, 500, false, 20)
self.caption = "Hello World"
@img = TexPlay.create_image(self, 300, 400)
# put a border on the image
@img.rect 0,0, @img.width - 1, @img.height - 1
points = []
# NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or 'y'
# NOTE: current maximum points for a bezier is 13
([email protected] + 100).step(40) { |x|
p = TexPlay::TPPoint.new
p.x = x
p.y = @img.height * rand
points << p
}
# making the bezier
@img.bezier points, :color => :red
# NOTE: can 'close' a bezier curve too (as with polylines)
end
def draw
@img.draw 100, 50,1
end
end
w = W.new
w.show