bitmap_cmd_editor 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +3 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +35 -0
- data/bin/bitmap_cmd_editor +10 -0
- data/bitmap_cmd_editor.gemspec +33 -0
- data/features/clear_table.feature +23 -0
- data/features/colours_pixel.feature +30 -0
- data/features/command_bitmap_cmd_editor.feature +48 -0
- data/features/create_bitmap.feature +29 -0
- data/features/draw_horinzontal_segment.feature +33 -0
- data/features/draw_vertical_segment.feature +33 -0
- data/features/fill_region.feature +44 -0
- data/features/show_content.feature +40 -0
- data/features/step_definitions/clear_table_step.rb +4 -0
- data/features/step_definitions/colours_pixel_step.rb +10 -0
- data/features/step_definitions/create_bitmap_step.rb +19 -0
- data/features/support/env.rb +2 -0
- data/lib/bitmap_cmd_editor.rb +3 -0
- data/lib/bitmap_cmd_editor/bitmap.rb +195 -0
- data/lib/bitmap_cmd_editor/client.rb +34 -0
- data/lib/bitmap_cmd_editor/exceptions.rb +17 -0
- data/lib/bitmap_cmd_editor/validators/clear_image_validator.rb +20 -0
- data/lib/bitmap_cmd_editor/validators/colour_pixel_validator.rb +34 -0
- data/lib/bitmap_cmd_editor/validators/command_validator.rb +21 -0
- data/lib/bitmap_cmd_editor/validators/create_image_validator.rb +34 -0
- data/lib/bitmap_cmd_editor/validators/error_message.rb +38 -0
- data/lib/bitmap_cmd_editor/validators/fill_region_validator.rb +34 -0
- data/lib/bitmap_cmd_editor/validators/horizontal_line_validator.rb +38 -0
- data/lib/bitmap_cmd_editor/validators/print_table_validator.rb +20 -0
- data/lib/bitmap_cmd_editor/validators/validator_herlper.rb +33 -0
- data/lib/bitmap_cmd_editor/validators/vertical_line_validator.rb +38 -0
- data/lib/bitmap_cmd_editor/version.rb +27 -0
- metadata +237 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 83ea6dff7912df7eb97e55b8c5e1fc7449c99360
|
4
|
+
data.tar.gz: cbf771084d9a2863758607d49aa25ad96602b47d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2bb8445a8cfbc59d18e7ce67b825ef93c40a4d90ef38694be8c9e78c3927e6ea385c60a6ec54bbe26eee2729fa154f4c03c0d4500c5d6fa61321f1d50b10da03
|
7
|
+
data.tar.gz: fe2a2155685721af6b4196358094c9e1477c5599a59486b18ea907919619674f9d1a53bf3f4fb298645d0e5eeda5d646bc426209f457216f68587aa1d6fad9f0
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Diego Hernán Piccinini Lagos
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# BitmapCmdEditor
|
2
|
+
|
3
|
+
This is an interactive command script, input consists of a string containing a sequence of commands, where a command is represented by a single capital letter at the beginning of the line. Parameters of the command are separated by white spaces and they follow the command character.
|
4
|
+
|
5
|
+
Pixel co-ordinates are a pair of integers: a column number between 1 and 250, and a row number between 1 and 250. Bitmaps starts at coordinates 1,1. Colours are specified by capital letters.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'bitmap_cmd_editor'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install bitmap_cmd_editor
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
After install the gem in your system you will have avaible the command bitmap_cmd_editor.
|
26
|
+
So, run in your terminal `bitmap_cmd_editor` then you should see this:
|
27
|
+
|
28
|
+
Available Commands:
|
29
|
+
-------------------
|
30
|
+
|
31
|
+
I M N - Create a new M x N image with all pixels coloured white (O).
|
32
|
+
C - Clears the table, setting all pixels to white (O).
|
33
|
+
L X Y C - Colours the pixel (X,Y) with colour C.
|
34
|
+
V X Y1 Y2 C - Draw a vertical segment of colour C in column X between rows Y1 and Y2 (inclusive).
|
35
|
+
H X1 X2 Y C - Draw a horizontal segment of colour C in row Y between columns X1 and X2 (inclusive).
|
36
|
+
F X Y C - Fill the region R with the colour C. R is defined as: Pixel (X,Y) belongs to R. Any other pixel which is the same colour as (X,Y) and shares a common side with any pixel in R also belongs to this region.
|
37
|
+
S - Show the contents of the current image
|
38
|
+
X - Terminate the session
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it ( https://github.com/diegopiccinini/bitmap_cmd_editor.git/fork )
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bundler'
|
7
|
+
rescue LoadError => e
|
8
|
+
warn e.message
|
9
|
+
warn "Run `gem install bundler` to install Bundler."
|
10
|
+
exit -1
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
Bundler.setup(:development)
|
15
|
+
rescue Bundler::BundlerError => e
|
16
|
+
warn e.message
|
17
|
+
warn "Run `bundle install` to install missing gems."
|
18
|
+
exit e.status_code
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake'
|
22
|
+
|
23
|
+
require 'rubygems/tasks'
|
24
|
+
Gem::Tasks.new
|
25
|
+
|
26
|
+
YARD::Rake::YardocTask.new do |t|
|
27
|
+
t.files = ['app/**/*.rb', 'lib/**/*.rb', '-', 'doc/FAQ.md', 'doc/Changes.md']
|
28
|
+
t.options = ['--any', '--extra', '--opts'] # optional
|
29
|
+
end
|
30
|
+
|
31
|
+
task :test => :cucumber
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bitmap_cmd_editor/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bitmap_cmd_editor"
|
8
|
+
spec.version = BitmapCmdEditor::VERSION
|
9
|
+
spec.platform = Gem::Platform::RUBY
|
10
|
+
spec.authors = ["Diego Hernán Piccinini Lagos"]
|
11
|
+
spec.email = ["diego@guiasrails.es"]
|
12
|
+
spec.summary = %q{Produce a Ruby 2.0 program that simulates a basic interactive bitmap editor. Bitmaps are represented as an M x N matrix of pixels with each element representing a colour.}
|
13
|
+
spec.description = %q{The input consists of a string containing a sequence of commands, where a command is represented by a single capital letter at the beginning of the line. Parameters of the command are separated by white spaces and they follow the command character.
|
14
|
+
|
15
|
+
Pixel co-ordinates are a pair of integers: a column number between 1 and 250, and a row number between 1 and 250. Bitmaps starts at coordinates 1,1. Colours are specified by capital letters.}
|
16
|
+
spec.homepage = ""
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0")
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
spec.required_ruby_version = ">= 2.0.0"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "shoulda-matchers", '2.8.0'
|
27
|
+
spec.add_development_dependency "rspec-expectations", '3.2.0'
|
28
|
+
spec.add_development_dependency "cucumber", '2.0.0'
|
29
|
+
spec.add_development_dependency "aruba"
|
30
|
+
spec.add_development_dependency "yard"
|
31
|
+
|
32
|
+
spec.has_rdoc = 'yard'
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Feature: Clear table
|
2
|
+
the command C - Clears the table, setting all pixels to white (O)
|
3
|
+
|
4
|
+
Scenario: Cleaning the table
|
5
|
+
Given a bitmap created
|
6
|
+
And The user type "I 5 6"
|
7
|
+
And The user type "L 2 3 A"
|
8
|
+
And the bitmap should be
|
9
|
+
|O|O|O|O|O|
|
10
|
+
|O|O|O|O|O|
|
11
|
+
|O|A|O|O|O|
|
12
|
+
|O|O|O|O|O|
|
13
|
+
|O|O|O|O|O|
|
14
|
+
|O|O|O|O|O|
|
15
|
+
When The user type "C"
|
16
|
+
Then the bitmap should be
|
17
|
+
|O|O|O|O|O|
|
18
|
+
|O|O|O|O|O|
|
19
|
+
|O|O|O|O|O|
|
20
|
+
|O|O|O|O|O|
|
21
|
+
|O|O|O|O|O|
|
22
|
+
|O|O|O|O|O|
|
23
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: Colours a Pixel
|
2
|
+
the command L X Y C - Colours the pixel (X,Y) with colour C.
|
3
|
+
Scenario: Colouring a Bitmap
|
4
|
+
Given a bitmap was created typing the command "I 5 6"
|
5
|
+
When The user type "L 4 1 E"
|
6
|
+
And The user type "L 3 2 B"
|
7
|
+
Then the bitmap should be
|
8
|
+
|O|O|O|E|O|
|
9
|
+
|O|O|B|O|O|
|
10
|
+
|O|O|O|O|O|
|
11
|
+
|O|O|O|O|O|
|
12
|
+
|O|O|O|O|O|
|
13
|
+
|O|O|O|O|O|
|
14
|
+
|
15
|
+
Scenario Outline: Trying to colour a Bitmap with invalid commands
|
16
|
+
Given a bitmap was created typing the command <Command I>
|
17
|
+
When The user tries to colour <Command L>
|
18
|
+
Then He should see the message <Message>
|
19
|
+
|
20
|
+
Examples:
|
21
|
+
|Command I| Command L | Message |
|
22
|
+
| "I 5 6" | "L 7 2 A" | "a valid columns values are between 1 and 5, and you try 7" |
|
23
|
+
| "I 5 6" | "L -1 2 A" | "a valid columns values are between 1 and 5, and you try -1" |
|
24
|
+
| "I 6 3" | "L 3 9 A" | "a valid rows values are between 1 and 3, and you try 9" |
|
25
|
+
| "I 5 4" | "L 3 0 A" | "a valid rows values are between 1 and 4, and you try 0" |
|
26
|
+
| "I 5 4" | "L 3 4 A C" | "this command require 3 arguments" |
|
27
|
+
| "I 5 4" | "L 3 4" | "this command require 3 arguments" |
|
28
|
+
| "I 5 4" | "L S 4 A" | "the coordinates M N must be integers" |
|
29
|
+
| "I 5 4" | "L 4 H A" | "the coordinates M N must be integers" |
|
30
|
+
| "I 5 4" | "L 4 3 5H" | "the colour must be a Capital Letter A-Z" |
|
@@ -0,0 +1,48 @@
|
|
1
|
+
Feature: Command bitmap_cmd_editor
|
2
|
+
Scenario: Welcome Message and Exit
|
3
|
+
When I run `bitmap_cmd_editor` interactively
|
4
|
+
And I type "X"
|
5
|
+
Then it should pass with:
|
6
|
+
"""
|
7
|
+
Welcome to the Bitmap Command Editor
|
8
|
+
------------------------------------
|
9
|
+
|
10
|
+
Available Commands:
|
11
|
+
-------------------
|
12
|
+
|
13
|
+
I M N - Create a new M x N image with all pixels coloured white (O).
|
14
|
+
C - Clears the table, setting all pixels to white (O).
|
15
|
+
L X Y C - Colours the pixel (X,Y) with colour C.
|
16
|
+
V X Y1 Y2 C - Draw a vertical segment of colour C in column X between rows Y1 and Y2 (inclusive).
|
17
|
+
H X1 X2 Y C - Draw a horizontal segment of colour C in row Y between columns X1 and X2 (inclusive).
|
18
|
+
F X Y C - Fill the region R with the colour C. R is defined as: Pixel (X,Y) belongs to R. Any other pixel which is the same colour as (X,Y) and shares a common side with any pixel in R also belongs to this region.
|
19
|
+
S - Show the contents of the current image
|
20
|
+
X - Terminate the session
|
21
|
+
|
22
|
+
End the Session...
|
23
|
+
"""
|
24
|
+
Scenario: Welcome Message and not Exit
|
25
|
+
When I run `bitmap_cmd_editor` interactively
|
26
|
+
And I type "Y"
|
27
|
+
And I type "X"
|
28
|
+
Then it should pass with:
|
29
|
+
"""
|
30
|
+
Welcome to the Bitmap Command Editor
|
31
|
+
------------------------------------
|
32
|
+
|
33
|
+
Available Commands:
|
34
|
+
-------------------
|
35
|
+
|
36
|
+
I M N - Create a new M x N image with all pixels coloured white (O).
|
37
|
+
C - Clears the table, setting all pixels to white (O).
|
38
|
+
L X Y C - Colours the pixel (X,Y) with colour C.
|
39
|
+
V X Y1 Y2 C - Draw a vertical segment of colour C in column X between rows Y1 and Y2 (inclusive).
|
40
|
+
H X1 X2 Y C - Draw a horizontal segment of colour C in row Y between columns X1 and X2 (inclusive).
|
41
|
+
F X Y C - Fill the region R with the colour C. R is defined as: Pixel (X,Y) belongs to R. Any other pixel which is the same colour as (X,Y) and shares a common side with any pixel in R also belongs to this region.
|
42
|
+
S - Show the contents of the current image
|
43
|
+
X - Terminate the session
|
44
|
+
|
45
|
+
This command is not available, please check the available commands
|
46
|
+
|
47
|
+
End the Session...
|
48
|
+
"""
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: Create a Bitmap
|
2
|
+
the command I M N - Create a new M x N image with all pixels coloured white (O).
|
3
|
+
|
4
|
+
Scenario: Create a new M x N image
|
5
|
+
Given a bitmap created
|
6
|
+
When The user type "I 5 6"
|
7
|
+
Then this bitmap should be created
|
8
|
+
|O|O|O|O|O|
|
9
|
+
|O|O|O|O|O|
|
10
|
+
|O|O|O|O|O|
|
11
|
+
|O|O|O|O|O|
|
12
|
+
|O|O|O|O|O|
|
13
|
+
|O|O|O|O|O|
|
14
|
+
|
15
|
+
Scenario Outline: Trying create an invalid image
|
16
|
+
Given a bitmap created
|
17
|
+
When The user attempts to create <Command>
|
18
|
+
Then He should see the message <Message>
|
19
|
+
Examples:
|
20
|
+
| Command | Message |
|
21
|
+
| "I 500 6" | "the maximun columns allowed are 250 and you want 500" |
|
22
|
+
| "I 5 645" | "the maximun rows allowed are 250 and you want 645" |
|
23
|
+
| "I 0 6" | "the minimun columns allowed is 1 and you want 0" |
|
24
|
+
| "I 7 -6" | "the minimun rows allowed is 1 and you want -6" |
|
25
|
+
| "I 500 6" | "the maximun columns allowed are 250 and you want 500" |
|
26
|
+
| "I 7 8 10"| "this command require 2 arguments" |
|
27
|
+
| "I 7" | "this command require 2 arguments" |
|
28
|
+
| "I S 3" | "the coordinates M N must be integers" |
|
29
|
+
| "I 2 H" | "the coordinates M N must be integers" |
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Feature: Draw a horizontal segment
|
2
|
+
With command H X1 X2 Y C - Draw a horizontal segment of colour C
|
3
|
+
in row Y between columns X1 and X2 (inclusive).
|
4
|
+
Scenario: Drawing a horinzontal segment
|
5
|
+
Given a bitmap was created typing the command "I 5 6"
|
6
|
+
When The user type "H 2 4 3 C"
|
7
|
+
Then the bitmap should be
|
8
|
+
|O|O|O|O|O|
|
9
|
+
|O|O|O|O|O|
|
10
|
+
|O|C|C|C|O|
|
11
|
+
|O|O|O|O|O|
|
12
|
+
|O|O|O|O|O|
|
13
|
+
|O|O|O|O|O|
|
14
|
+
|
15
|
+
Scenario Outline: Trying to draw a horizontal line with invalid commands
|
16
|
+
Given a bitmap was created typing the command <Command I>
|
17
|
+
When The user tries to colour <Command L>
|
18
|
+
Then He should see the message <Message>
|
19
|
+
|
20
|
+
Examples:
|
21
|
+
|Command I | Command L | Message |
|
22
|
+
| "I 5 6" | "H 2 7 4 A" | "a valid columns values are between 1 and 5, and you try 7" |
|
23
|
+
| "I 5 6" | "H 2 11 4 A" | "a valid columns values are between 1 and 5, and you try 11" |
|
24
|
+
| "I 5 6" | "H -1 2 4 A" | "a valid columns values are between 1 and 5, and you try -1" |
|
25
|
+
| "I 5 6" | "H 1 -3 4 A" | "a valid columns values are between 1 and 5, and you try -3" |
|
26
|
+
| "I 6 3" | "H 3 5 9 A" | "a valid rows values are between 1 and 3, and you try 9" |
|
27
|
+
| "I 5 4" | "H 3 4 0 A" | "a valid rows values are between 1 and 4, and you try 0" |
|
28
|
+
| "I 5 4" | "H 3 4 A C R" | "this command require 4 arguments" |
|
29
|
+
| "I 5 4" | "H 3 4" | "this command require 4 arguments" |
|
30
|
+
| "I 5 4" | "H S 4 5 A" | "the coordinates M N must be integers" |
|
31
|
+
| "I 5 4" | "H 4 H 6 A" | "the coordinates M N must be integers" |
|
32
|
+
| "I 5 4" | "H 4 2 Z A" | "the coordinates M N must be integers" |
|
33
|
+
| "I 5 4" | "H 4 1 4 5H" | "the colour must be a Capital Letter A-Z" |
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Feature: Draw a vertical segment
|
2
|
+
With command V X Y1 Y2 C - Draw a vertical segment of colour C in column X
|
3
|
+
between rows Y1 and Y2 (inclusive).
|
4
|
+
Scenario: Drawing a vertical segment
|
5
|
+
Given a bitmap was created typing the command "I 5 6"
|
6
|
+
When The user type "V 2 1 4 W"
|
7
|
+
Then the bitmap should be
|
8
|
+
|O|W|O|O|O|
|
9
|
+
|O|W|O|O|O|
|
10
|
+
|O|W|O|O|O|
|
11
|
+
|O|W|O|O|O|
|
12
|
+
|O|O|O|O|O|
|
13
|
+
|O|O|O|O|O|
|
14
|
+
|
15
|
+
Scenario Outline: Trying to draw a vertical line with invalid commands
|
16
|
+
Given a bitmap was created typing the command <Command I>
|
17
|
+
When The user tries to colour <Command L>
|
18
|
+
Then He should see the message <Message>
|
19
|
+
|
20
|
+
Examples:
|
21
|
+
|Command I | Command L | Message |
|
22
|
+
| "I 5 6" | "V 7 2 4 A" | "a valid columns values are between 1 and 5, and you try 7" |
|
23
|
+
| "I 5 6" | "V -1 2 4 A" | "a valid columns values are between 1 and 5, and you try -1" |
|
24
|
+
| "I 6 3" | "V 3 9 3 A" | "a valid rows values are between 1 and 3, and you try 9" |
|
25
|
+
| "I 5 4" | "V 3 0 4 A" | "a valid rows values are between 1 and 4, and you try 0" |
|
26
|
+
| "I 6 3" | "V 3 3 9 A" | "a valid rows values are between 1 and 3, and you try 9" |
|
27
|
+
| "I 5 4" | "V 3 1 -2 A" | "a valid rows values are between 1 and 4, and you try -2" |
|
28
|
+
| "I 5 4" | "V 3 4 A C R" | "this command require 4 arguments" |
|
29
|
+
| "I 5 4" | "V 3 4" | "this command require 4 arguments" |
|
30
|
+
| "I 5 4" | "V S 4 5 A" | "the coordinates M N must be integers" |
|
31
|
+
| "I 5 4" | "V 4 H 6 A" | "the coordinates M N must be integers" |
|
32
|
+
| "I 5 4" | "V 4 2 Z A" | "the coordinates M N must be integers" |
|
33
|
+
| "I 5 4" | "V 4 1 4 5H" | "the colour must be a Capital Letter A-Z" |
|
@@ -0,0 +1,44 @@
|
|
1
|
+
Feature: Fill the region R with the colour C
|
2
|
+
with command F X Y C - Fill the region R with the colour C.
|
3
|
+
R is defined as: Pixel (X,Y) belongs to R.
|
4
|
+
Any other pixel which is the same colour as (X,Y) and shares a common side with any pixel in R also belongs to this region.
|
5
|
+
|
6
|
+
Scenario: Filling a Region
|
7
|
+
Given a bitmap was created typing the command "I 5 6"
|
8
|
+
And The user type "L 4 1 E"
|
9
|
+
And The user type "L 3 2 E"
|
10
|
+
And The user type "L 4 2 E"
|
11
|
+
And The user type "L 3 3 E"
|
12
|
+
And The user type "L 2 5 E"
|
13
|
+
And the bitmap should be
|
14
|
+
|O|O|O|E|O|
|
15
|
+
|O|O|E|E|O|
|
16
|
+
|O|O|E|O|O|
|
17
|
+
|O|O|O|O|O|
|
18
|
+
|O|E|O|O|O|
|
19
|
+
|O|O|O|O|O|
|
20
|
+
When The user type "F 4 2 H"
|
21
|
+
Then the bitmap should be
|
22
|
+
|O|O|O|H|O|
|
23
|
+
|O|O|H|H|O|
|
24
|
+
|O|O|H|O|O|
|
25
|
+
|O|O|O|O|O|
|
26
|
+
|O|E|O|O|O|
|
27
|
+
|O|O|O|O|O|
|
28
|
+
|
29
|
+
Scenario Outline: Trying to filling a Bitmap with invalid commands
|
30
|
+
Given a bitmap was created typing the command <Command I>
|
31
|
+
When The user tries to colour <Command L>
|
32
|
+
Then He should see the message <Message>
|
33
|
+
|
34
|
+
Examples:
|
35
|
+
|Command I| Command L | Message |
|
36
|
+
| "I 5 6" | "F 7 2 A" | "a valid columns values are between 1 and 5, and you try 7" |
|
37
|
+
| "I 5 6" | "F -1 2 A" | "a valid columns values are between 1 and 5, and you try -1" |
|
38
|
+
| "I 6 3" | "F 3 9 A" | "a valid rows values are between 1 and 3, and you try 9" |
|
39
|
+
| "I 5 4" | "F 3 0 A" | "a valid rows values are between 1 and 4, and you try 0" |
|
40
|
+
| "I 5 4" | "F 3 4 A C" | "this command require 3 arguments" |
|
41
|
+
| "I 5 4" | "F 3 4" | "this command require 3 arguments" |
|
42
|
+
| "I 5 4" | "F S 4 A" | "the coordinates M N must be integers" |
|
43
|
+
| "I 5 4" | "F 4 H A" | "the coordinates M N must be integers" |
|
44
|
+
| "I 5 4" | "F 4 3 5H" | "the colour must be a Capital Letter A-Z" |
|