blob: 67ce1b1d05cd45d3b264a7baa1b469ffbc3668a3 (
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
|
# Ruby2D::Image
module Ruby2D
class Image
include Renderable
attr_reader :path
attr_accessor :x, :y, :width, :height, :rotate, :data
def initialize(path, opts = {})
unless File.exist? path
raise Error, "Cannot find image file `#{path}`"
end
@path = path
@x = opts[:x] || 0
@y = opts[:y] || 0
@z = opts[:z] || 0
@width = opts[:width] || nil
@height = opts[:height] || nil
@rotate = opts[:rotate] || 0
self.color = opts[:color] || 'white'
self.opacity = opts[:opacity] if opts[:opacity]
unless ext_init(@path)
raise Error, "Image `#{@path}` cannot be created"
end
add
end
end
end
|