6package org.mozilla.gecko.gfx;
8import android.graphics.Point;
9import android.graphics.PointF;
10import android.graphics.Rect;
11import android.graphics.RectF;
18 public static RectF
expand(RectF rect,
float moreWidth,
float moreHeight) {
19 float halfMoreWidth = moreWidth / 2;
20 float halfMoreHeight = moreHeight / 2;
21 return new RectF(rect.left - halfMoreWidth,
22 rect.top - halfMoreHeight,
23 rect.right + halfMoreWidth,
24 rect.bottom + halfMoreHeight);
27 public static RectF
contract(RectF rect,
float lessWidth,
float lessHeight) {
28 float halfLessWidth = lessWidth / 2.0f;
29 float halfLessHeight = lessHeight / 2.0f;
30 return new RectF(rect.left + halfLessWidth,
31 rect.top + halfLessHeight,
32 rect.right - halfLessWidth,
33 rect.bottom - halfLessHeight);
36 public static RectF
intersect(RectF one, RectF two) {
45 float x = rect.left *
scale;
46 float y = rect.top *
scale;
47 return new RectF(
x,
y,
48 x + (rect.width() *
scale),
49 y + (rect.height() *
scale));
53 float x = rect.left /
scale;
54 float y = rect.top /
scale;
55 return new RectF(
x,
y,
56 x + (rect.width() /
scale),
57 y + (rect.height() /
scale));
67 public static void round(RectF rect, Rect dest) {
68 dest.set(
Math.round(rect.left),
Math.round(rect.top),
69 Math.round(rect.right),
Math.round(rect.bottom));
73 return new Rect((
int)
Math.ceil(rect.left), (
int)
Math.ceil(rect.top),
74 (
int)
Math.floor(rect.right), (
int)
Math.floor(rect.bottom));
78 return new IntSize(rect.width(), rect.height());
82 return new Point(rect.left, rect.top);
86 return new PointF(rect.left, rect.top);
90 if (
a ==
null && b ==
null)
93 return a !=
null && b !=
null
103 public static void assign(
final RectF target,
final RectF source)
105 target.left = source.left;
106 target.top = source.top;
107 target.right = source.right;
108 target.bottom = source.bottom;
static RectF scale(RectF rect, float scale)
static RectF inverseScale(RectF rect, float scale)
static Rect round(RectF rect)
Returns the nearest integer rect of the given rect.
static void assign(final RectF target, final RectF source)
Assign rectangle values from source to target.
static Point getOrigin(Rect rect)
static PointF getOrigin(RectF rect)
static void round(RectF rect, Rect dest)
static IntSize getSize(Rect rect)
static RectF intersect(RectF one, RectF two)
static RectF expand(RectF rect, float moreWidth, float moreHeight)
static RectF contract(RectF rect, float lessWidth, float lessHeight)
static boolean fuzzyEquals(RectF a, RectF b)
static Rect roundIn(RectF rect)
static boolean fuzzyEquals(float a, float b)