Class: CanvasWrapper
- Includes:
- Droiuby::ViewHelper, JavaMethodHelper
- Defined in:
- lib/droiuby/wrappers/canvas_wrapper.rb
Instance Method Summary collapse
- #bitmap(bitmap, x, y, paint = nil, options = {}) ⇒ Object
- #circle(x, y, size, paint = nil) ⇒ Object
- #draw_color(value) ⇒ Object
-
#initialize(native) ⇒ CanvasWrapper
constructor
A new instance of CanvasWrapper.
- #line(x, y, x1, y1, paint = nil) ⇒ Object
- #make_paint ⇒ Object
- #make_rect(left, top, right, bottom) ⇒ Object
- #native ⇒ Object
- #paint ⇒ Object
- #paint=(p) ⇒ Object
- #round_rect(rect, x, y, paint = nil) ⇒ Object
- #text(msg, x, y, paint = nil) ⇒ Object
Methods included from Droiuby::ViewHelper
Methods included from JavaMethodHelper
Constructor Details
#initialize(native) ⇒ CanvasWrapper
Returns a new instance of CanvasWrapper.
85 86 87 88 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 85 def initialize(native) @native = native @paint = make_paint end |
Instance Method Details
#bitmap(bitmap, x, y, paint = nil, options = {}) ⇒ Object
134 135 136 137 138 139 140 141 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 134 def bitmap(bitmap, x, y, paint = nil, = {}) paint = @paint if paint.nil? if bitmap.class == BitmapDrawableWrapper bitmap = bitmap.to_bitmap end # native.drawBitmap(bitmap, x.to_f, y.to_f, paint.native) java_drawBitmap(bitmap, x.to_f, y.to_f, paint.native) end |
#circle(x, y, size, paint = nil) ⇒ Object
124 125 126 127 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 124 def circle(x, y, size, paint = nil) paint = @paint if paint.nil? java_drawCircle(x, y, size, paint.native); end |
#draw_color(value) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 110 def draw_color(value) if (value.kind_of? String) value = value.to_color end java_drawColor(value) end |
#line(x, y, x1, y1, paint = nil) ⇒ Object
129 130 131 132 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 129 def line(x, y, x1, y1, paint = nil) paint = @paint if paint.nil? java_drawLine(x, y, x1, y1, paint.native); end |
#make_paint ⇒ Object
94 95 96 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 94 def make_paint Paint.new end |
#make_rect(left, top, right, bottom) ⇒ Object
98 99 100 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 98 def make_rect(left, top, right, bottom) Java::android.graphics.RectF.new(left, top, right, bottom) end |
#native ⇒ Object
90 91 92 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 90 def native @native end |
#paint ⇒ Object
102 103 104 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 102 def paint @paint end |
#paint=(p) ⇒ Object
106 107 108 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 106 def paint=(p) @paint = p end |
#round_rect(rect, x, y, paint = nil) ⇒ Object
143 144 145 146 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 143 def round_rect(rect, x, y, paint = nil) paint = @paint if paint.nil? java_drawRoundRect(rect, x, y, paint.native) end |
#text(msg, x, y, paint = nil) ⇒ Object
118 119 120 121 122 |
# File 'lib/droiuby/wrappers/canvas_wrapper.rb', line 118 def text(msg, x, y, paint = nil) paint = @paint if paint.nil? java_drawText(msg, x, y, paint.native); end |