Sha256: 4db705e4d8b4c86e205c548d155eab0a01f308da881f2c6c5719167767bf6f83

Contents?: true

Size: 556 Bytes

Versions: 6

Compression:

Stored size: 556 Bytes

Contents

module Browser; class Canvas

class Gradient
  include Native::Wrapper

  attr_reader :context

  def initialize(context, *args, &block)
    @context = context

    super(case args.length
      when 4 then `#{@context.to_n}.createLinearGradient.apply(self, args)`
      when 6 then `#{@context.to_n}.createRadialGradient.apply(self, args)`
      else raise ArgumentError, "don't know where to dispatch"
    end)

    instance_eval(&block)
  end

  def add(position, color)
    `#{@context.to_n}.addColorStop(position, color)`

    self
  end
end

end; end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
opal-browser-0.3.4 opal/browser/canvas/gradient.rb
atome-opal-browser-0.3.9.5 opal/browser/canvas/gradient.rb
opal-browser-0.3.3 opal/browser/canvas/gradient.rb
opal-browser-0.3.2 opal/browser/canvas/gradient.rb
opal-browser-0.3.1 opal/browser/canvas/gradient.rb
opal-browser-0.3.0 opal/browser/canvas/gradient.rb