Sha256: 3434162db92b44b9f5772efa2612a76719e275416d8a9af9c4c0f9918b0c4e58
Contents?: true
Size: 902 Bytes
Versions: 2
Compression:
Stored size: 902 Bytes
Contents
# rectangle.rb module Ruby2D class Rectangle < Quad attr_reader :x, :y, :width, :height def initialize(x=0, y=0, w=200, h=100, c='white') @type_id = 2 @x, @y, @width, @height, @color = x, y, w, h, c update_coords(x, y, w, h) update_color(c) add end def x=(x) @x = @x1 = x @x2 = x + @width @x3 = x + @width @x4 = x end def y=(y) @y = @y1 = y @y2 = y @y3 = y + @height @y4 = y + @height end def width=(w) @width = w update_coords(@x, @y, w, @height) end def height=(h) @height = h update_coords(@x, @y, @width, h) end private def update_coords(x, y, w, h) @x1 = x @y1 = y @x2 = x + w @y2 = y @x4 = x @y4 = y + h @x3 = x + w @y3 = y + h end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby2d-0.3.1 | lib/ruby2d/rectangle.rb |
ruby2d-0.3.0 | lib/ruby2d/rectangle.rb |