Sha256: f4e9acfaeb449db732f2bc5f6e36ded94941b4d8532a92194815ca358a1b29a8

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

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.points(*args)
      points! args
    end

    def self.lines(*args)
      lines! args
    end

    def self.line_strip(*args, loop: false)
      line_strip! args, loop
    end

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

      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)

      ellipse! args, center, radius, hole, from, to, nsegment
    end

    def self.triangles(*args, loop: true)
      triangles! args, loop
    end

    def self.triangle_strip(*args)
      triangle_strip! args
    end

    def self.triangle_fan(*args)
      triangle_fan! args
    end

    def self.quads(*args, loop: true)
      quads! args, loop
    end

    def self.quad_strip(*args)
      quad_strip! args
    end

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

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

  end# Polygon


end# Rays

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rays-0.1.47 lib/rays/polygon.rb