Commit 779bf68c authored by Théotime BOLLENGIER's avatar Théotime BOLLENGIER
Browse files

graphics

parent 0456d845
This diff is collapsed.
This diff is collapsed.
require 'optparse'
require_relative '../../lib/argen/version.rb'
require_relative '../../lib/argen/graphics/resources_to_svg.rb'
require_relative '../../lib/argen/arch_reader.rb'
$copyright = "Copyright (C) 2017-2018, 2020 ENSTA Bretagne"
$authors = [
["Théotime Bollengier", "<theotime.bollengier@ensta-bretagne.fr>"]
]
$program_name = File.basename(__FILE__, '.*')
$program_version = ArGen::VERSION
$description = "This program generates a graphical representation of the input architecture."
$description_string = "\nWelcome to #{$program_name} #{$program_version}, a component of the ArGen framework.\n#{$description}\n#{$copyright}\n#{$authors.collect.with_index{|a, i| "#{(i == 0) ? "Author#{($authors.length > 1) ? 's':''}: " : " #{($authors.length > 1) ? ' ':''} "}#{a.first} #{a.last}\n"}.join}"
STDOUT.sync = true
STDERR.sync = true
options = {}
optparse = OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename($0)} [options]"
options[:arch] = nil
opts.on('-a', '--architecture FILE', 'ArGen architecture input file') do |s|
options[:arch] = s
end
options[:output] = nil
opts.on('-o', '--output FILE', "Output file for the image representation of the architecture. Can end with '.png', '.svg' or '.svgz' (gziped SVG)") do |s|
options[:output] = s
end
options[:negate] = false
opts.on('-d', '--dark', 'Use dark color scheme') do
options[:negate] = true
end
options[:tiles] = false
opts.on('-t', '--tiles', 'Draw matrix tiles boundaries') do
options[:tiles] = true
end
options[:width] = 1920
opts.on('-W', '--max_width INTEGER', 'Maximum width (for PNG)') do |n|
options[:width] = n.to_i.abs
end
options[:height] = 1080
opts.on('-H', '--max_height INTEGER', 'Maximum height (for PNG)') do |n|
options[:height] = n.to_i.abs
end
opts.on('-h', '--help', 'Display this help') do
puts opts
puts $description_string
exit
end
end
begin
optparse.parse!
rescue Exception => e
if e.class == SystemExit then
exit 0
else
abort e.message + "\n" + optparse.to_s
end
end
STDERR.puts "WARNING: Unused commandline arguments: #{ARGV.join(' ')}" unless ARGV.empty?
if options[:arch].nil? then
STDERR.puts "ERROR: you must specify an ArGen architecture file!"
abort optparse.to_s
end
if options[:output].nil? then
STDERR.puts "ERROR: you must specify an output file!"
abort optparse.to_s
end
arch = ArGen::Architecture::Arch.new(ArGen::ArchReader.parse(options[:arch]))
arch.write_architecture_resources(fileName: options[:output],
compress: options[:output] =~ /z$/,
printTilesBoundaries: options[:tiles],
inverseColor: options[:negate],
max_width: options[:width],
max_height: options[:height])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment