Sha256: 9b730845c3563565be4193f36031e5eff1b0bfb8ddc54e5f6d8caeef0d16a9e6

Contents?: true

Size: 648 Bytes

Versions: 2

Compression:

Stored size: 648 Bytes

Contents

# frozen_string_literal: true

require_relative "shape_helper"

class Scarpe
  class WebviewShape < Scarpe::WebviewWidget
    include ShapeHelper

    def initialize(properties)
      @color = color_for_fill
      super(properties)
    end

    def element(&block)
      HTML.render do |h|
        h.div(id: html_id, style: style) do
          h.svg(width: "400", height: "500") do
            h.path(d: shape_path, style: "fill:#{@color};stroke-width:2;")
          end
          block.call(h) if block_given?
        end
      end
    end

    private

    def style
      {
        width: "400",
        height: "900",
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scarpe-0.2.1 lib/scarpe/wv/shape.rb
scarpe-0.2.0 lib/scarpe/wv/shape.rb