Class: Browser::Canvas::Text
- Includes:
- Native
- Defined in:
- opal/browser/canvas/text.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #fill(text, x = nil, y = nil, max_width = nil) ⇒ Object
-
#initialize(context) ⇒ Text
constructor
A new instance of Text.
- #measure(text) ⇒ Object
- #stroke(text, x = nil, y = nil, max_width = nil) ⇒ Object
Constructor Details
#initialize(context) ⇒ Text
Returns a new instance of Text.
8 9 10 11 12 |
# File 'opal/browser/canvas/text.rb', line 8 def initialize(context) @context = context super(@context.to_n) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'opal/browser/canvas/text.rb', line 6 def context @context end |
Instance Method Details
#fill(text, x = nil, y = nil, max_width = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'opal/browser/canvas/text.rb', line 18 def fill(text, x = nil, y = nil, max_width = nil) x ||= 0 y ||= 0 if max_width `#@native.fillText(text, x, y, max_width)` else `#@native.fillText(text, x, y)` end @context end |
#measure(text) ⇒ Object
14 15 16 |
# File 'opal/browser/canvas/text.rb', line 14 def measure(text) `#@native.measureText(text)` end |
#stroke(text, x = nil, y = nil, max_width = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'opal/browser/canvas/text.rb', line 31 def stroke(text, x = nil, y = nil, max_width = nil) x ||= 0 y ||= 0 if max_width `#@native.strokeText(text, x, y, max_width)` else `#@native.strokeText(text, x, y)` end @context end |