Sha256: d2ce922c52d2e1cecf1a3cc2df19ace45931327cc3303ea03f5639c0b35d9645

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module PurplishFrame
  module Rect
    def scale(num)
      [[origin.x*num, origin.y*num], [size.width*num, size.height*num]].to_rect
    end

    def scale!(num)
      self.origin = [origin.x*num, origin.y*num]
      self.size = [size.width*num, size.height*num]
      self
    end

    def left
      origin.x
    end

    def left=(x)
      origin.x = x
    end

    def right
      origin.x+size.width
    end

    def right=(right)
      origin.x = right - size.width
    end

    def center_x
      left+size.width/2
    end

    def center_x=(center_x)
      self.left = center_x-size.width/2
    end

    def width
      size.width
    end

    def width=(w)
      size.width = w
    end

    def height
      size.height
    end

    def top_left
      [left, top].to_point
    end

    def top_right
      [right, top].to_point
    end

    def bottom_left
      [left, bottom].to_point
    end

    def bottom_right
      [right, bottom].to_point
    end

    def top_center
      [center_x, top].to_point
    end

    def bottom_center
      [center_x, bottom].to_point
    end

    def left_center
      [left, center_y].to_point
    end

    def right_center
      [right, center_y].to_point
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
purplish-frame-0.0.12 lib/purplish-frame/non-ui/rect.rb
purplish-frame-0.0.11 lib/purplish-frame/non-ui/rect.rb