Class: Pixitar::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/pixitar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image_lib = ChunkyPNG::Image, height = 400, width = 400) ⇒ Image

Returns a new instance of Image.



9
10
11
12
# File 'lib/pixitar.rb', line 9

def initialize(image_lib = ChunkyPNG::Image, height = 400, width = 400)
  @image_lib = image_lib
  @image = image_lib.new(height, width)
end

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image.



7
8
9
# File 'lib/pixitar.rb', line 7

def image
  @image
end

#image_libObject (readonly)

Returns the value of attribute image_lib.



6
7
8
# File 'lib/pixitar.rb', line 6

def image_lib
  @image_lib
end

Instance Method Details

#compose(filename) ⇒ Object



14
15
16
17
# File 'lib/pixitar.rb', line 14

def compose(filename)
  canvas = image_lib.from_file(filename)
  image.compose!(canvas, 0, 0)
end

#save(filename) ⇒ Object



19
20
21
# File 'lib/pixitar.rb', line 19

def save(filename)
  image.save(filename, interlace: true)
end