Module: Rabbit::Renderer::Engine::GDK
Class Method Summary collapse
Instance Method Summary collapse
- #alpha_available? ⇒ Boolean
- #background=(color) ⇒ Object
- #background_image=(pixbuf) ⇒ Object
- #draw_arc(filled, x, y, w, h, a1, a2, color = nil, params = {}) ⇒ Object
- #draw_arc_by_radius(filled, x, y, r, a1, a2, color = nil, params = {}) ⇒ Object
- #draw_layout(layout, x, y, color = nil, params = {}) ⇒ Object
- #draw_line(x1, y1, x2, y2, color = nil, params = {}) ⇒ Object
- #draw_lines(points, color = nil, params = {}) ⇒ Object
- #draw_pixbuf(pixbuf, x, y, params = {}) ⇒ Object
- #draw_polygon(filled, points, color = nil, params = {}) ⇒ Object
- #draw_rectangle(filled, x, y, w, h, color = nil, params = {}) ⇒ Object
- #draw_rounded_rectangle(filled, x, y, w, h, radius, color = nil, params = {}) ⇒ Object
- #finish_renderer ⇒ Object
- #foreground=(color) ⇒ Object
- #init_renderer(drawable) ⇒ Object
- #prepare_renderer(drawable) ⇒ Object
Methods included from Kernel
#draw_background, #draw_circle, #draw_circle_by_radius, #draw_cone, #draw_cube, #draw_dodecahedron, #draw_flag, #draw_flag_layout, #draw_icosahedron, #draw_octahedron, #draw_rectangle_flag, #draw_slide, #draw_sphere, #draw_teapot, #draw_tetrahedron, #draw_torus, #draw_triangle_flag, #flag_size, #gl_call_list, #gl_compile, #gl_supported?, #make_color, #new_list_id, #reflect_context, #restore_context, #rotate_context, #save_context, #scale_context, #shear_context, #translate_context, #z_far, #z_view
Class Method Details
.priority ⇒ Object
12 13 14 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 12 def priority 0 end |
Instance Method Details
#alpha_available? ⇒ Boolean
32 33 34 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 32 def alpha_available? false end |
#background=(color) ⇒ Object
40 41 42 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 40 def background=(color) @background.set_rgb_fg_color(color.to_gdk_color) end |
#background_image=(pixbuf) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 44 def background_image=(pixbuf) w, h = pixbuf.width, pixbuf.height pixmap = Gdk::Pixmap.new(nil, w, h, depth) pixmap.draw_rectangle(@background, true, 0, 0, w, h) args = [ @foreground, pixbuf, 0, 0, 0, 0, w, h, Gdk::RGB::DITHER_NORMAL, 0, 0, ] pixmap.draw_pixbuf(*args) @background.set_tile(pixmap) @background.fill = Gdk::GC::Fill::TILED end |
#draw_arc(filled, x, y, w, h, a1, a2, color = nil, params = {}) ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 126 def draw_arc(filled, x, y, w, h, a1, a2, color=nil, params={}) gc = make_gc(color, params) return if gc.nil? a1 *= 64 a2 *= 64 @gdk_drawable.draw_arc(gc, filled, x, y, w, h, a1, a2) end |
#draw_arc_by_radius(filled, x, y, r, a1, a2, color = nil, params = {}) ⇒ Object
134 135 136 137 138 139 140 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 134 def draw_arc_by_radius(filled, x, y, r, a1, a2, color=nil, params={}) sx = x - r sy = y - r w = r * 2 h = r * 2 draw_arc(filled, sx, sy, w, h, a1, a2, color, params) end |
#draw_layout(layout, x, y, color = nil, params = {}) ⇒ Object
148 149 150 151 152 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 148 def draw_layout(layout, x, y, color=nil, params={}) gc = make_gc(color, params) return if gc.nil? @gdk_drawable.draw_layout(gc, x, y, layout) end |
#draw_line(x1, y1, x2, y2, color = nil, params = {}) ⇒ Object
58 59 60 61 62 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 58 def draw_line(x1, y1, x2, y2, color=nil, params={}) gc = make_gc(color, params) return if gc.nil? @gdk_drawable.draw_line(gc, x1, y1, x2, y2) end |
#draw_lines(points, color = nil, params = {}) ⇒ Object
64 65 66 67 68 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 64 def draw_lines(points, color=nil, params={}) gc = make_gc(color, params) return if gc.nil? @gdk_drawable.draw_lines(gc, points) end |
#draw_pixbuf(pixbuf, x, y, params = {}) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 154 def draw_pixbuf(pixbuf, x, y, params={}) gc = make_gc(params[:color], params) return if gc.nil? draw_scaled_pixbuf = params[:draw_scaled_pixbuf] draw_scaled_pixbuf = @draw_scaled_image if draw_scaled_pixbuf.nil? width = params[:width] || pixbuf.width height = params[:height] || pixbuf.height if draw_scaled_pixbuf and [width, height] != [pixbuf.width, pixbuf.height] pixbuf = pixbuf.scale(width, height) end args = [0, 0, x, y, width, height, params[:dither_mode] || Gdk::RGB::DITHER_NORMAL, params[:x_dither] || 0, params[:y_dither] || 0] @gdk_drawable.draw_pixbuf(gc, pixbuf, *args) end |
#draw_polygon(filled, points, color = nil, params = {}) ⇒ Object
142 143 144 145 146 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 142 def draw_polygon(filled, points, color=nil, params={}) gc = make_gc(color, params) return if gc.nil? @gdk_drawable.draw_polygon(gc, filled, points) end |
#draw_rectangle(filled, x, y, w, h, color = nil, params = {}) ⇒ Object
70 71 72 73 74 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 70 def draw_rectangle(filled, x, y, w, h, color=nil, params={}) gc = make_gc(color, params) return if gc.nil? @gdk_drawable.draw_rectangle(gc, filled, x, y, w, h) end |
#draw_rounded_rectangle(filled, x, y, w, h, radius, color = nil, params = {}) ⇒ Object
76 77 78 79 80 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 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 76 def draw_rounded_rectangle(filled, x, y, w, h, radius, color=nil, params={}) x_radius = params[:x_radius] || radius y_radius = params[:y_radius] || radius x_diameter = x_radius * 2 y_diameter = y_radius * 2 line_width = params[:line_width] inner_x = x + x_radius inner_y = y + y_radius inner_w = w - x_diameter inner_h = h - y_diameter if filled draw_rectangle(true, inner_x, inner_y, inner_w, inner_h, color) end if filled top = [inner_x, y, inner_w, y_radius] left = [x, inner_y, x_radius, inner_h] bottom = [inner_x, inner_y + inner_h, inner_w, y_radius] right = [inner_x + inner_w, inner_y, x_radius, inner_h] [top, left, bottom, right].each do |rx, ry, rw, rh| draw_rectangle(true, rx, ry, rw, rh, color) end else top = [inner_x, y, inner_x + inner_w, y] left = [x, inner_y, x, inner_y + inner_h] bottom = [inner_x, y + h, inner_x + inner_w, y + h] right = [x + w, inner_y, x + w, inner_y + inner_h] [top, left, bottom, right].each do |start_x, start_y, end_x, end_y| draw_line(start_x, start_y, end_x, end_y, color, {:line_width => line_width}) end end upper_left = [x, y, 90] lower_left = [x, y + inner_h, 180] lower_right = [x + inner_w, y + inner_h, 270] upper_right = [x + inner_w, y, 0] [ upper_left, lower_left, lower_right, upper_right ].each do |ax, ay, start_angle| draw_arc(filled, ax, ay, x_diameter, y_diameter, start_angle, 90, color, {:line_width => line_width}) end end |
#finish_renderer ⇒ Object
27 28 29 30 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 27 def finish_renderer @gdk_drawables.pop @gdk_drawable = @gdk_drawables.pop end |
#foreground=(color) ⇒ Object
36 37 38 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 36 def foreground=(color) @foreground.set_rgb_fg_color(color.to_gdk_color) end |
#init_renderer(drawable) ⇒ Object
23 24 25 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 23 def init_renderer(drawable) prepare_renderer(drawable) end |
#prepare_renderer(drawable) ⇒ Object
17 18 19 20 21 |
# File 'lib/rabbit/renderer/engine/gdk.rb', line 17 def prepare_renderer(drawable) @gdk_drawables ||= [] @gdk_drawable = drawable @gdk_drawables.push(@gdk_drawable) end |