Module: ZPNG::Pixels::ImageEnum

Defined in:
lib/zpng/pixels.rb

Instance Method Summary collapse

Instance Method Details

#eachObject



6
7
8
9
10
11
12
# File 'lib/zpng/pixels.rb', line 6

def each
  @image.height.times do |y|
    @image.width.times do |x|
      yield @image[x,y]
    end
  end
end

#filter!Object Also known as: map!



22
23
24
25
26
27
28
# File 'lib/zpng/pixels.rb', line 22

def filter!
  @image.height.times do |y|
    @image.width.times do |x|
      @image[x,y] = yield(@image[x,y])
    end
  end
end

#keep_if(otherwise = Color::TRANSPARENT) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/zpng/pixels.rb', line 14

def keep_if otherwise = Color::TRANSPARENT
  @image.height.times do |y|
    @image.width.times do |x|
      @image[x,y] = otherwise unless yield(@image[x,y])
    end
  end
end