Module: Bitmapped::Commands::CommandsHelper
- Included in:
- FillCommand, HorizontalLineCommand, PixelFillCommand, VerticalLineCommand
- Defined in:
- lib/bitmapped/commands/commands_helper.rb
Instance Method Summary collapse
Instance Method Details
#coordinates_to_array_indexes(bitmap, x, y) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/bitmapped/commands/commands_helper.rb', line 14 def coordinates_to_array_indexes(bitmap, x, y) x = x.to_i - 1 y = y.to_i - 1 if valid_cooridinates(bitmap, x, y) [x, y] else raise InvalidCoordinatesError end end |
#valid_cooridinates(bitmap, x, y) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/bitmapped/commands/commands_helper.rb', line 6 def valid_cooridinates(bitmap, x, y) if (0 <= x && x <= bitmap.columns) && (0 <= y && y <= bitmap.rows) true else false end end |