class RSVGR::Root

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/rsvgr.rb, line 146
def initialize *args
  @x1 = 0
  @y1 = 0
  @x2 = 1
  @y2 = 1
  @fill_color = "silver"
  @stroke_color = "black"
  # @stroke_width = 0.005
  # @stroke_linecap = "round"
  super
end

Public Instance Methods

cat() click to toggle source

def to_html

"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"   \
" <head>\n"                                         \
"  <title>#{Time.now}</title>\n"                    \
"  <style type=\"text/css\" media=\"screen\">\n"    \
"   body {\n"                                       \
"    background:lightgrey;\n"                       \
"    margin:0;\n"                                   \
"   }\n"                                            \
"   svg {\n"                                        \
"    display:block;\n"                              \
"    border:2px solid grey;\n"                      \
"    position:absolute;\n"                          \
"    top:3%;\n"                                     \
"    left:3%;\n"                                    \
"    width:94%;\n"                                  \
"    height:94%;\n"                                 \
"    background:white;\n"                           \
"   }\n"                                            \
"  </style>\n"                                      \
" </head>\n"                                        \
" <body>\n" + to_s + " </body>\n</html>\n"

end

# File lib/rsvgr.rb, line 191
def cat
  self.tap &method(:puts)
end
to_s() click to toggle source
# File lib/rsvgr.rb, line 157
def to_s
  "<?xml version=\"1.0\"?>\n"                                                      +
  "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.2\" baseProfile=\"tiny\"" +
  " viewBox=\"#{[@x1, @y1, @x2, @y2].map{ |i| DEFAULT_SIZE * i }.join " "}\""      +
  " preserveAspectRatio=\"xMidYMid meet\""                                         +
  " fill=\"#{@fill_color}\""                                                       +
  " stroke=\"#{@stroke_color}\""                                                   +
  # " stroke-width=\"#{@stroke_width}\""                                             +
  # " stroke-linecap=\"#{@stroke_linecap}\""                                         +
  ">\n <title>Generated by RubySVGmakeR (c) Nakilon</title>\n" + to_s_children + "</svg>\n"
end