class Magick::Image::View::Rows

Magick::Image::View::Rows

Public Class Methods

new(view, width, height, rows) click to toggle source
# File lib/rmagick_internal.rb, line 1137
def initialize(view, width, height, rows)
  @view = view
  @width = width
  @height = height
  @rows = rows
end

Public Instance Methods

[](*args) click to toggle source
# File lib/rmagick_internal.rb, line 1144
def [](*args)
  cols(args)

  # Both View::Pixels and Magick::Pixel implement Observable
  if @unique
    pixels = @view[@rows[0] * @width + @cols[0]]
    pixels.add_observer(self)
  else
    pixels = View::Pixels.new
    each do |x|
      p = @view[x]
      p.add_observer(self)
      pixels << p
    end
  end
  pixels
end
[]=(*args) click to toggle source
# File lib/rmagick_internal.rb, line 1162
def []=(*args)
  rv = args.delete_at(-1) # get rvalue
  unless rv.is_a?(Pixel) # must be a Pixel or a color name
    begin
      rv = Pixel.from_color(rv)
    rescue TypeError
      Kernel.raise TypeError, "cannot convert #{rv.class} into Pixel"
    end
  end
  cols(args)
  each { |x| @view[x] = rv.dup }
  changed
  notify_observers(self)
end
update(pixel) click to toggle source

A pixel has been modified. Tell the view.

# File lib/rmagick_internal.rb, line 1178
def update(pixel)
  changed
  notify_observers(self)
  pixel.delete_observer(self) # Don't need to hear again.
  nil
end