Class: Browser::Canvas::Text
- Includes:
- Native::Wrapper
- 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.
9 10 11 12 13 |
# File 'opal/browser/canvas/text.rb', line 9 def initialize(context) @context = context super(@context.to_n) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'opal/browser/canvas/text.rb', line 7 def context @context end |
Instance Method Details
#fill(text, x = nil, y = nil, max_width = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'opal/browser/canvas/text.rb', line 19 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
15 16 17 |
# File 'opal/browser/canvas/text.rb', line 15 def measure(text) `#@native.measureText(text)` end |
#stroke(text, x = nil, y = nil, max_width = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'opal/browser/canvas/text.rb', line 32 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 |