Sha256: 208f6aa27852f11c72b9e8283d77a53ed8bf61ad3d8d2efe17e7fb61a2b5b6f2

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 Bytes

Contents

#--
#            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
#                    Version 2, December 2004
#
#            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
#   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
#  0. You just DO WHAT THE FUCK YOU WANT TO.
#++

module Browser; class Canvas

class Text
  include Native

  attr_reader :context

  def initialize(context)
    @context = context

    super(@context.to_n)
  end

  def measure(text)
    `#@native.measureText(text)`
  end

  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

  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
end

end; end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-browser-0.2.0.beta1 opal/browser/canvas/text.rb
opal-browser-0.1.0.beta1 opal/browser/canvas/text.rb