parent
c8ba902bc9
commit
65cf4f6b15
|
@ -1,7 +1,9 @@
|
||||||
|
require "rubella/output/base"
|
||||||
|
|
||||||
module Rubella
|
module Rubella
|
||||||
module Output
|
module Output
|
||||||
|
|
||||||
class ASCII
|
class ASCII < Base
|
||||||
attr_accessor :symbols
|
attr_accessor :symbols
|
||||||
attr_reader :used_symbols
|
attr_reader :used_symbols
|
||||||
|
|
||||||
|
@ -16,8 +18,8 @@ module Rubella
|
||||||
@symbols["numbers"] =
|
@symbols["numbers"] =
|
||||||
[" ", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
|
[" ", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
|
||||||
|
|
||||||
@field_size = field_size
|
|
||||||
self.used_symbols = "shades_ascii"
|
self.used_symbols = "shades_ascii"
|
||||||
|
super field_size
|
||||||
end
|
end
|
||||||
|
|
||||||
def used_symbols= value
|
def used_symbols= value
|
||||||
|
@ -30,19 +32,18 @@ module Rubella
|
||||||
end
|
end
|
||||||
|
|
||||||
def create storage
|
def create storage
|
||||||
parsed_list = storage.data
|
buckets = storage.data[0].length
|
||||||
buckets = parsed_list[0].length
|
# columns = storage.data.length
|
||||||
columns = parsed_list.length
|
|
||||||
|
|
||||||
# image size
|
# image size
|
||||||
x = columns*@field_size
|
# x = columns*@field_size
|
||||||
y = buckets*@field_size
|
# y = buckets*@field_size
|
||||||
|
|
||||||
# start drawing the damn thing
|
# start drawing the damn thing
|
||||||
ascii_arr = []
|
ascii_arr = []
|
||||||
0.upto(buckets).each { |i| ascii_arr[i] = "" }
|
0.upto(buckets).each { |i| ascii_arr[i] = "" }
|
||||||
|
|
||||||
parsed_list.each do |point|
|
storage.data.each do |point|
|
||||||
i = 0
|
i = 0
|
||||||
point.reverse.each do |part|
|
point.reverse.each do |part|
|
||||||
part = (part*10).to_i
|
part = (part*10).to_i
|
||||||
|
@ -58,7 +59,7 @@ module Rubella
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ascii_arr.join("\n")
|
@data = ascii_arr.join("\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,12 @@ module Rubella
|
||||||
module Output
|
module Output
|
||||||
|
|
||||||
class Base
|
class Base
|
||||||
|
attr_accessor :field_size
|
||||||
|
attr_reader :data
|
||||||
|
|
||||||
|
def initialize field_size = 15
|
||||||
|
@field_size = field_size
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
|
require "rubella/output/base"
|
||||||
require 'RMagick'
|
require 'RMagick'
|
||||||
|
|
||||||
module Rubella
|
module Rubella
|
||||||
module Output
|
module Output
|
||||||
|
|
||||||
class Image
|
class Image < Base
|
||||||
attr_accessor :field_size
|
|
||||||
|
|
||||||
def initialize field_size = 15
|
|
||||||
@field_size = field_size
|
|
||||||
end
|
|
||||||
|
|
||||||
def create storage
|
def create storage
|
||||||
parsed_list = storage.data
|
buckets = storage.data[0].length
|
||||||
buckets = parsed_list[0].length
|
columns = storage.data.length
|
||||||
columns = parsed_list.length
|
|
||||||
|
|
||||||
# image size
|
# image size
|
||||||
x = columns*@field_size
|
x = columns*@field_size
|
||||||
|
@ -23,7 +18,7 @@ module Rubella
|
||||||
loadImg = Magick::Image.new(x, y) { self.background_color = "white" }
|
loadImg = Magick::Image.new(x, y) { self.background_color = "white" }
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
parsed_list.each do |point|
|
storage.data.each do |point|
|
||||||
j = 0
|
j = 0
|
||||||
point.reverse.each do |part|
|
point.reverse.each do |part|
|
||||||
# draw a red rectangle on the white background
|
# draw a red rectangle on the white background
|
||||||
|
@ -45,7 +40,7 @@ module Rubella
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
loadImg.display
|
@data = loadImg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue