0
0
Fork 0

Use Rubella::Output::Base

Not complete yet.
This commit is contained in:
Stormwind 2015-02-23 22:29:18 +01:00
parent c8ba902bc9
commit 65cf4f6b15
3 changed files with 22 additions and 20 deletions

View File

@ -1,7 +1,9 @@
require "rubella/output/base"
module Rubella
module Output
class ASCII
class ASCII < Base
attr_accessor :symbols
attr_reader :used_symbols
@ -16,8 +18,8 @@ module Rubella
@symbols["numbers"] =
[" ", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
@field_size = field_size
self.used_symbols = "shades_ascii"
super field_size
end
def used_symbols= value
@ -30,19 +32,18 @@ module Rubella
end
def create storage
parsed_list = storage.data
buckets = parsed_list[0].length
columns = parsed_list.length
buckets = storage.data[0].length
# columns = storage.data.length
# image size
x = columns*@field_size
y = buckets*@field_size
# x = columns*@field_size
# y = buckets*@field_size
# start drawing the damn thing
ascii_arr = []
0.upto(buckets).each { |i| ascii_arr[i] = "" }
parsed_list.each do |point|
storage.data.each do |point|
i = 0
point.reverse.each do |part|
part = (part*10).to_i
@ -58,7 +59,7 @@ module Rubella
end
end
ascii_arr.join("\n")
@data = ascii_arr.join("\n")
end
end

View File

@ -2,6 +2,12 @@ module Rubella
module Output
class Base
attr_accessor :field_size
attr_reader :data
def initialize field_size = 15
@field_size = field_size
end
end
end

View File

@ -1,19 +1,14 @@
require "rubella/output/base"
require 'RMagick'
module Rubella
module Output
class Image
attr_accessor :field_size
def initialize field_size = 15
@field_size = field_size
end
class Image < Base
def create storage
parsed_list = storage.data
buckets = parsed_list[0].length
columns = parsed_list.length
buckets = storage.data[0].length
columns = storage.data.length
# image size
x = columns*@field_size
@ -23,7 +18,7 @@ module Rubella
loadImg = Magick::Image.new(x, y) { self.background_color = "white" }
i = 0
parsed_list.each do |point|
storage.data.each do |point|
j = 0
point.reverse.each do |part|
# draw a red rectangle on the white background
@ -45,7 +40,7 @@ module Rubella
i = i + 1
end
loadImg.display
@data = loadImg
end