Class: Gauguin::Image

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gauguin/image.rb

Defined Under Namespace

Classes: Pixel

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Image

Returns a new instance of Image.



10
11
12
13
14
15
# File 'lib/gauguin/image.rb', line 10

def initialize(path = nil)
  return unless path

  list = Magick::ImageList.new(path)
  self.image = list.first
end

Instance Attribute Details

#imageObject

Returns the value of attribute image.



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

def image
  @image
end

Class Method Details

.blank(columns, rows) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/gauguin/image.rb', line 17

def self.blank(columns, rows)
  blank_image = Image.new
  transparent_white = Magick::Pixel.new(255, 255, 255, Pixel::MAX_TRANSPARENCY)
  blank_image.image = Magick::Image.new(columns, rows) do
    self.background_color = transparent_white
  end
  blank_image
end

Instance Method Details

#pixel(magic_pixel) ⇒ Object



26
27
28
# File 'lib/gauguin/image.rb', line 26

def pixel(magic_pixel)
  Pixel.new(magic_pixel)
end

#pixel_color(row, column, *args) ⇒ Object



30
31
32
33
# File 'lib/gauguin/image.rb', line 30

def pixel_color(row, column, *args)
  magic_pixel = self.image.pixel_color(row, column, *args)
  pixel(magic_pixel)
end