Sha256: 070c876b68f3b3a50676697bb62a7fe2b661ba76a3f31864f2bc9ba151d96fbb

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

class Shoes
  class Arrow < Common::ArtElement
    style_with :art_styles, :curve, :common_styles, :dimensions
    STYLES = { fill: Shoes::COLORS[:black] }.freeze

    def create_dimensions(left, top, width)
      left   ||= @style[:left] || 0
      top    ||= @style[:top] || 0
      width  ||= @style[:width] || 0

      @dimensions = AbsoluteDimensions.new left, top, width, width, @style
    end

    def width=(*_)
      super
      gui.update_position
    end

    # Our locations are nonstandard, so let redrawing and gradient know
    def redraw_left
      return 0 unless element_left
      element_left - width * 0.5 - style[:strokewidth].to_i
    end

    def redraw_top
      return 0 unless element_top
      element_top - width * 0.4 - style[:strokewidth].to_i
    end

    def redraw_width
      width + style[:strokewidth].to_i * 2
    end

    def redraw_height
      width + style[:strokewidth].to_i * 2
    end

    def gradient_left
      redraw_left
    end

    def gradient_top
      redraw_top
    end

    def gradient_height
      redraw_height
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoes-core-4.0.0.rc1 lib/shoes/arrow.rb