Sha256: cc44caa0ae064ed4c89e8aa9713d17d51d5b9be151f340cad3b00e3a08811a02

Contents?: true

Size: 1.09 KB

Versions: 14

Compression:

Stored size: 1.09 KB

Contents

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

Version data entries

14 entries across 14 versions & 1 rubygems

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