class Fzeet::Windows::RECT

Public Class Methods

[](*args) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 12
def self.[](*args)
        case args.length
        when 2 # location, size
                new.set(args[0][:x], args[0][:y], args[0][:x] + args[1][:cx], args[0][:y] + args[1][:cy])
        when 4 # left, top, right, bottom
                new.set(*args)
        else raise ArgumentError
        end
end
Also aliased as: from
from(*args)
Alias for: []

Public Instance Methods

&(other) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 94
def &(other) self.class.new.tap { |r| Windows.IntersectRect(r, self, other) } end
-(other) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 95
def -(other) self.class.new.tap { |r| Windows.SubtractRect(r, self, other) } end
==(other) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 61
def ==(other) Windows.EqualRect(self, other) != 0 end
clear() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 34
def clear; set(0, 0, 0, 0) end
dup() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 27
def dup; self.class[self[:left], self[:top], self[:right], self[:bottom]] end
empty?() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 62
def empty?; Windows.IsRectEmpty(self) != 0 end
exclude?(arg) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 74
def exclude?(arg) !include?(arg) end
get() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 29
def get; [self[:left], self[:top], self[:right], self[:bottom]] end
Also aliased as: to_a
height() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 53
def height; self[:bottom] - self[:top] end
height=(height) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 54
def height=(height) self[:bottom] = self[:top] + height end
include?(*args) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 64
def include?(*args)
        return args.all? { |arg| include?(arg) } if args.length > 1

        case args[0]
        when POINT; Windows.PtInRect(self, args[0]) != 0
        when RECT; [args[0].lt, args[0].lb, args[0].rt, args[0].rb].all? { |pt| include?(pt) }
        else raise ArgumentError
        end
end
inflate(dx, dy) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 90
def inflate(dx, dy) dup.inflate!(dx, dy) end
inflate!(dx, dy) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 91
def inflate!(dx, dy) tap { |r| Windows.Detonate(0, :InflateRect, r, dx, dy) } end
lb() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 41
def lb; POINT[self[:left], self[:bottom]] end
lb=(pt) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 42
def lb=(pt) self[:left], self[:bottom] = pt[:x], pt[:y] end
location()
Alias for: lt
location=(pt)
Alias for: lt=
lt() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 36
def lt; POINT[self[:left], self[:top]] end
Also aliased as: location
lt=(pt) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 37
def lt=(pt) self[:left], self[:top] = pt[:x], pt[:y] end
Also aliased as: location=
normalize() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 78
def normalize; dup.normalize! end
normalize!() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 80
def normalize!
        self[:left], self[:right] = self[:right], self[:left] if self[:left] > self[:right]
        self[:top], self[:bottom] = self[:bottom], self[:top] if self[:top] > self[:bottom]

        self
end
normalized?() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 76
def normalized?; self[:left] <= self[:right] && self[:top] <= self[:bottom] end
offset(dx, dy) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 87
def offset(dx, dy) dup.offset!(dx, dy) end
offset!(dx, dy) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 88
def offset!(dx, dy) tap { |r| Windows.Detonate(0, :OffsetRect, r, dx, dy) } end
rb() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 47
def rb; POINT[self[:right], self[:bottom]] end
rb=(pt) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 48
def rb=(pt) self[:right], self[:bottom] = pt[:x], pt[:y] end
rt() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 44
def rt; POINT[self[:right], self[:top]] end
rt=(pt) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 45
def rt=(pt) self[:right], self[:top] = pt[:x], pt[:y] end
set(l, t, r, b) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 32
def set(l, t, r, b) tap { |rect| rect[:left], rect[:top], rect[:right], rect[:bottom] = l, t, r, b } end
size() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 58
def size; SIZE[width, height] end
Also aliased as: structSize
size=(s) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 59
def size=(s) self.width, self.height = s[:cx], s[:cy] end
structSize()
Alias for: size
to_a()
Alias for: get
width() click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 50
def width; self[:right] - self[:left] end
width=(width) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 51
def width=(width) self[:right] = self[:left] + width end
|(other) click to toggle source
# File lib/fzeet/windows/core/Rect.rb, line 93
def |(other) self.class.new.tap { |r| Windows.UnionRect(r, self, other) } end