Sha256: 5626e50de90f83f616f0d9b7e7fffe0ddbb51d61077a5497f6b004e5caed601c

Contents?: true

Size: 914 Bytes

Versions: 14

Compression:

Stored size: 914 Bytes

Contents

module Savage
  module Directions
    class QuadraticCurveTo < PointTarget
      attr_accessor :control
    
      def initialize(*args)
        raise ArgumentError if args.length < 2
        case args.length
        when 2
          super(args[0],args[1],true)
        when 3
          raise ArgumentError if args[2].kind_of?(Numeric)
          super(args[0],args[1],args[2])
        when 4
          @control = Point.new(args[0],args[1])
          super(args[2],args[3],true)
        when 5
          @control = Point.new(args[0],args[1])
          super(args[2],args[3],args[4])
        end
      end
    
      def to_command
        command_code << ((@control) ? "#{@control.x} #{@control.y} #{@target.x} #{@target.y}".gsub(/ -/,'-') : super().gsub(/[A-Za-z]/,''))
      end

      def command_code
        return (absolute?) ? 'Q' : 'q' if @control
        (absolute?) ? 'T' : 't'
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
savage-1.1.8 lib/savage/directions/quadratic_curve_to.rb
savage-1.1.7 lib/savage/directions/quadratic_curve_to.rb
savage-1.1.6 lib/savage/directions/quadratic_curve_to.rb
savage-1.1.5 lib/savage/directions/quadratic_curve_to.rb
savage-1.1.4 lib/savage/directions/quadratic_curve_to.rb
savage-1.1.3 lib/savage/directions/quadratic_curve_to.rb
savage-1.1.2 lib/savage/directions/quadratic_curve_to.rb
savage-1.1.1 lib/savage/directions/quadratic_curve_to.rb
savage-1.1.0 lib/savage/directions/quadratic_curve_to.rb
savage-1.0.3 lib/savage/directions/quadratic_curve_to.rb
savage-1.0.2 lib/savage/directions/quadratic_curve_to.rb
savage-1.0.1 lib/savage/directions/quadratic_curve_to.rb
savage-1.0.0 lib/savage/directions/quadratic_curve_to.rb
savage-0.2.0 lib/savage/directions/quadratic_curve_to.rb