IRect
- class IRect
IRect
holds four 32-bit integer coordinates describing the upper and lower bounds of a rectangle.IRect
may be created from outer bounds or from position, width, and height.IRect
describes an area; if its right is less than or equal to its left, or if its bottom is less than or equal to its top, it is considered empty.Example:
irect = skia.IRect(0, 0, 180, 120) irect = skia.IRect((0, 0, 180, 120)) # Convert from tuple print(irect.width(), irect.height()) left, top, right, bottom = tuple(irect) # Convert to tuple
Methods
Returns true if a intersects b.
Returns constructed
IRect
set to (0, 0, 0, 0).Returns constructed
IRect
set to (l, t, r, b).Returns constructed
IRect
set to (0, 0, size.width(), size.height()).Returns constructed
IRect
set to (0, 0, w, h).Returns constructed
IRect
set to: (x, y, x + w, y + h).Overloaded function.
Adjusts
IRect
by adding dL to fLeft, dT to fTop, dR to fRight, and dB to fBottom.Returns bottom edge of
IRect
, if sorted.Overloaded function.
Returns true if
IRect
contains construction.Returns span on the y-axis.
Returns span on the y-axis.
Insets
IRect
by (dx,dy).Overloaded function.
Returns true if fLeft is equal to or greater than fRight, or if fTop is equal to or greater than fBottom.
Sets
IRect
to the union of itself and r.Returns left edge of
IRect
, if sorted.Returns
IRect
, inset by (dx, dy).Overloaded function.
Returns
IRect
, outset by (dx, dy).Returns
IRect
with fLeft and fRight swapped if fLeft is greater than fRight; and with fTop and fBottom swapped if fTop is greater than fBottom.Overloaded function.
Offsets
IRect
so that fLeft equals newX, and fTop equals newY.Outsets
IRect
by (dx, dy).Returns right edge of
IRect
, if sorted.Sets
IRect
to (0, 0, 0, 0).Sets
IRect
to (left, top, right, bottom).Sets
IRect
to: (x, y, x + width, y + height).Returns spans on the x-axis and y-axis.
Swaps fLeft and fRight if fLeft is greater than fRight; and swaps fTop and fBottom if fTop is greater than fBottom.
Returns top edge of
IRect
, if sorted.Returns span on the x-axis.
Returns span on the x-axis.
Returns left edge of
IRect
, if sorted.Returns top edge of
IRect
, if sorted.Attributes
larger y-axis bounds
smaller x-axis bounds
larger x-axis bounds
smaller y-axis bounds
Methods
- static IRect.Intersects(a: skia.IRect, b: skia.IRect) bool
Returns true if a intersects b.
Returns false if either a or b is empty, or do not intersect.
- static IRect.MakeEmpty() skia.IRect
Returns constructed
IRect
set to (0, 0, 0, 0).Many other rectangles are empty; if left is equal to or greater than right, or if top is equal to or greater than bottom. Setting all members to zero is a convenience, but does not designate a special empty rectangle.
- Returns:
bounds (0, 0, 0, 0)
- static IRect.MakeLTRB(l: int, t: int, r: int, b: int) skia.IRect
Returns constructed
IRect
set to (l, t, r, b).Does not sort input;
IRect
may result in fLeft greater than fRight, or fTop greater than fBottom.- Parameters:
l – integer stored in fLeft
t – integer stored in fTop
r – integer stored in fRight
b – integer stored in fBottom
- Returns:
bounds (l, t, r, b)
- static IRect.MakeSize(size: skia.ISize) skia.IRect
Returns constructed
IRect
set to (0, 0, size.width(), size.height()).Does not validate input; size.width() or size.height() may be negative.
- Parameters:
size – values for
IRect
width and height- Returns:
bounds (0, 0, size.width(), size.height())
- static IRect.MakeWH(w: int, h: int) skia.IRect
Returns constructed
IRect
set to (0, 0, w, h).Does not validate input; w or h may be negative.
- static IRect.MakeXYWH(x: int, y: int, w: int, h: int) skia.IRect
Returns constructed
IRect
set to: (x, y, x + w, y + h).Does not validate input; w or h may be negative.
- Parameters:
x – stored in fLeft
y – stored in fTop
w – added to x and stored in fRight
h – added to y and stored in fBottom
- Returns:
bounds at (x, y) with width w and height h
- IRect.__init__(*args, **kwargs)
Overloaded function.
__init__(self: skia.IRect) -> None
Creates
IRect
set to (0, 0, 0, 0).Many other rectangles are empty; if left is equal to or greater than right, or if top is equal to or greater than bottom. Setting all members to zero is a convenience, but does not designate a special empty rectangle.
- return:
bounds (0, 0, 0, 0)
__init__(self: skia.IRect, w: int, h: int) -> None
__init__(self: skia.IRect, l: int, t: int, r: int, b: int) -> None
Creates
IRect
set to: (x, y, x + w, y + h).Does not validate input; w or h may be negative.
- l:
integer stored in fLeft
- t:
integer stored in fTop
- r:
integer stored in fRight
- b:
integer stored in fBottom
- return:
bounds (l, t, r, b)
__init__(self: skia.IRect, t: tuple) -> None
- IRect.adjust(self: skia.IRect, dL: int, dT: int, dR: int, dB: int) None
Adjusts
IRect
by adding dL to fLeft, dT to fTop, dR to fRight, and dB to fBottom.If dL is positive, narrows
IRect
on the left. If negative, widens it on the left. If dT is positive, shrinksIRect
on the top. If negative, lengthens it on the top. If dR is positive, narrowsIRect
on the right. If negative, widens it on the right. If dB is positive, shrinksIRect
on the bottom. If negative, lengthens it on the bottom.The resulting
IRect
is not checked for validity. Thus, if the resultingIRect
left is greater than right, theIRect
will be considered empty. Callsort()
after this call if that is not the desired behavior.- Parameters:
dL – offset added to fLeft
dT – offset added to fTop
dR – offset added to fRight
dB – offset added to fBottom
- IRect.bottom(self: skia.IRect) int
Returns bottom edge of
IRect
, if sorted.Call
isEmpty()
to see ifIRect
may be invalid, andsort()
to reverse fTop and fBottom if needed.Returns fBottom
- IRect.contains(*args, **kwargs)
Overloaded function.
contains(self: skia.IRect, x: int, y: int) -> bool
contains(self: skia.IRect, r: skia.IRect) -> bool
contains(self: skia.IRect, r: SkRect) -> bool
- IRect.containsNoEmptyCheck(self: skia.IRect, r: skia.IRect) bool
Returns true if
IRect
contains construction.Asserts if
IRect
is empty or construction is empty, and if SK_DEBUG is defined.Return is undefined if
IRect
is empty or construction is empty.
- IRect.height(self: skia.IRect) int
Returns span on the y-axis.
This does not check if
IRect
is sorted, or if result fits in 32-bit signed integer; result may be negative.- Returns:
fBottom minus fTop
- IRect.height64(self: skia.IRect) int
Returns span on the y-axis.
This does not check if
IRect
is sorted, so the result may be negative. This is safer than callingheight()
sinceheight()
might overflow in its calculation.- Returns:
fBottom minus fTop cast to int64_t
- IRect.inset(self: skia.IRect, dx: int, dy: int) None
Insets
IRect
by (dx,dy).If dx is positive, makes
IRect
narrower. If dx is negative, makesIRect
wider. If dy is positive, makesIRect
shorter. If dy is negative, makesIRect
taller.- Parameters:
dx – offset added to fLeft and subtracted from fRight
dy – offset added to fTop and subtracted from fBottom
- IRect.intersect(*args, **kwargs)
Overloaded function.
intersect(self: skia.IRect, r: skia.IRect) -> bool
intersect(self: skia.IRect, a: skia.IRect, b: skia.IRect) -> bool
- IRect.isEmpty(self: skia.IRect) bool
- IRect.isEmpty64(self: skia.IRect) bool
Returns true if fLeft is equal to or greater than fRight, or if fTop is equal to or greater than fBottom.
Call
sort()
to reverse rectangles with negativewidth64()
orheight64()
.- Returns:
true if
width64()
orheight64()
are zero or negative
- IRect.join(self: skia.IRect, r: skia.IRect) None
Sets
IRect
to the union of itself and r.Has no effect if r is empty. Otherwise, if
IRect
is empty, setsIRect
to r.- Parameters:
r – expansion
IRect
- IRect.left(self: skia.IRect) int
Returns left edge of
IRect
, if sorted.Call
sort()
to reverse fLeft and fRight if needed.- Returns:
fLeft
- IRect.makeInset(self: skia.IRect, dx: int, dy: int) skia.IRect
Returns
IRect
, inset by (dx, dy).If dx is negative,
IRect
returned is wider. If dx is positive,IRect
returned is narrower. If dy is negative,IRect
returned is taller. If dy is positive,IRect
returned is shorter.- Parameters:
dx – offset added to fLeft and subtracted from fRight
dy – offset added to fTop and subtracted from fBottom
- Returns:
IRect
inset symmetrically left and right, top and bottom
- IRect.makeOffset(*args, **kwargs)
Overloaded function.
makeOffset(self: skia.IRect, dx: int, dy: int) -> skia.IRect
Returns
IRect
offset by (dx, dy).If dx is negative,
IRect
returned is moved to the left. If dx is positive,IRect
returned is moved to the right. If dy is negative,IRect
returned is moved upward. If dy is positive,IRect
returned is moved downward.- dx:
offset added to fLeft and fRight
- dy:
offset added to fTop and fBottom
- return:
IRect
offset by dx and dy, with original width and height
makeOffset(self: skia.IRect, offset: skia.IPoint) -> skia.IRect
Returns
IRect
offset by (offset.x(), offset.y()).If offset.x() is negative,
IRect
returned is moved to the left. If offset.x() is positive,IRect
returned is moved to the right. If offset.y() is negative,IRect
returned is moved upward. If offset.y() is positive,IRect
returned is moved downward.- offset:
translation vector
- return:
IRect
translated by offset, with original width and height
- IRect.makeOutset(self: skia.IRect, dx: int, dy: int) skia.IRect
Returns
IRect
, outset by (dx, dy).If dx is negative,
IRect
returned is narrower. If dx is positive,IRect
returned is wider. If dy is negative,IRect
returned is shorter. If dy is positive,IRect
returned is taller.- Parameters:
dx – offset subtracted to fLeft and added from fRight
dy – offset subtracted to fTop and added from fBottom
- Returns:
IRect
outset symmetrically left and right, top and bottom
- IRect.makeSorted(self: skia.IRect) skia.IRect
Returns
IRect
with fLeft and fRight swapped if fLeft is greater than fRight; and with fTop and fBottom swapped if fTop is greater than fBottom.Result may be empty; and
width()
andheight()
will be zero or positive.- Returns:
sorted
IRect
- IRect.offset(*args, **kwargs)
Overloaded function.
offset(self: skia.IRect, dx: int, dy: int) -> None
Offsets
IRect
by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.If dx is negative, moves
IRect
returned to the left. If dx is positive, movesIRect
returned to the right. If dy is negative, movesIRect
returned upward. If dy is positive, movesIRect
returned downward.- dx:
offset added to fLeft and fRight
- dy:
offset added to fTop and fBottom
offset(self: skia.IRect, delta: skia.IPoint) -> None
Offsets
IRect
by adding delta.fX to fLeft, fRight; and by adding delta.fY to fTop, fBottom.If delta.fX is negative, moves
IRect
returned to the left. If delta.fX is positive, movesIRect
returned to the right. If delta.fY is negative, movesIRect
returned upward. If delta.fY is positive, movesIRect
returned downward.- delta:
offset added to
IRect
- IRect.offsetTo(self: skia.IRect, newX: int, newY: int) None
Offsets
IRect
so that fLeft equals newX, and fTop equals newY.width and height are unchanged.
- IRect.outset(self: skia.IRect, dx: int, dy: int) None
Outsets
IRect
by (dx, dy).If dx is positive, makes
IRect
wider. If dx is negative, makesIRect
narrower. If dy is positive, makesIRect
taller. If dy is negative, makesIRect
shorter.- Parameters:
dx – subtracted to fLeft and added from fRight
dy – subtracted to fTop and added from fBottom
- IRect.right(self: skia.IRect) int
Returns right edge of
IRect
, if sorted.Call
sort()
to reverse fLeft and fRight if needed.- Returns:
fRight
- IRect.setEmpty(self: skia.IRect) None
Sets
IRect
to (0, 0, 0, 0).Many other rectangles are empty; if left is equal to or greater than right, or if top is equal to or greater than bottom. Setting all members to zero is a convenience, but does not designate a special empty rectangle.
- IRect.setLTRB(self: skia.IRect, left: int, top: int, right: int, bottom: int) None
Sets
IRect
to (left, top, right, bottom).left and right are not sorted; left is not necessarily less than right. top and bottom are not sorted; top is not necessarily less than bottom.
- Parameters:
left – stored in fLeft
top – stored in fTop
right – stored in fRight
bottom – stored in fBottom
- IRect.setWH(self: skia.IRect, width: int, height: int) None
- IRect.setXYWH(self: skia.IRect, x: int, y: int, width: int, height: int) None
Sets
IRect
to: (x, y, x + width, y + height).Does not validate input; width or height may be negative.
- Parameters:
x – stored in fLeft
y – stored in fTop
width – added to x and stored in fRight
height – added to y and stored in fBottom
- IRect.size(self: skia.IRect) skia.ISize
Returns spans on the x-axis and y-axis.
- IRect.sort(self: skia.IRect) None
Swaps fLeft and fRight if fLeft is greater than fRight; and swaps fTop and fBottom if fTop is greater than fBottom.
Result may be empty, and
width()
andheight()
will be zero or positive.
- IRect.top(self: skia.IRect) int
Returns top edge of
IRect
, if sorted.Call
isEmpty()
to see ifIRect
may be invalid, andsort()
to reverse fTop and fBottom if needed.- Returns:
fTop
- IRect.topLeft(self: skia.IRect) skia.IPoint
- IRect.width(self: skia.IRect) int
Returns span on the x-axis.
This does not check if
IRect
is sorted, or if result fits in 32-bit signed integer; result may be negative.- Returns:
fRight minus fLeft
- IRect.width64(self: skia.IRect) int
Returns span on the x-axis.
This does not check if
IRect
is sorted, so the result may be negative. This is safer than callingwidth()
sincewidth()
might overflow in its calculation.- Returns:
fRight minus fLeft cast to int64_t
Attributes
- IRect.fBottom
larger y-axis bounds
- IRect.fLeft
smaller x-axis bounds
- IRect.fRight
larger x-axis bounds
- IRect.fTop
smaller y-axis bounds