Class: Theseus::Formatters::ASCII::Upsilon
- Inherits:
-
Theseus::Formatters::ASCII
- Object
- Theseus::Formatters::ASCII
- Theseus::Formatters::ASCII::Upsilon
- Defined in:
- lib/theseus/formatters/ascii/upsilon.rb
Overview
Renders an UpsilonMaze to an ASCII representation, using 3 characters horizontally and 4 characters vertically to represent a single octagonal cell, and 3 characters horizontally and 2 vertically to represent a square cell.
_ _ _
/ \_/ \_/ \
| |_| |_| |
\_/ \_/ \_/
|_| |_| |_|
/ \_/ \_/ \
You shouldn’t ever need to instantiate this class directly. Rather, use UpsilonMaze#to(:ascii) (or UpsilonMaze#to_s to get the string directly).
Instance Attribute Summary
Attributes inherited from Theseus::Formatters::ASCII
Instance Method Summary collapse
-
#initialize(maze, options = {}) ⇒ Upsilon
constructor
Returns a new Sigma canvas for the given maze (which should be an instance of SigmaMaze).
Methods inherited from Theseus::Formatters::ASCII
Constructor Details
#initialize(maze, options = {}) ⇒ Upsilon
Returns a new Sigma canvas for the given maze (which should be an instance of SigmaMaze). The options parameter is not used.
The returned object will be fully initialized, containing an ASCII representation of the given SigmaMaze.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/theseus/formatters/ascii/upsilon.rb', line 25 def initialize(maze, ={}) super(maze.width * 2 + 1, maze.height * 2 + 3) maze.height.times do |y| py = y * 2 maze.row_length(y).times do |x| cell = maze[x, y] next if cell == 0 px = x * 2 if (x + y) % 2 == 0 draw_octogon_cell(px, py, cell) else draw_square_cell(px, py, cell) end end end end |