Решение на Трета задача от Йордан Пулов

Обратно към всички решения

Към профила на Йордан Пулов

Резултати

  • 2 точки от тестове
  • 0 бонус точки
  • 2 точки общо
  • 26 успешни тест(а)
  • 43 неуспешни тест(а)

Код

require 'matrix.rb'
class Matrix
def []= (i,j,x)
@rows[i][j] = x
end
end
module Graphics
class Canvas
attr_reader :height , :width
def initialize(x,y)
@layout = Matrix.build(x, y) {false}
@height , @width = x , y
end
def set_pixel(x,y)
@layout[x,y] = true
self
end
def pixel_at?(x,y)
@layout[x,y]
end
def draw(figure)
figure.layout.each_with_index do |col,row|
draw_inner_loop(col,row) if (col)
end
self
end
def draw_inner_loop(col,row)
col.each { |value| set_pixel(value,row) if value }
end
def render_as(renderer)
output = renderer::RENDER[:header]
@layout.each_with_index do|val , _ , coll|
pixel = val ? renderer::RENDER[:render][1] : renderer::RENDER[:render][0]
output << pixel
output << renderer::RENDER[:newline] if coll == width-1
end
output<<renderer::RENDER[:footer]
end
end
class Point
attr_reader :x , :y ,:layout
def initialize(x,y)
@layout =[]
@layout[x]=[y]
@x , @y = x , y
end
end
class Line
attr_reader :from , :to ,:layout
def initialize(start_point,end_point)
@layout =[]
@from = start_point
(start_point.x).upto(end_point.x) { |i| @layout[i] = [] }
if(start_point.x ==end_point.x or start_point.y == end_point.y)
then
straight_line(start_point,end_point)
else
bresenham(start_point,end_point)
end
end
def bresenham(start_point,end_point)
@horizontal_length=end_point.x-start_point.x
@vertical_length=end_point.y-start_point.y
@equation = 2*@vertical_length -@horizontal_length
@layout[start_point.x] = [start_point.y]
@end_point_changing=end_point.y
bresenham_line_loop(start_point,end_point)
end
def bresenham_line_loop(start_point,end_point)
(start_point.x+1).upto(end_point.x) do |i|
if @equation > 0
then
bresenham_equation_greater(i)
else
bresenham_equation_lower(i)
end
@to = Point.new i , @end_point_changing
end
end
def bresenham_equation_greater(i)
@end_point_changing = @end_point_changing+1
@layout[i].push(@end_point_changing)
@equation = @equation + (2*@vertical_length-2*@horizontal_length)
end
def bresenham_equation_lower(i)
@layout[i].push(@end_point_changing)
@equation =@equation + (2*@vertical_length)
end
def straight_line(start_point,end_point)
(start_point.x).upto(end_point.x) { |i| @layout[i] =[start_point.y , end_point.y] }
(start_point.y).upto(end_point.y) do |i|
@layout[start_point.x] .push(i)
@layout[end_point.x] .push(i)
end
@to = end_point
end
end
class Rectangle
attr_reader :top_left , :top_right , :bottom_left , :bottom_right ,:layout
def initialize(start_point,end_point)
@layout =[]
@top_left , @top_right = start_point , Point.new(start_point.x,end_point.y)
@bottom_left = Point.new(end_point.x,start_point.y)
@bottom_right = end_point
draw_it(start_point,end_point)
end
def draw_it(start_point,end_point)
(start_point.x).upto(end_point.x) { |i| @layout[i] =[start_point.y , end_point.y] }
(start_point.y).upto(end_point.y) do |i|
@layout[start_point.x] .push(i)
@layout[end_point.x] .push(i)
end
end
end
module Renderers
module Ascii
RENDER = {footer: "" , header: "" , render: ["-" ,"@"] , newline: "\n"}
end
module Html
RENDER = {footer: " </div>
</body>
</html>" , header: ' <!DOCTYPE html>
<html>
<head>
<title>Rendered Canvas</title>
<style type="text/css">
.canvas {
font-size: 1px;
line-height: 1px;
}
.canvas * {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 5px;
}
.canvas i {
background-color: #eee;
}
.canvas b {
background-color: #333;
}
</style>
</head>
<body>
<div class="canvas">' , render: ["<i></i>" ,"<b></b>"] , newline: "<br/> \n"}
end
end
end

Лог от изпълнението

...F....FFFFFFFFFFFFFFFF.FFF....F.FF.....FFFF.FFFFF...F.F.FFFFFF.FFF.

Failures:

  1) Graphics Canvas exposes its width and height via getters
     Failure/Error: canvas.width.should eq 5
       
       expected: 5
            got: 10
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:18:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Graphics Canvas drawing of shapes and rasterization renders multiple drawn shapes
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@------@@-@-@\n@-@---@@@---@-@\n@-@-@@------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n"
       
       (compared using ==)
       
       Diff:
       @@ -2,9 +2,9 @@
        @-------------@
        @-@@@@@@@@@@@-@
        @-@---------@-@
       -@-@------@@-@-@
       -@-@---@@@---@-@
       -@-@-@@------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
        @-@---------@-@
        @-@-@@@@----@-@
        @-@-@-------@-@
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:211:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) Graphics Canvas drawing of shapes and rasterization of points works for a single one
     Failure/Error: canvas.pixel_at?(2, 4).should be_true
       expected: true value
            got: false
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:48:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) Graphics Canvas drawing of shapes and rasterization of points works for multiple ones
     Failure/Error: canvas.set_pixel 4, 4
     NoMethodError:
       undefined method `[]=' for nil:NilClass
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:4:in `[]='
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:17:in `set_pixel'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:57:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) Graphics Canvas drawing of shapes and rasterization of lines works with simple horizontal lines
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "--------\n---@@@@-\n--------"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,24 @@
       ---------
       ----@@@@-
       ---------
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:73:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  6) Graphics Canvas drawing of shapes and rasterization of lines works with vertical lines
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n"
       
       (compared using ==)
       
       Diff:
       @@ -1,3 +1,26 @@
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
        -@------
        -@------
        -@------
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:84:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  7) Graphics Canvas drawing of shapes and rasterization of lines works with lines with a small slope
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "----------\n-@@-------\n---@@@@---\n-------@@-\n----------"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n-----\n-@---\n-----\n--@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n"
       
       (compared using ==)
       
       Diff:
       @@ -1,6 +1,42 @@
       -----------
       --@@-------
       ----@@@@---
       --------@@-
       -----------
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +--------
       +-----
       +-@---
       +-----
       +--@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:100:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  8) Graphics Canvas drawing of shapes and rasterization of lines works with lines with a significant slope, with swapped ends
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "----------\n-@--------\n-@--------\n--@-------\n--@-------\n--@-------\n--@-------\n---@------\n---@------\n----------"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n-----\n-@---\n-----\n--@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n---@------\n----------\n"
       
       (compared using ==)
       
       Diff:
       
       @@ -1,11 +1,52 @@
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +--------
       +-----
       +-@---
       +-----
       +--@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
        ----------
       --@--------
       --@--------
       ---@-------
       ---@-------
       ---@-------
       ---@-------
       ----@------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
        ---@------
        ----------
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:113:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  9) Graphics Canvas drawing of shapes and rasterization of lines works with multiple lines
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "-@--------\n-@@-------\n-@-@@@@---\n-@-----@@-\n----------"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n-----\n-@---\n-----\n--@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n---@------\n----------\n-@---\n-@---\n-@---\n-@@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n"
       
       (compared using ==)
       
       Diff:
       
       @@ -1,6 +1,62 @@
       --@--------
       --@@-------
       --@-@@@@---
       --@-----@@-
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +--------
       +-----
       +-@---
       +-----
       +--@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
        ----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +---@------
       +----------
       +-@---
       +-@---
       +-@---
       +-@@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:132:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  10) Graphics Canvas drawing of shapes and rasterization of lines draws lines with two equal ends as points
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "---\n-@-\n---"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n-----\n-@---\n-----\n--@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n---@------\n----------\n-@---\n-@---\n-@---\n-@@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n---\n-@-\n---\n"
       
       (compared using ==)
       
       Diff:
       @@ -1,3 +1,64 @@
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +--------
       +-----
       +-@---
       +-----
       +--@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +---@------
       +----------
       +-@---
       +-@---
       +-@---
       +-@@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
        ---
        -@-
        ---
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:145:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  11) Graphics Canvas drawing of shapes and rasterization of rectangles works with simple rects
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "----------\n-@@@@@@@@-\n-@------@-\n-@@@@@@@@-\n----------"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n-----\n-@---\n-----\n--@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n---@------\n----------\n-@---\n-@---\n-@---\n-@@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n---\n-@-\n---\n-----\n-@@@@\n@@@@-@---\n---@-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n"
       
       (compared using ==)
       
       Diff:
       
       
       @@ -1,6 +1,75 @@
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +--------
       +-----
       +-@---
       +-----
       +--@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
        ----------
       --@@@@@@@@-
       --@------@-
       --@@@@@@@@-
        ----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +---@------
       +----------
       +-@---
       +-@---
       +-@---
       +-@@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
       +---
       +-@-
       +---
       +-----
       +-@@@@
       +@@@@-@---
       +---@-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:158:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  12) Graphics Canvas drawing of shapes and rasterization of rectangles works with rects defined with their bottom left and top right points
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "----------\n-@@@@@@@@-\n-@------@-\n-@@@@@@@@-\n----------"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n-----\n-@---\n-----\n--@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n---@------\n----------\n-@---\n-@---\n-@---\n-@@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n---\n-@-\n---\n-----\n-@@@@\n@@@@-@---\n---@-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n-----\n-@@@@\n@@@@-----\n-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n"
       
       (compared using ==)
       
       Diff:
       
       
       @@ -1,6 +1,85 @@
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +--------
       +-----
       +-@---
       +-----
       +--@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
        ----------
       --@@@@@@@@-
       --@------@-
       --@@@@@@@@-
        ----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +---@------
       +----------
       +-@---
       +-@---
       +-@---
       +-@@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
       +---
       +-@-
       +---
       +-----
       +-@@@@
       +@@@@-@---
       +---@-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +-@@@@
       +@@@@-----
       +-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:171:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  13) Graphics Canvas drawing of shapes and rasterization of rectangles works with rects with a zero height as a line
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "----------\n-@@@@@@@@-\n----------"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n-----\n-@---\n-----\n--@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n---@------\n----------\n-@---\n-@---\n-@---\n-@@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n---\n-@-\n---\n-----\n-@@@@\n@@@@-@---\n---@-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n-----\n-@@@@\n@@@@-----\n-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n---\n-@@\n@@@@@@---\n---\n---\n---\n---\n---\n---\n---\n"
       
       (compared using ==)
       
       Diff:
       
       
       @@ -1,4 +1,95 @@
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +--------
       +-----
       +-@---
       +-----
       +--@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
        ----------
       --@@@@@@@@-
        ----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +---@------
       +----------
       +-@---
       +-@---
       +-@---
       +-@@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
       +---
       +-@-
       +---
       +-----
       +-@@@@
       +@@@@-@---
       +---@-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +-@@@@
       +@@@@-----
       +-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +---
       +-@@
       +@@@@@@---
       +---
       +---
       +---
       +---
       +---
       +---
       +---
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:184:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  14) Graphics Canvas drawing of shapes and rasterization of rectangles works with rects with a zero width and height as a single point
     Failure/Error: ascii.should eq rendering(expected)
       
       expected: "---\n-@-\n---"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n-----\n-@---\n-----\n--@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n---@------\n----------\n-@---\n-@---\n-@---\n-@@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n---\n-@-\n---\n-----\n-@@@@\n@@@@-@---\n---@-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n-----\n-@@@@\n@@@@-----\n-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n---\n-@@\n@@@@@@---\n---\n---\n---\n---\n---\n---\n---\n---\n-@-\n---\n"
       
       (compared using ==)
       
       Diff:
       @@ -1,3 +1,97 @@
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +--------
       +-----
       +-@---
       +-----
       +--@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +---@------
       +----------
       +-@---
       +-@---
       +-@---
       +-@@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
       +---
       +-@-
       +---
       +-----
       +-@@@@
       +@@@@-@---
       +---@-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +-@@@@
       +@@@@-----
       +-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +---
       +-@@
       +@@@@@@---
       +---
       +---
       +---
       +---
       +---
       +---
       +---
        ---
        -@-
        ---
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:624:in `check_rendering_of'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:195:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  15) Graphics Renderers Ascii renders a grid of the size of the canvas
     Failure/Error: lines.size.should eq 3
       
       expected: 3
            got: 101
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:240:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  16) Graphics Renderers Ascii renders blank canvases
     Failure/Error: canvas.render_as(ascii).should eq rendering('
       
       expected: "----\n----\n----"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n-----\n-@---\n-----\n--@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n---@------\n----------\n-@---\n-@---\n-@---\n-@@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n---\n-@-\n---\n-----\n-@@@@\n@@@@-@---\n---@-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n-----\n-@@@@\n@@@@-----\n-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n---\n-@@\n@@@@@@---\n---\n---\n---\n---\n---\n---\n---\n---\n-@-\n---\n---\n---\n---\n---\n---\n---\n---\n---\n"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,106 @@
       -----
       -----
       -----
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +--------
       +-----
       +-@---
       +-----
       +--@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +---@------
       +----------
       +-@---
       +-@---
       +-@---
       +-@@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
       +---
       +-@-
       +---
       +-----
       +-@@@@
       +@@@@-@---
       +---@-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +-@@@@
       +@@@@-----
       +-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +---
       +-@@
       +@@@@@@---
       +---
       +---
       +---
       +---
       +---
       +---
       +---
       +---
       +-@-
       +---
       +---
       +---
       +---
       +---
       +---
       +---
       +---
       +---
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:245:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  17) Graphics Renderers Ascii renders simple canvases
     Failure/Error: canvas.render_as(ascii).should eq rendering('
       
       expected: "@---\n----\n---@"
            got: "@@@@@@@@@@@@@@@\n@-------------@\n@-@@@@@@@@@@@-@\n@-@---------@-@\n@-@--@@@@@@-@-@\n@-@---------@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@-@@@@----@-@\n@-@-@-------@-@\n@-@---------@-@\n@-@---------@-@\n@-@@@@@@@@@@@-@\n@-------------@\n@@@@@@@@@@@@@@@\n---\n---\n@@@@---\n---\n---\n---\n---\n---\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n-@------\n--------\n-----\n-@---\n-----\n--@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n----------\n---@------\n----------\n-@---\n-@---\n-@---\n-@@--\n---@@\n@@-----\n--@@-----\n-----\n-----\n-----\n---\n-@-\n---\n-----\n-@@@@\n@@@@-@---\n---@-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n-----\n-@@@@\n@@@@-----\n-@@@@\n@@@@-----\n-----\n-----\n-----\n-----\n-----\n---\n-@@\n@@@@@@---\n---\n---\n---\n---\n---\n---\n---\n---\n-@-\n---\n---\n---\n---\n---\n---\n---\n---\n---\n@--\n---\n---\n--@\n"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,110 @@
       -@---
       -----
       ----@
       +@@@@@@@@@@@@@@@
       +@-------------@
       +@-@@@@@@@@@@@-@
       +@-@---------@-@
       +@-@--@@@@@@-@-@
       +@-@---------@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@-@@@@----@-@
       +@-@-@-------@-@
       +@-@---------@-@
       +@-@---------@-@
       +@-@@@@@@@@@@@-@
       +@-------------@
       +@@@@@@@@@@@@@@@
       +---
       +---
       +@@@@---
       +---
       +---
       +---
       +---
       +---
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +-@------
       +--------
       +-----
       +-@---
       +-----
       +--@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +----------
       +---@------
       +----------
       +-@---
       +-@---
       +-@---
       +-@@--
       +---@@
       +@@-----
       +--@@-----
       +-----
       +-----
       +-----
       +---
       +-@-
       +---
       +-----
       +-@@@@
       +@@@@-@---
       +---@-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +-@@@@
       +@@@@-----
       +-@@@@
       +@@@@-----
       +-----
       +-----
       +-----
       +-----
       +-----
       +---
       +-@@
       +@@@@@@---
       +---
       +---
       +---
       +---
       +---
       +---
       +---
       +---
       +-@-
       +---
       +---
       +---
       +---
       +---
       +---
       +---
       +---
       +---
       +@--
       +---
       +---
       +--@
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:256:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  18) Graphics Renderers Html renders a grid of the size of the canvas
     Failure/Error: lines.size.should eq 3
       
       expected: 3
            got: 1
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:283:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  19) Graphics Renderers Html renders simple canvases
     Failure/Error: html_rendering_of(canvas).should eq [
       
       expected: "<i></i><i></i><i></i><i></i><br><i></i><b></b><i></i><i></i><br><i></i><b></b><i></i><i></i>"
            got: "<i></i><i></i><i></i><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/>"
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:291:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  20) Graphics Renderers Html returns the same rendering when called twice
     Failure/Error: second_rendering.should eq first_rendering
       
       expected: "<!doctypehtml><html><head><title>renderedcanvas</title><styletype=\"text/css\">.canvas{font-size:1px;line-height:1px;}.canvas*{display:inline-block;width:10px;height:10px;border-radius:5px;}.canvasi{background-color:#eee;}.canvasb{background-color:#333;}</style></head><body><divclass=\"canvas\"><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/></div></body></html><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/></div></body></html><i></i><i></i><i></i><br/><i></i><b></b><b></b><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/></div></body></html><i></i><i></i><i></i><br/><i></i><b></b><b></b><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/></div></body></html>"
            got: "<!doctypehtml><html><head><title>renderedcanvas</title><styletype=\"text/css\">.canvas{font-size:1px;line-height:1px;}.canvas*{display:inline-block;width:10px;height:10px;border-radius:5px;}.canvasi{background-color:#eee;}.canvasb{background-color:#333;}</style></head><body><divclass=\"canvas\"><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/></div></body></html><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/></div></body></html><i></i><i></i><i></i><br/><i></i><b></b><b></b><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/></div></body></html><i></i><i></i><i></i><br/><i></i><b></b><b></b><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/></div></body></html><i></i><i></i><i></i><br/><i></i><b></b><b></b><br/><i></i><i></i><i></i><br/><i></i><i></i><i></i><br/></div></body></html>"
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:305:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  21) Graphics shapes Point comparison for equality is true if coordinates are the same
     Failure/Error: (a1 == a2).should be_true
       expected: true value
            got: false
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:348:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  22) Graphics shapes Point comparison for equality works for eql? as well
     Failure/Error: a1.should eql a2
       
       expected: #<Graphics::Point:0xb9885680 @layout=[nil, nil, nil, nil, [5]], @x=4, @y=5>
            got: #<Graphics::Point:0xb9885748 @layout=[nil, nil, nil, nil, [5]], @x=4, @y=5>
       
       (compared using eql?)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Graphics::Point:0xb9885680 @layout=[nil, nil, nil, nil, [5]], @x=4, @y=5>
       +#<Graphics::Point:0xb9885748 @layout=[nil, nil, nil, nil, [5]], @x=4, @y=5>
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:356:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  23) Graphics shapes Point comparison for equality returns the same hash for the same points
     Failure/Error: a1.hash.should eq a2.hash
       
       expected: 660643498
            got: 527059378
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:361:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  24) Graphics shapes Line initialization with swapped points puts the leftmost point in the from field
     Failure/Error: inverted_line.from.x.should eq 1
       
       expected: 1
            got: 25
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:402:in `block (6 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  25) Graphics shapes Line initialization with swapped points puts the rightmost point in the to field
     Failure/Error: inverted_line.to.x.should eq 25
     NoMethodError:
       undefined method `x' for nil:NilClass
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:407:in `block (6 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  26) Graphics shapes Line initialization with swapped points puts the top point of vertical lines in the from field
     Failure/Error: vertical_line.from.y.should eq 1
       
       expected: 1
            got: 8
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:413:in `block (6 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  27) Graphics shapes Line initialization with swapped points puts the bottom point of vertical lines in the to field
     Failure/Error: vertical_line.to.y.should eq 8
       
       expected: 8
            got: 1
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:418:in `block (6 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  28) Graphics shapes Line comparison for equality is true if line ends are the same
     Failure/Error: (a == b).should be_true
       expected: true value
            got: false
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:435:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  29) Graphics shapes Line comparison for equality is true if line ends are the same, even if swapped
     Failure/Error: (a == b).should be_true
       expected: true value
            got: false
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:442:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  30) Graphics shapes Line comparison for equality is true if line is vertical and the bottom is given first
     Failure/Error: (a == b).should be_true
       expected: true value
            got: false
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:449:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  31) Graphics shapes Line comparison for equality works with eql? as well
     Failure/Error: a.should eql b
       
       expected: #<Graphics::Line:0xba0a22f0 @layout=[nil, [1], [15], [16], [17], [18], [19], [20], [21], [22], [23]], @from=#<Graphics::Point:0xba0a24a8 @layout=[nil, [1]], @x=1, @y=1>, @to=#<Graphics::Point:0xba0a1b84 @layout=[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [23]], @x=10, @y=23>, @horizontal_length=9, @vertical_length=13, @equation=89, @end_point_changing=23>
            got: #<Graphics::Line:0xba0a2b4c @layout=[nil, [1], [15], [16], [17], [18], [19], [20], [21], [22], [23]], @from=#<Graphics::Point:0xba0a2c14 @layout=[nil, [1]], @x=1, @y=1>, @to=#<Graphics::Point:0xba0a2570 @layout=[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [23]], @x=10, @y=23>, @horizontal_length=9, @vertical_length=13, @equation=89, @end_point_changing=23>
       
       (compared using eql?)
       
       Diff:
       
       
       @@ -1,11 +1,11 @@
       -#<Graphics::Line:0xba0a22f0
       +#<Graphics::Line:0xba0a2b4c
         @end_point_changing=23,
         @equation=89,
       - @from=#<Graphics::Point:0xba0a24a8 @layout=[nil, [1]], @x=1, @y=1>,
       + @from=#<Graphics::Point:0xba0a2c14 @layout=[nil, [1]], @x=1, @y=1>,
         @horizontal_length=9,
         @layout=[nil, [1], [15], [16], [17], [18], [19], [20], [21], [22], [23]],
         @to=
       -  #<Graphics::Point:0xba0a1b84
       +  #<Graphics::Point:0xba0a2570
           @layout=[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [23]],
           @x=10,
           @y=23>,
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:457:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  32) Graphics shapes Line comparison for equality returns the same hash if the lines are the same
     Failure/Error: a.hash.should eq b.hash
       
       expected: 565301642
            got: 83656196
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:465:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  33) Graphics shapes Rectangle initialization allows accessing its left and right points via getters
     Failure/Error: rect.left.x.should eq 3
     NoMethodError:
       undefined method `left' for #<Graphics::Rectangle:0xb9fdb3f8>
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:490:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  34) Graphics shapes Rectangle initialization puts the leftmost point in its left field
     Failure/Error: Graphics::Rectangle.new(*args)
     NoMethodError:
       undefined method `push' for nil:NilClass
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:117:in `block in draw_it'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:116:in `upto'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:116:in `draw_it'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:112:in `initialize'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:615:in `new'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:615:in `make_rectangle'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:505:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  35) Graphics shapes Rectangle comparison for equality is true if rectangle points are the same
     Failure/Error: (a == b).should be_true
       expected: true value
            got: false
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:526:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  36) Graphics shapes Rectangle comparison for equality is true if rectangle points are the same, even if swapped
     Failure/Error: (a == b).should be_true
       expected: true value
            got: false
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:533:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  37) Graphics shapes Rectangle comparison for equality is true for rectangles defined with different diagonal corners
     Failure/Error: Graphics::Rectangle.new(*args)
     NoMethodError:
       undefined method `push' for nil:NilClass
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:117:in `block in draw_it'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:116:in `upto'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:116:in `draw_it'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:112:in `initialize'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:615:in `new'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:615:in `make_rectangle'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:538:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  38) Graphics shapes Rectangle comparison for equality works with eql? as well
     Failure/Error: a.should eql b
       
       expected: #<Graphics::Rectangle:0xb9fc5a6c @layout=[nil, [1, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [1, 14], [1, 14], [1, 14], [1, 14], [1, 14], [1, 14], [1, 14], [1, 14], [1, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]], @top_right=#<Graphics::Point:0xb9fc5a1c @layout=[nil, [14]], @x=1, @y=14>, @top_left=#<Graphics::Point:0xb9fc5c38 @layout=[nil, [1]], @x=1, @y=1>, @bottom_left=#<Graphics::Point:0xb9fc59a4 @layout=[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [1]], @x=10, @y=1>, @bottom_right=#<Graphics::Point:0xb9fc5af8 @layout=[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [14]], @x=10, @y=14>>
            got: #<Graphics::Rectangle:0xb9fc5ef4 @layout=[nil, [1, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [1, 14], [1, 14], [1, 14], [1, 14], [1, 14], [1, 14], [1, 14], [1, 14], [1, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]], @top_right=#<Graphics::Point:0xb9fc5ecc @layout=[nil, [14]], @x=1, @y=14>, @top_left=#<Graphics::Point:0xb9fc6020 @layout=[nil, [1]], @x=1, @y=1>, @bottom_left=#<Graphics::Point:0xb9fc5ddc @layout=[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [1]], @x=10, @y=1>, @bottom_right=#<Graphics::Point:0xb9fc5fa8 @layout=[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [14]], @x=10, @y=14>>
       
       (compared using eql?)
       
       Diff:
       
       
       @@ -1,11 +1,11 @@
       -#<Graphics::Rectangle:0xb9fc5a6c
       +#<Graphics::Rectangle:0xb9fc5ef4
         @bottom_left=
       -  #<Graphics::Point:0xb9fc59a4
       +  #<Graphics::Point:0xb9fc5ddc
           @layout=[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [1]],
           @x=10,
           @y=1>,
         @bottom_right=
       -  #<Graphics::Point:0xb9fc5af8
       +  #<Graphics::Point:0xb9fc5fa8
           @layout=[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [14]],
           @x=10,
           @y=14>,
       @@ -21,6 +21,6 @@
           [1, 14],
           [1, 14],
           [1, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]],
       - @top_left=#<Graphics::Point:0xb9fc5c38 @layout=[nil, [1]], @x=1, @y=1>,
       - @top_right=#<Graphics::Point:0xb9fc5a1c @layout=[nil, [14]], @x=1, @y=14>>
       + @top_left=#<Graphics::Point:0xb9fc6020 @layout=[nil, [1]], @x=1, @y=1>,
       + @top_right=#<Graphics::Point:0xb9fc5ecc @layout=[nil, [14]], @x=1, @y=14>>
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:548:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  39) Graphics shapes Rectangle comparison for equality returns the same hash if the rectangles are the same
     Failure/Error: a.hash.should eq b.hash
       
       expected: -974617516
            got: 1049722704
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:556:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  40) Graphics shapes Rectangle comparison for equality returns the same hash for rectangles defined with different diagonal corners
     Failure/Error: Graphics::Rectangle.new(*args)
     NoMethodError:
       undefined method `push' for nil:NilClass
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:117:in `block in draw_it'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:116:in `upto'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:116:in `draw_it'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:112:in `initialize'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:615:in `new'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:615:in `make_rectangle'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:561:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  41) Graphics shapes Rectangle corners top left
     Failure/Error: rect.top_left.y.should eq 2
       
       expected: 2
            got: 4
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:578:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  42) Graphics shapes Rectangle corners top right
     Failure/Error: rect.top_right.x.should eq 5
       
       expected: 5
            got: 1
       
       (compared using ==)
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:583:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  43) Graphics shapes Rectangle corners bottom right
     Failure/Error: Graphics::Rectangle.new(*args)
     NoMethodError:
       undefined method `push' for nil:NilClass
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:117:in `block in draw_it'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:116:in `upto'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:116:in `draw_it'
     # /tmp/d20131223-4637-1jwrv3p/solution.rb:112:in `initialize'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:615:in `new'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:615:in `make_rectangle'
     # /tmp/d20131223-4637-1jwrv3p/spec.rb:588:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.13698 seconds
