Class: Gtk2SVG::DrawingInstructions
- Inherits:
-
Object
- Object
- Gtk2SVG::DrawingInstructions
- Defined in:
- lib/gtk2svg.rb
Instance Attribute Summary collapse
-
#area ⇒ Object
Returns the value of attribute area.
Instance Method Summary collapse
- #draw_arc(args) ⇒ Object
- #draw_layout(args) ⇒ Object
- #draw_line(args) ⇒ Object
- #draw_lines(args) ⇒ Object
- #draw_polygon(args) ⇒ Object
- #draw_rectangle(args) ⇒ Object
-
#initialize(area = nil) ⇒ DrawingInstructions
constructor
A new instance of DrawingInstructions.
- #render(a) ⇒ Object
- #script(args) ⇒ Object
- #window(args) ⇒ Object
Constructor Details
#initialize(area = nil) ⇒ DrawingInstructions
Returns a new instance of DrawingInstructions.
122 123 124 125 126 |
# File 'lib/gtk2svg.rb', line 122 def initialize(area=nil) @area = area if area end |
Instance Attribute Details
#area ⇒ Object
Returns the value of attribute area.
119 120 121 |
# File 'lib/gtk2svg.rb', line 119 def area @area end |
Instance Method Details
#draw_arc(args) ⇒ Object
128 129 130 131 132 133 134 135 |
# File 'lib/gtk2svg.rb', line 128 def draw_arc(args) dimensions, style = args x, y, width, height = dimensions gc = gc_ini(fill: style[:fill] || :none) @area.window.draw_arc(gc, 1, x, y, width, height, 0, 64 * 360) end |
#draw_layout(args) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/gtk2svg.rb', line 179 def draw_layout(args) coords, text, style = args x, y = coords layout = Pango::Layout.new(Gdk::Pango.context) layout.font_description = Pango::FontDescription.\ new('Sans ' + style[:font_size]) layout.text = text gc = gc_ini(fill: style[:fill] || :none) @area.window.draw_layout(gc, x, y, layout) end |
#draw_line(args) ⇒ Object
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/gtk2svg.rb', line 137 def draw_line(args) coords, style = args x1, y1, x2, y2 = coords gc = gc_ini(stroke: style[:stroke] || :none) gc.set_line_attributes(style[:'stroke-width'].to_i, Gdk::GC::LINE_SOLID, \ Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_MITER) @area.window.draw_line(gc, x1, y1, x2, y2) end |
#draw_lines(args) ⇒ Object
159 160 161 162 163 164 165 166 167 |
# File 'lib/gtk2svg.rb', line 159 def draw_lines(args) points, style = args gc = gc_ini(fill: style[:fill] || :none, stroke: style[:stroke] || :none) gc.set_line_attributes(style[:'stroke-width'].to_i, Gdk::GC::LINE_SOLID, \ Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_MITER) @area.window.draw_lines(gc, points) end |
#draw_polygon(args) ⇒ Object
148 149 150 151 152 153 154 155 156 157 |
# File 'lib/gtk2svg.rb', line 148 def draw_polygon(args) points, style = args gc = gc_ini(fill: style[:fill] || :none, stroke: style[:stroke] || :none) gc.set_line_attributes(style[:'stroke-width'].to_i, Gdk::GC::LINE_SOLID, \ Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_MITER) @area.window.draw_polygon(gc, 1, points) end |
#draw_rectangle(args) ⇒ Object
169 170 171 172 173 174 175 176 177 |
# File 'lib/gtk2svg.rb', line 169 def draw_rectangle(args) coords, style = args x1, y1, x2, y2 = coords gc = gc_ini(fill: style[:fill] || :none) @area.window.draw_rectangle(gc, 1, x1, y1, x2, y2) end |
#render(a) ⇒ Object
198 199 200 201 |
# File 'lib/gtk2svg.rb', line 198 def render(a) method(a[0]).call(args=a[1..2]) draw a[3] end |
#script(args) ⇒ Object
203 204 205 |
# File 'lib/gtk2svg.rb', line 203 def script(args) end |
#window(args) ⇒ Object
195 196 |
# File 'lib/gtk2svg.rb', line 195 def window(args) end |