Method: Grid#minmax

Defined in:
lib/cem/cruzzles.rb

#minmax(null = nil) ⇒ Object



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/cem/cruzzles.rb', line 326

def minmax(null=nil)
  min = nil
  max = nil
  
  @data.each_with_index { |l, y|
    l.each_with_index { |c, x|
     
      if c != null
        if min == nil || max == nil
          min = max = Point2D.new(x,y)
        end
        min = Point2D.new([min.x, x].min, [min.y, y].min)
        max = Point2D.new([max.x, x].max, [min.y, y].max)
      end
    }
  }
  
  return min, max
end