Sha256: bf59ac965f057dc2b4117461d6b5e5c6129a5d1e2255ffbc8d19cb8bbef77e6d

Contents?: true

Size: 1.01 KB

Versions: 12

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Gruff
  # @private
  class Renderer::Line
    EPSILON = 0.001

    def initialize(renderer, color:, width: nil)
      @renderer = renderer
      @color = color
      @width = width
    end

    def render(start_x, start_y, end_x, end_y)
      render_line(start_x, start_y, end_x, end_y, @color)
    end

  private

    def render_line(start_x, start_y, end_x, end_y, color)
      # FIXME(uwe): Workaround for Issue #66
      #             https://github.com/topfunky/gruff/issues/66
      #             https://github.com/rmagick/rmagick/issues/82
      #             Remove if the issue gets fixed.
      unless defined?(JRUBY_VERSION)
        start_x += EPSILON
        end_x += EPSILON
        start_y += EPSILON
        end_y += EPSILON
      end

      @renderer.draw.push
      @renderer.draw.stroke_width(@width) if @width
      @renderer.draw.stroke(color)
      @renderer.draw.fill(color)
      @renderer.draw.line(start_x, start_y, end_x, end_y)
      @renderer.draw.pop
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gruff-0.24.0-java lib/gruff/renderer/line.rb
gruff-0.24.0 lib/gruff/renderer/line.rb
gruff-0.23.0 lib/gruff/renderer/line.rb
gruff-0.23.0-java lib/gruff/renderer/line.rb
gruff-0.22.0 lib/gruff/renderer/line.rb
gruff-0.22.0-java lib/gruff/renderer/line.rb
gruff-0.21.0-java lib/gruff/renderer/line.rb
gruff-0.21.0 lib/gruff/renderer/line.rb
gruff-0.20.0-java lib/gruff/renderer/line.rb
gruff-0.20.0 lib/gruff/renderer/line.rb
gruff-0.19.0 lib/gruff/renderer/line.rb
gruff-0.19.0-java lib/gruff/renderer/line.rb