69 examples, 43 failures

Failed examples:

rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:16 # Graphics Canvas exposes its width and height via getters
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:203 # Graphics Canvas drawing of shapes and rasterization renders multiple drawn shapes
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:45 # Graphics Canvas drawing of shapes and rasterization of points works for a single one
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:51 # Graphics Canvas drawing of shapes and rasterization of points works for multiple ones
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:69 # Graphics Canvas drawing of shapes and rasterization of lines works with simple horizontal lines
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:80 # Graphics Canvas drawing of shapes and rasterization of lines works with vertical lines
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:96 # Graphics Canvas drawing of shapes and rasterization of lines works with lines with a small slope
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:109 # Graphics Canvas drawing of shapes and rasterization of lines works with lines with a significant slope, with swapped ends
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:127 # Graphics Canvas drawing of shapes and rasterization of lines works with multiple lines
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:141 # Graphics Canvas drawing of shapes and rasterization of lines draws lines with two equal ends as points
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:154 # Graphics Canvas drawing of shapes and rasterization of rectangles works with simple rects
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:167 # Graphics Canvas drawing of shapes and rasterization of rectangles works with rects defined with their bottom left and top right points
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:180 # Graphics Canvas drawing of shapes and rasterization of rectangles works with rects with a zero height as a line
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:191 # Graphics Canvas drawing of shapes and rasterization of rectangles works with rects with a zero width and height as a single point
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:237 # Graphics Renderers Ascii renders a grid of the size of the canvas
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:244 # Graphics Renderers Ascii renders blank canvases
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:252 # Graphics Renderers Ascii renders simple canvases
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:280 # Graphics Renderers Html renders a grid of the size of the canvas
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:287 # Graphics Renderers Html renders simple canvases
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:298 # Graphics Renderers Html returns the same rendering when called twice
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:347 # Graphics shapes Point comparison for equality is true if coordinates are the same
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:355 # Graphics shapes Point comparison for equality works for eql? as well
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:360 # Graphics shapes Point comparison for equality returns the same hash for the same points
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:401 # Graphics shapes Line initialization with swapped points puts the leftmost point in the from field
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:406 # Graphics shapes Line initialization with swapped points puts the rightmost point in the to field
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:411 # Graphics shapes Line initialization with swapped points puts the top point of vertical lines in the from field
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:416 # Graphics shapes Line initialization with swapped points puts the bottom point of vertical lines in the to field
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:431 # Graphics shapes Line comparison for equality is true if line ends are the same
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:438 # Graphics shapes Line comparison for equality is true if line ends are the same, even if swapped
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:445 # Graphics shapes Line comparison for equality is true if line is vertical and the bottom is given first
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:452 # Graphics shapes Line comparison for equality works with eql? as well
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:461 # Graphics shapes Line comparison for equality returns the same hash if the lines are the same
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:487 # Graphics shapes Rectangle initialization allows accessing its left and right points via getters
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:504 # Graphics shapes Rectangle initialization puts the leftmost point in its left field
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:522 # Graphics shapes Rectangle comparison for equality is true if rectangle points are the same
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:529 # Graphics shapes Rectangle comparison for equality is true if rectangle points are the same, even if swapped
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:536 # Graphics shapes Rectangle comparison for equality is true for rectangles defined with different diagonal corners
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:543 # Graphics shapes Rectangle comparison for equality works with eql? as well
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:552 # Graphics shapes Rectangle comparison for equality returns the same hash if the rectangles are the same
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:559 # Graphics shapes Rectangle comparison for equality returns the same hash for rectangles defined with different diagonal corners
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:575 # Graphics shapes Rectangle corners top left
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:581 # Graphics shapes Rectangle corners top right
rspec /tmp/d20131223-4637-1jwrv3p/spec.rb:587 # Graphics shapes Rectangle corners bottom right

