Module: Rabbit::Renderer::Kernel
- Included in:
- Engine::Cairo, Engine::GDK, Print::Multiple
- Defined in:
- lib/rabbit/renderer/kernel.rb
Instance Method Summary collapse
- #draw_background(slide) ⇒ Object
- #draw_circle(filled, x, y, w, h, color = nil, params = {}) ⇒ Object
- #draw_circle_by_radius(filled, x, y, r, color = nil, params = {}) ⇒ Object
- #draw_cone(filled, x, y, z, base, height, slices, stacks, color = nil) ⇒ Object
- #draw_cube(filled, x, y, z, size, color = nil) ⇒ Object
- #draw_dodecahedron(filled, x, y, z, color = nil) ⇒ Object
- #draw_flag(x, y, pole_height, params) ⇒ Object
- #draw_flag_layout(layout, x, y, pole_width, flag_width, text_height, flag_height) ⇒ Object
- #draw_icosahedron(filled, x, y, z, color = nil) ⇒ Object
- #draw_octahedron(filled, x, y, z, color = nil) ⇒ Object
- #draw_rectangle_flag(x, y, pole_height, params) ⇒ Object
- #draw_slide(slide, simulation) ⇒ Object
- #draw_sphere(filled, x, y, z, radius, slices, stacks, color = nil) ⇒ Object
- #draw_teapot(filled, x, y, z, scale, color = nil) ⇒ Object
- #draw_tetrahedron(filled, x, y, z, color = nil) ⇒ Object
- #draw_torus(filled, x, y, z, inner_radius, outer_radius, n_sides, rings, color = nil) ⇒ Object
- #draw_triangle_flag(x, y, pole_height, params) ⇒ Object
- #flag_size(pole_height, params) ⇒ Object
- #gl_call_list(id, x, y, z, color = nil) ⇒ Object
- #gl_compile(id) ⇒ Object
- #gl_supported? ⇒ Boolean
- #make_color(color) ⇒ Object
- #new_list_id ⇒ Object
- #poppler_available? ⇒ Boolean
- #reflect_context(base, params = {}) ⇒ Object
- #restore_context ⇒ Object
- #rotate_context(angle, params = {}) ⇒ Object
- #rsvg_available? ⇒ Boolean
- #save_context ⇒ Object
- #scale_context(x, y, params = {}) ⇒ Object
- #shear_context(x, y, params = {}) ⇒ Object
- #translate_context(x, y, params = {}) ⇒ Object
- #z_far ⇒ Object
- #z_view ⇒ Object
Instance Method Details
#draw_background(slide) ⇒ Object
61 62 63 |
# File 'lib/rabbit/renderer/kernel.rb', line 61 def draw_background() draw_rectangle(true, 0, 0, width, height, @background) end |
#draw_circle(filled, x, y, w, h, color = nil, params = {}) ⇒ Object
65 66 67 |
# File 'lib/rabbit/renderer/kernel.rb', line 65 def draw_circle(filled, x, y, w, h, color=nil, params={}) draw_arc(filled, x, y, w, h, 0, 360, color, params) end |
#draw_circle_by_radius(filled, x, y, r, color = nil, params = {}) ⇒ Object
69 70 71 |
# File 'lib/rabbit/renderer/kernel.rb', line 69 def draw_circle_by_radius(filled, x, y, r, color=nil, params={}) draw_arc_by_radius(filled, x, y, r, 0, 360, color, params) end |
#draw_cone(filled, x, y, z, base, height, slices, stacks, color = nil) ⇒ Object
192 193 194 |
# File 'lib/rabbit/renderer/kernel.rb', line 192 def draw_cone(filled, x, y, z, base, height, slices, stacks, color=nil) not_support_method("draw_cone") end |
#draw_cube(filled, x, y, z, size, color = nil) ⇒ Object
184 185 186 |
# File 'lib/rabbit/renderer/kernel.rb', line 184 def draw_cube(filled, x, y, z, size, color=nil) not_support_method("draw_cube") end |
#draw_dodecahedron(filled, x, y, z, color = nil) ⇒ Object
209 210 211 |
# File 'lib/rabbit/renderer/kernel.rb', line 209 def draw_dodecahedron(filled, x, y, z, color=nil) not_support_method("draw_dodecahedron") end |
#draw_flag(x, y, pole_height, params) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/rabbit/renderer/kernel.rb', line 73 def draw_flag(x, y, pole_height, params) if params["flag_type"] == "triangle" draw_triangle_flag(x, y, pole_height, params) else draw_rectangle_flag(x, y, pole_height, params) end end |
#draw_flag_layout(layout, x, y, pole_width, flag_width, text_height, flag_height) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/rabbit/renderer/kernel.rb', line 167 def draw_flag_layout(layout, x, y, pole_width, flag_width, text_height, flag_height) base_x = x + pole_width layout.width = flag_width * Pango::SCALE layout.alignment = Pango::Layout::ALIGN_CENTER base_y = y if text_height < flag_height base_y += (flag_height - text_height) / 2 end draw_layout(layout, base_x, base_y) end |
#draw_icosahedron(filled, x, y, z, color = nil) ⇒ Object
213 214 215 |
# File 'lib/rabbit/renderer/kernel.rb', line 213 def draw_icosahedron(filled, x, y, z, color=nil) not_support_method("draw_icosahedron") end |
#draw_octahedron(filled, x, y, z, color = nil) ⇒ Object
205 206 207 |
# File 'lib/rabbit/renderer/kernel.rb', line 205 def draw_octahedron(filled, x, y, z, color=nil) not_support_method("draw_octahedron") end |
#draw_rectangle_flag(x, y, pole_height, params) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/rabbit/renderer/kernel.rb', line 128 def draw_rectangle_flag(x, y, pole_height, params) params = setup_flag_params(pole_height, 1.3, params) layout = params["layout"] text_width = params["text_width"] text_height = params["text_height"] pole_width = params["pole_width"] pole_color = params["pole_color"] flag_height = params["flag_height"] flag_width = params["flag_width"] flag_color = params["flag_color"] flag_frame_width = params["flag_frame_width"] flag_frame_color = params["flag_frame_color"] draw_rectangle(true, x, y, pole_width, pole_height, pole_color) base_x = x + pole_width draw_rectangle(true, base_x, y, flag_width, flag_height, flag_frame_color) draw_rectangle(true, base_x, y + flag_frame_width, flag_width - flag_frame_width, flag_height - 2 * flag_frame_width, flag_color) if layout args = [ layout, x, y, pole_width, flag_width - 2 * flag_frame_width, text_height, flag_height, ] draw_flag_layout(*args) end end |
#draw_slide(slide, simulation) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/rabbit/renderer/kernel.rb', line 51 def (, simulation) unless simulation save_context draw_background() end yield ensure restore_context unless simulation end |
#draw_sphere(filled, x, y, z, radius, slices, stacks, color = nil) ⇒ Object
188 189 190 |
# File 'lib/rabbit/renderer/kernel.rb', line 188 def draw_sphere(filled, x, y, z, radius, slices, stacks, color=nil) not_support_method("draw_sphere") end |
#draw_teapot(filled, x, y, z, scale, color = nil) ⇒ Object
217 218 219 |
# File 'lib/rabbit/renderer/kernel.rb', line 217 def draw_teapot(filled, x, y, z, scale, color=nil) not_support_method("draw_teapot") end |
#draw_tetrahedron(filled, x, y, z, color = nil) ⇒ Object
201 202 203 |
# File 'lib/rabbit/renderer/kernel.rb', line 201 def draw_tetrahedron(filled, x, y, z, color=nil) not_support_method("draw_tetrahedron") end |
#draw_torus(filled, x, y, z, inner_radius, outer_radius, n_sides, rings, color = nil) ⇒ Object
196 197 198 199 |
# File 'lib/rabbit/renderer/kernel.rb', line 196 def draw_torus(filled, x, y, z, inner_radius, outer_radius, n_sides, rings, color=nil) not_support_method("draw_torus") end |
#draw_triangle_flag(x, y, pole_height, params) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/rabbit/renderer/kernel.rb', line 81 def draw_triangle_flag(x, y, pole_height, params) params = setup_flag_params(pole_height, 1.5, params) layout = params["layout"] text_width = params["text_width"] text_height = params["text_height"] pole_width = params["pole_width"] pole_color = params["pole_color"] flag_height = params["flag_height"] flag_width = params["flag_width"] flag_color = params["flag_color"] flag_frame_width = params["flag_frame_width"] flag_frame_color = params["flag_frame_color"] draw_rectangle(true, x, y, pole_width, pole_height, pole_color) base_x = x + pole_width draw_polygon(true, [ [base_x, y], [base_x + flag_width, y + flag_height / 2], [base_x, y + flag_height], ], flag_frame_color) draw_polygon(true, [ [base_x, y + flag_frame_width], [ base_x + flag_width - 2 * flag_frame_width, y + flag_height / 2 ], [ base_x, y + flag_height - flag_frame_width ], ], flag_color) if layout args = [ layout, x, y, pole_width, flag_width * 0.8, text_height, flag_height, ] draw_flag_layout(*args) end end |
#flag_size(pole_height, params) ⇒ Object
179 180 181 182 |
# File 'lib/rabbit/renderer/kernel.rb', line 179 def flag_size(pole_height, params) params = setup_flag_params(pole_height, 1.5, params) [params["pole_width"] + params["flag_width"], pole_height] end |
#gl_call_list(id, x, y, z, color = nil) ⇒ Object
225 226 227 |
# File 'lib/rabbit/renderer/kernel.rb', line 225 def gl_call_list(id, x, y, z, color=nil) not_support_method("gl_call_list") end |
#gl_compile(id) ⇒ Object
221 222 223 |
# File 'lib/rabbit/renderer/kernel.rb', line 221 def gl_compile(id) not_support_method("gl_compile") end |
#gl_supported? ⇒ Boolean
229 230 231 |
# File 'lib/rabbit/renderer/kernel.rb', line 229 def gl_supported? false end |
#make_color(color) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/rabbit/renderer/kernel.rb', line 14 def make_color(color) return color if color.is_a?(Color) if color.nil? @foreground else Color.parse(color) end end |
#new_list_id ⇒ Object
241 242 243 244 |
# File 'lib/rabbit/renderer/kernel.rb', line 241 def new_list_id @list_id += 1 @list_id end |
#poppler_available? ⇒ Boolean
10 11 12 |
# File 'lib/rabbit/renderer/kernel.rb', line 10 def poppler_available? false end |
#reflect_context(base, params = {}) ⇒ Object
32 33 |
# File 'lib/rabbit/renderer/kernel.rb', line 32 def reflect_context(base, params={}) end |
#restore_context ⇒ Object
48 49 |
# File 'lib/rabbit/renderer/kernel.rb', line 48 def restore_context end |
#rotate_context(angle, params = {}) ⇒ Object
26 27 |
# File 'lib/rabbit/renderer/kernel.rb', line 26 def rotate_context(angle, params={}) end |
#rsvg_available? ⇒ Boolean
6 7 8 |
# File 'lib/rabbit/renderer/kernel.rb', line 6 def rsvg_available? false end |
#save_context ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/rabbit/renderer/kernel.rb', line 38 def save_context if block_given? begin yield ensure restore_context end end end |
#scale_context(x, y, params = {}) ⇒ Object
29 30 |
# File 'lib/rabbit/renderer/kernel.rb', line 29 def scale_context(x, y, params={}) end |
#shear_context(x, y, params = {}) ⇒ Object
35 36 |
# File 'lib/rabbit/renderer/kernel.rb', line 35 def shear_context(x, y, params={}) end |
#translate_context(x, y, params = {}) ⇒ Object
23 24 |
# File 'lib/rabbit/renderer/kernel.rb', line 23 def translate_context(x, y, params={}) end |
#z_far ⇒ Object
233 234 235 |
# File 'lib/rabbit/renderer/kernel.rb', line 233 def z_far 100.0 end |
#z_view ⇒ Object
237 238 239 |
# File 'lib/rabbit/renderer/kernel.rb', line 237 def z_view 5.0 end |