Sha256: e9102dea2f63841ea8499967ea425245b6ea55bd2393a1ce24fdcea9f57db899

Contents?: true

Size: 923 Bytes

Versions: 1

Compression:

Stored size: 923 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_a
        if @control
          [command_code, @control.x, @control.y, @target.x, @target.y]
        else
          [command_code, @target.x, @target.y]
        end
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
savage-1.2.0 lib/savage/directions/quadratic_curve_to.rb