История (2 версии и 1 коментар)

Йордан обнови решението на 21.12.2013 23:03 (преди почти 11 години)

+# няма методи == и eql
+require 'matrix.rb'
+ class Matrix
+ def []= (i,j,x)
+ @rows[i][j] = x
+ end
+ end
+module Graphics
+ class Canvas
+ attr_reader :height , :width
+ def initialize(x,y)
+
+ @layout = Matrix.build(x, y) {false}
+
+ @height , @width = x , y
+ end
+ def set_pixel(x,y)
+ @layout[x,y] = true
+ self
+ end
+ def pixel_at?(x,y)
+ @layout[x,y]
+ end
+ def draw(figure)
+ figure.layout.each_with_index do |col,row|
+ draw_inner_loop(col,row) if (col)
+ end
+ self
+ end
+ def draw_inner_loop(col,row)
+ col.each { |value| set_pixel(value,row) if value }
+ end
+ def render_as(renderer)
+ output = renderer::RENDER[:header]
+ @layout.each_with_index do|val , _ , coll|
+ pixel = val ? renderer::RENDER[:render][1] : renderer::RENDER[:render][0]
+ output << pixel
+ output << renderer::RENDER[:newline] if coll == width-1
+ end
+ output<<renderer::RENDER[:footer]
+ end
+ end
+
+ class Point
+ attr_reader :x , :y ,:layout
+ def initialize(x,y)
+ @layout =[]
+ @layout[x]=[y]
+ @x , @y = x , y
+ end
+ end
+
+
+ class Line
+ attr_reader :from , :to ,:layout
+ def initialize(start_point,end_point)
+ @layout =[]
+ @from = start_point
+ (start_point.x).upto(end_point.x) { |i| @layout[i] = [] }
+ if(start_point.x ==end_point.x or start_point.y == end_point.y)
+ then
+ straight_line(start_point,end_point)
+ else
+ bresenham(start_point,end_point)
+ end
+ end
+ def bresenham(start_point,end_point)
+ @horizontal_length=end_point.x-start_point.x
+ @vertical_length=end_point.y-start_point.y
+ @equation = 2*@vertical_length -@horizontal_length
+ @layout[start_point.x] = [start_point.y]
+ @end_point_changing=end_point.y
+ bresenham_line_loop(start_point,end_point)
+ end
+ def bresenham_line_loop(start_point,end_point)
+ (start_point.x+1).upto(end_point.x) do |i|
+ if @equation > 0
+ then
+ bresenham_equation_greater(i)
+ else
+ bresenham_equation_lower(i)
+ end
+ @to = Graphics::Point.new i , @end_point_changing
+ end
+ end
+ def bresenham_equation_greater(i)
+ puts i
+ @end_point_changing = @end_point_changing+1
+ @layout[i].push(@end_point_changing)
+ @equation = @equation + (2*@vertical_length-2*@horizontal_length)
+ end
+ def bresenham_equation_lower(i)
+ puts i
+ @layout[i].push(@end_point_changing)
+ @equation =@equation + (2*@vertical_length)
+ end
+ def straight_line(start_point,end_point)
+ (start_point.x).upto(end_point.x) { |i| @layout[i] =[start_point.y , end_point.y] }
+ (start_point.y).upto(end_point.y) do |i|
+ @layout[start_point.x] .push(i)
+ @layout[end_point.x] .push(i)
+ end
+ @to = end_point
+ end
+ end
+
+
+ class Rectangle
+ attr_reader :top_left , :top_right , :bottom_left , :bottom_right ,:layout
+ def initialize(start_point,end_point)
+ @layout =[]
+ @top_left , @top_right = start_point , Graphics::Point.new(start_point.x,end_point.y)
+ @bottom_left = Graphics::Point.new(end_point.x,start_point.y)
+ @bottom_right = end_point
+ draw_it(start_point,end_point)
+ end
+ def draw_it(start_point,end_point)
+ (start_point.x).upto(end_point.x) { |i| @layout[i] =[start_point.y , end_point.y] }
+ (start_point.y).upto(end_point.y) do |i|
+ @layout[start_point.x] .push(i)
+ @layout[end_point.x] .push(i)
+ end
+ end
+ end
+
+
+ module Renderers
+ module Ascii
+ RENDER = {footer: "" , header: "" , render: ["-" ,"@"] , newline: "\n"}
+ end
+ module Html
+ RENDER = {footer: " </div>
+ </body>
+ </html>" , header: ' <!DOCTYPE html>
+ <html>
+ <head>
+ <title>Rendered Canvas</title>
+ <style type="text/css">
+ .canvas {
+ font-size: 1px;
+ line-height: 1px;
+ }
+ .canvas * {
+ display: inline-block;
+ width: 10px;
+ height: 10px;
+ border-radius: 5px;
+ }
+ .canvas i {
+ background-color: #eee;
+ }
+ .canvas b {
+ background-color: #333;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="canvas">' , render: ["<i></i>" ,"<b></b>"] , newline: "<br/> \n"}
+ end
+ end
+
+end

Бележки:

  • Имаш сериозни проблеми със спазване на конвенциите по отношение на идентация и подредба на кода. Моля те да ги оправиш преди крайния срок на задачата, защото иначе ще ти взема наказателни точки. Ако трябва, прочети ръководството по стил отново.
  • Можеш да минеш и без Matrix в тази задача, а със сигурност можеш да минеш и без да го monkey-patch-ваш този клас. Ако държиш представянето ти да е двумерен масив, може просто да ползваш списък от списъци. Само че това не е нужно. Помисли дали няма друг по-оптимален начин в Ruby за реализация вътрешното представяне на пано, от масив от масиви. Ruby не е C и има по-удобни структури от данни, които са достъпни дори без require :)
  • Не виждам нужда да извеждаш метод draw_inner_loop, а не просто да ползваш кода му на ред 26 (т.е. "да го inline-неш"). Това е излишно усложнение. Не го ползваш никъде другаде, не помага на четимостта, името му не е добро.
  • Помисли кой трбява да носи отговорността за "рендериране" на пано. Самото пано или рендерера? Помисли кой обект каква отговорност носи. Една основна идея на ОО-програмирането е да разпределиш различните отговорности между различни обекти. Стреми се всеки обект да отговаря за едно конкретно нещо и само за него. Напълно нормално е да имаш голям брой малки обекти в системата, с тясно специализирани отговорности. В момента ползваш класовете за рендериране като кофи за данни, по много неидиоматичен начин. Възползвай се от факта, че са класове и ги натовари с отговорности.
  • Пробвай да напишеш логиката за рендериране с map и join, вместо да буташ резултата в един низ.
  • Все още не си имплементирал методите за равенство и хеш (==, eql? и hash). Пиши ни имейл, ако имаш проблеми с това.
  • if ... then не се ползва, когато имаш многоредов if (ред 61).
  • На ред 83 няма нужда да слагаш Graphics::, тъй като вече си в контекста на този модул. Може само Point.new .... Това важи и за други места по-надолу.
  • Не оставяй коментари или puts в кода си. Вторите нямат място в крайното решение, а в тази задача от първите няма смисъл, ако кодът е написан чисто и ясно.
  • Методи като draw_it, които ползваш само вътрешно в даден клас и не са част от публичния му интерфейс, прави private.

Основното нещо, над което трябва да поработиш, е да си подобриш подредбата на кода. Това е много критично. Искам да си идеален откъм идентация, поставяне на празни редове, интервали, липса на trailing whitespace и прочее. Честно ти казвам, нямам идея как си постигнал тази каша на подредбата. Само погледни как ти изглежда решението в сайта. Ако имаш нужда от помощ с редактора, виж тази тема или пиши във форума.

Следващото нещо, което искам да опиташ да подобриш, са имената на неща. Мисли дали това е най-добрия начин да кръстиш променлива, метод... Дали изразява максимално точно това, което този метод прави, или това, което тази променлива съдържа. Опитай да гледаш от позицията на човек, който вижда този код за пръв път.

Йордан обнови решението на 22.12.2013 23:25 (преди почти 11 години)

-# няма методи == и eql
require 'matrix.rb'
class Matrix
def []= (i,j,x)
@rows[i][j] = x
end
end
module Graphics
class Canvas
attr_reader :height , :width
def initialize(x,y)
@layout = Matrix.build(x, y) {false}
@height , @width = x , y
end
def set_pixel(x,y)
@layout[x,y] = true
self
end
def pixel_at?(x,y)
@layout[x,y]
end
def draw(figure)
figure.layout.each_with_index do |col,row|
draw_inner_loop(col,row) if (col)
end
self
end
def draw_inner_loop(col,row)
col.each { |value| set_pixel(value,row) if value }
end
def render_as(renderer)
output = renderer::RENDER[:header]
@layout.each_with_index do|val , _ , coll|
pixel = val ? renderer::RENDER[:render][1] : renderer::RENDER[:render][0]
output << pixel
output << renderer::RENDER[:newline] if coll == width-1
end
output<<renderer::RENDER[:footer]
end
end
class Point
attr_reader :x , :y ,:layout
def initialize(x,y)
@layout =[]
@layout[x]=[y]
@x , @y = x , y
end
end
class Line
attr_reader :from , :to ,:layout
def initialize(start_point,end_point)
@layout =[]
@from = start_point
(start_point.x).upto(end_point.x) { |i| @layout[i] = [] }
if(start_point.x ==end_point.x or start_point.y == end_point.y)
then
straight_line(start_point,end_point)
else
bresenham(start_point,end_point)
end
end
def bresenham(start_point,end_point)
@horizontal_length=end_point.x-start_point.x
@vertical_length=end_point.y-start_point.y
@equation = 2*@vertical_length -@horizontal_length
@layout[start_point.x] = [start_point.y]
@end_point_changing=end_point.y
bresenham_line_loop(start_point,end_point)
end
def bresenham_line_loop(start_point,end_point)
(start_point.x+1).upto(end_point.x) do |i|
if @equation > 0
then
bresenham_equation_greater(i)
else
bresenham_equation_lower(i)
end
- @to = Graphics::Point.new i , @end_point_changing
+ @to = Point.new i , @end_point_changing
end
end
def bresenham_equation_greater(i)
- puts i
@end_point_changing = @end_point_changing+1
@layout[i].push(@end_point_changing)
@equation = @equation + (2*@vertical_length-2*@horizontal_length)
end
def bresenham_equation_lower(i)
- puts i
@layout[i].push(@end_point_changing)
@equation =@equation + (2*@vertical_length)
end
def straight_line(start_point,end_point)
(start_point.x).upto(end_point.x) { |i| @layout[i] =[start_point.y , end_point.y] }
(start_point.y).upto(end_point.y) do |i|
@layout[start_point.x] .push(i)
@layout[end_point.x] .push(i)
end
@to = end_point
end
end
class Rectangle
attr_reader :top_left , :top_right , :bottom_left , :bottom_right ,:layout
def initialize(start_point,end_point)
@layout =[]
- @top_left , @top_right = start_point , Graphics::Point.new(start_point.x,end_point.y)
- @bottom_left = Graphics::Point.new(end_point.x,start_point.y)
+ @top_left , @top_right = start_point , Point.new(start_point.x,end_point.y)
+ @bottom_left = Point.new(end_point.x,start_point.y)
@bottom_right = end_point
draw_it(start_point,end_point)
end
def draw_it(start_point,end_point)
(start_point.x).upto(end_point.x) { |i| @layout[i] =[start_point.y , end_point.y] }
(start_point.y).upto(end_point.y) do |i|
@layout[start_point.x] .push(i)
@layout[end_point.x] .push(i)
end
end
end
module Renderers
module Ascii
RENDER = {footer: "" , header: "" , render: ["-" ,"@"] , newline: "\n"}
end
module Html
RENDER = {footer: " </div>
</body>
</html>" , header: ' <!DOCTYPE html>
<html>
<head>
<title>Rendered Canvas</title>
<style type="text/css">
.canvas {
font-size: 1px;
line-height: 1px;
}
.canvas * {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 5px;
}
.canvas i {
background-color: #eee;
}
.canvas b {
background-color: #333;
}
</style>
</head>
<body>
<div class="canvas">' , render: ["<i></i>" ,"<b></b>"] , newline: "<br/> \n"}
end
end
end