class Theseus::Formatters::PNG::Delta
Renders a DeltaMaze
to a PNG
canvas. Does not currently support the :wall_width
option.
You will almost never access this class directly. Instead, use DeltaMaze#to(:png, options) to return the raw PNG
data directly.
Public Class Methods
new(maze, options={})
click to toggle source
Create and return a fully initialized PNG::Delta
object, with the maze rendered. To get the maze data, call to_blob
.
See Theseus::Formatters::PNG
for a list of all supported options.
Calls superclass method
Theseus::Formatters::PNG::new
# File lib/theseus/formatters/png/delta.rb, line 16 def initialize(maze, options={}) super height = @options[:outer_padding] * 2 + maze.height * @options[:cell_size] width = @options[:outer_padding] * 2 + (maze.width + 1) * @options[:cell_size] / 2 canvas = ChunkyPNG::Image.new(width, height, @options[:background]) maze.height.times do |y| py = @options[:outer_padding] + y * @options[:cell_size] maze.row_length(y).times do |x| px = @options[:outer_padding] + x * @options[:cell_size] / 2.0 draw_cell(canvas, [x, y], maze.points_up?(x,y), px, py, maze[x, y]) end end @blob = canvas.to_blob end