Sha256: 3d09dffe75419b1094307972b506cac62886bdee3b2c1b3f2f0e4e324d268fcb

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

# -*- coding: utf-8 -*-


require 'rays/ext'
require 'rays/polyline'


module Rays


  class Polygon

    include Enumerable

    def initialize(*args, loop: true)
      setup args, loop
    end

    def transform(matrix = nil, &block)
      lines = to_a
      lines = lines.map {|line| line.transform matrix} if matrix
      lines = block.call lines if block
      self.class.new(*lines)
    end

    def intersects(obj)
      !(self & obj).empty?
    end

    def self.line(*args, loop: false)
      new(*args, loop: loop)
    end

    def self.rect(
      *args, round: nil, lt: nil, rt: nil, lb: nil, rb: nil, nsegment: nil)

      create_rect args, round, lt, rt, lb, rb, nsegment
    end

    def self.ellipse(
      *args, center: nil, radius: nil, hole: nil, from: nil, to: nil,
      nsegment: nil)

      create_ellipse args, center, radius, hole, from, to, nsegment
    end

    def self.curve(*args, loop: false)
      create_curve args, loop
    end

    def self.bezier(*args, loop: false)
      create_bezier args, loop
    end

  end# Polygon


end# Rays

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rays-0.1.34 lib/rays/polygon.rb
rays-0.1.33 lib/rays/polygon.rb
rays-0.1.32 lib/rays/polygon.rb
rays-0.1.31 lib/rays/polygon.rb
rays-0.1.30 lib/rays/polygon.rb
rays-0.1.29 lib/rays/polygon.rb
rays-0.1.28 lib/rays/polygon.rb
rays-0.1.27 lib/rays/polygon.rb
rays-0.1.26 lib/rays/polygon.rb
rays-0.1.25 lib/rays/polygon.rb
rays-0.1.24 lib/rays/polygon.rb
rays-0.1.23 lib/rays/polygon.rb
rays-0.1.22 lib/rays/polygon.rb