Class: RSVGR::Root

Inherits:
Object
  • Object
show all
Defined in:
lib/rsvgr.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Root

Returns a new instance of Root.



146
147
148
149
150
151
152
153
154
155
156
# 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

Instance Method Details

#catObject

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



191
192
193
# File 'lib/rsvgr.rb', line 191

def cat
  self.tap &method(:puts)
end

#to_sObject



157
158
159
160
161
162
163
164
165
166
167
# 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