class FromTo

Public Class Methods

new(image) click to toggle source
# File lib/A_Star.rb, line 4
def initialize image
  @image = image
end

Public Instance Methods

findEnd() click to toggle source
# File lib/A_Star.rb, line 8
def findEnd
  0.upto @image.dimension.width - 1 do |i|
    red = ChunkyPNG::Color.r(@image[i, @image.dimension.height - 1])
    green = ChunkyPNG::Color.g(@image[i, @image.dimension.height - 1])
    blue = ChunkyPNG::Color.b(@image[i, @image.dimension.height - 1])

    if red > 255/2 && green > 255/2 && blue > 255/2
      return [i, @image.dimension.height - 1]
    end
  end
  return Array.new
end
findStart() click to toggle source
# File lib/A_Star.rb, line 21
def findStart
  0.upto @image.dimension.width - 1 do |i|
    red = ChunkyPNG::Color.r(@image[i, 0])
    green = ChunkyPNG::Color.g(@image[i, 0])
    blue = ChunkyPNG::Color.b(@image[i, 0])

    if red > 255/2 && green > 255/2 && blue > 255/2
      return [i, 0]
    end
  end
  return Array.new
end