#!/usr/bin/ruby -w
=begin
/***************************************************************************
* Copyright (C) 2008, Paul Lutus *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
=end
# version: 1.4
if !ARGV[0] || ARGV.length < 4
puts "usage: bordercolor (hex) bg_color (hex) radius id"
puts "example: c0c0c0 ffffff 16 parch"
puts "result: creates stylesheet file and sample HTML"
exit 0
else
border,interior,radius,id = ARGV
end
graphic_background = (interior =~ /url\(/i)
css_baseclass = "roundcorner_#{radius}_#{id}"
target_css = "#{css_baseclass}.css"
target_html = "#{css_baseclass}.html"
radius = radius.to_i
array = []
# create an array of margin values
0.upto(radius-1) do |i|
x = i.to_f/radius
y = 1.0 - Math.sqrt(1.0-(x*x))
r = (y * radius).to_i
array << r if r > 0
end
# content of sample HTML page
roundcorner_html = "\n
\n"
roundcorner_html += "\n"
(array.size-1).downto(0) do |n|
roundcorner_html += "\n"
end
# prettify the CSS
prettified_css = ""
tab = 0
roundcorner_css.each do |line|
tab -= 1 if(line =~ /\}/)
prettified_css += " " * tab + line
tab += 1 if(line =~ /\{/)
end
# more sample page output
roundcorner_html += "\n
\n\n\n"
# save the CSS and HTML content
File.open(target_css,"w") { |f| f.write(prettified_css) }
File.open(target_html,"w") { |f| f.write(roundcorner_html) }