Sha256: cf43e9ea93429e1e83ab7ee1e6eda82c21fdecc2270f3ff920a6a54ace5bffab

Contents?: true

Size: 678 Bytes

Versions: 3

Compression:

Stored size: 678 Bytes

Contents

# frozen_string_literal: true

require_relative "shape_helper"
class Scarpe
  class WebviewLine < Scarpe::WebviewWidget
    include ShapeHelper

    def initialize(properties)
      super(properties)
    end

    def element
      HTML.render do |h|
        h.div(id: html_id, style: style) do
          h.svg(width: @x2, height: @y2) do
            h.line(x1: @left, y1: @top, x2: @x2, y2: @y2, style: line_style)
          end
        end
      end
    end

    private

    def style
      {
        left: "#{@left}px",
        top: "#{@top}px",
      }
    end

    def line_style
      {
        stroke: " #{@color}",
        "stroke-width": "4",
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
lacci-0.2.1 lib/scarpe/wv/line.rb
scarpe-0.2.1 lib/scarpe/wv/line.rb
scarpe-0.2.0 lib/scarpe/wv/line.rb