Sha256: 04fe95669f1ad632cebe002592a59cdf7a983ac23a0b01787760d001604eab19

Contents?: true

Size: 611 Bytes

Versions: 8

Compression:

Stored size: 611 Bytes

Contents

# Ruby2D::Square

module Ruby2D
  class Square < Rectangle

    attr_reader :size

    def initialize(opts = {})
      @x = opts[:x] || 0
      @y = opts[:y] || 0
      @z = opts[:z] || 0
      @width = @height = @size = opts[:size] || 100
      self.color = opts[:color] || 'white'
      self.opacity = opts[:opacity] if opts[:opacity]
      update_coords(@x, @y, @size, @size)
      add
    end

    # Set the size of the square
    def size=(s)
      self.width = self.height = @size = s
    end

    # Make the inherited width and height attribute accessors private
    private :width=, :height=

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby2d-0.9.5 lib/ruby2d/square.rb
ruby2d-0.9.4 lib/ruby2d/square.rb
ruby2d-0.9.3 lib/ruby2d/square.rb
ruby2d-0.9.2 lib/ruby2d/square.rb
ruby2d-0.9.1 lib/ruby2d/square.rb
ruby2d-0.9.0 lib/ruby2d/square.rb
ruby2d-0.8.1 lib/ruby2d/square.rb
ruby2d-0.8.0 lib/ruby2d/square.rb