UNPKG

selenium-webdriver

Version:

The official WebDriver JavaScript bindings from the Selenium project

34 lines 23.7 kB
<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>goog.math.Rect</title><link href="dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>Class goog.math.Rect</h1><a class="source" href="source/lib/goog/math/rect.js.src.html#l35">code &raquo;</a></header><section><p>Class for representing rectangular regions.<h2>Constructor</h2><div class="ctor wrap-details public"><div><div class="ctor"><span class="member">goog.math.Rect <span class="args">( x, y, w, h )</span></span></div><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>x: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>Left.<dt>y: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>Top.<dt>w: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>Width.<dt>h: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>Height.</dl></table></div></div></div></section><div id="visibility-controls"><b>Show:</b><label for="show-public"><span><input type="checkbox" id="show-public" checked/></span>Public</label><label for="show-protected"><span><input type="checkbox" id="show-protected"/></span>Protected</label><label for="show-private"><span><input type="checkbox" id="show-private"/></span>Private</label></div><section id="instance-methods"><h2>Instance Methods</h2><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l266">code &raquo;</a><span class="member"><a name="boundingRect">boundingRect</a> <span class="args">( rect )</span></span></div><p>Expand this rectangle to also include the area of the given rectangle.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>rect: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>The other rectangle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l388">code &raquo;</a><span class="member"><a name="ceil">ceil</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_goog_math_Rect.html">goog.math.Rect</a></code></span></div><p>Rounds the fields to the next larger integer values.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This rectangle with ceil'd fields.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l53">code &raquo;</a><span class="member"><a name="clone">clone</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_goog_math_Rect.html">goog.math.Rect</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A new copy of this Rectangle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l307">code &raquo;</a><span class="member"><a name="contains">contains</a> <span class="args">( another )</span> &rArr; <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Tests whether this rectangle entirely contains another rectangle or coordinate.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>another: <code class="type">(<a href="class_goog_math_Rect.html">goog.math.Rect</a>|<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a>)</code><dd>The rectangle or coordinate to test for containment.</dl><tr><th>Returns<tr><td><dl>Whether this rectangle contains given rectangle or coordinate.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l257">code &raquo;</a><span class="member"><a name="difference">difference</a> <span class="args">( rect )</span> &rArr; <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code></span></div><p>Computes the difference regions between this rectangle and <code >rect</code>. The return value is an array of 0 to 4 rectangles defining the remaining regions of this rectangle after the other has been subtracted.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>rect: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A Rectangle.</dl><tr><th>Returns<tr><td><dl>An array with 0 to 4 rectangles which together define the difference area of rectangle a minus rectangle b.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l342">code &raquo;</a><span class="member"><a name="distance">distance</a> <span class="args">( point )</span> &rArr; <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>point: <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code><dd>A coordinate.</dl><tr><th>Returns<tr><td><dl>The distance between the point and the closest point inside the rectangle. Returns 0 if the point is inside the rectangle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l401">code &raquo;</a><span class="member"><a name="floor">floor</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_goog_math_Rect.html">goog.math.Rect</a></code></span></div><p>Rounds the fields to the next smaller integer values.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This rectangle with floored fields.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l378">code &raquo;</a><span class="member"><a name="getBottomRight">getBottomRight</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A new coordinate for the bottom-right corner of the rectangle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l368">code &raquo;</a><span class="member"><a name="getCenter">getCenter</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A new coordinate for the center of the rectangle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l350">code &raquo;</a><span class="member"><a name="getSize">getSize</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_goog_math_Size.html">goog.math.Size</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>The size of this rectangle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l359">code &raquo;</a><span class="member"><a name="getTopLeft">getTopLeft</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A new coordinate for the top-left corner of the rectangle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l124">code &raquo;</a><span class="member"><a name="intersection">intersection</a> <span class="args">( rect )</span> &rArr; <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Computes the intersection of this rectangle and the rectangle parameter. If there is no intersection, returns false and leaves this rectangle as is.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>rect: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A Rectangle.</dl><tr><th>Returns<tr><td><dl>True iff this rectangle intersects with the parameter.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l193">code &raquo;</a><span class="member"><a name="intersects">intersects</a> <span class="args">( rect )</span> &rArr; <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Returns whether a rectangle intersects this rectangle.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>rect: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A rectangle.</dl><tr><th>Returns<tr><td><dl>Whether rect intersects this rectangle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l414">code &raquo;</a><span class="member"><a name="round">round</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_goog_math_Rect.html">goog.math.Rect</a></code></span></div><p>Rounds the fields to nearest integer values.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This rectangle with rounded fields.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l456">code &raquo;</a><span class="member"><a name="scale">scale</a> <span class="args">( sx, opt_sy )</span> &rArr; <code class="type">!<a href="class_goog_math_Rect.html">goog.math.Rect</a></code></span></div><p>Scales this rectangle by the given scale factors. The left and width values are scaled by <code >sx</code> and the top and height values are scaled by <code >opt_sy</code>. If <code >opt_sy</code> is not given, then all fields are scaled by <code >sx</code>.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>sx: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The scale factor to use for the x dimension.<dt>opt_sy: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>The scale factor to use for the y dimension.</dl><tr><th>Returns<tr><td><dl>This rectangle after scaling.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l328">code &raquo;</a><span class="member"><a name="squaredDistance">squaredDistance</a> <span class="args">( point )</span> &rArr; <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>point: <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code><dd>A coordinate.</dl><tr><th>Returns<tr><td><dl>The squared distance between the point and the closest point inside the rectangle. Returns 0 if the point is inside the rectangle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l63">code &raquo;</a><span class="member"><a name="toBox">toBox</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="class_goog_math_Box.html">goog.math.Box</a></code></span></div><p>Returns a new Box object with the same position and dimensions as this rectangle.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A new Box representation of this Rectangle.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l92">code &raquo;</a><span class="member"><a name="toString">toString</a> <span class="args">( )</span> &rArr; <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Returns a nice string representing size and dimensions of rectangle.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>In the form (50, 73 - 75w x 25h).</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l433">code &raquo;</a><span class="member"><a name="translate">translate</a> <span class="args">( tx, opt_ty )</span> &rArr; <code class="type">!<a href="class_goog_math_Rect.html">goog.math.Rect</a></code></span></div><p>Translates this rectangle by the given offsets. If a <code >goog.math.Coordinate</code> is given, then the left and top values are translated by the coordinate's x and y values. Otherwise, top and left are translated by <code >tx</code> and <code >opt_ty</code> respectively.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>tx: <code class="type">(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>|<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a>)</code><dd>The value to translate left by or the the coordinate to translate this rect by.<dt>opt_ty: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>The value to translate top by.</dl><tr><th>Returns<tr><td><dl>This rectangle after translating.</dl></table></div></details></div></div></section><section id="instance-properties"><h2>Instance Properties</h2><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l46">code &raquo;</a><span class="member"><a name="height">height</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div></summary></details></div></div><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l37">code &raquo;</a><span class="member"><a name="left">left</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div></summary></details></div></div><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l40">code &raquo;</a><span class="member"><a name="top">top</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div></summary></details></div></div><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l43">code &raquo;</a><span class="member"><a name="width">width</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div></summary></details></div></div></section><section id="static-functions"><h2>Static Functions</h2><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l286">code &raquo;</a><span class="member"><a name="goog.math.Rect.boundingRect">goog.math.Rect.boundingRect</a> <span class="args">( a, b )</span> &rArr; <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code></span></div><p>Returns a new rectangle which completely contains both input rectangles.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A rectangle.<dt>b: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A rectangle.</dl><tr><th>Returns<tr><td><dl>A new bounding rect, or null if either rect is null.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l80">code &raquo;</a><span class="member"><a name="goog.math.Rect.createFromBox">goog.math.Rect.createFromBox</a> <span class="args">( box )</span> &rArr; <code class="type">!<a href="class_goog_math_Rect.html">goog.math.Rect</a></code></span></div><p>Creates a new Rect object with the same position and dimensions as a given Box. Note that this is only the inverse of toBox if left/top are defined.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>box: <code class="type"><a href="class_goog_math_Box.html">goog.math.Box</a></code><dd>A box.</dl><tr><th>Returns<tr><td><dl>A new Rect initialized with the box's position and size.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l207">code &raquo;</a><span class="member"><a name="goog.math.Rect.difference">goog.math.Rect.difference</a> <span class="args">( a, b )</span> &rArr; <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code></span></div><p>Computes the difference regions between two rectangles. The return value is an array of 0 to 4 rectangles defining the remaining regions of the first rectangle after the second has been subtracted.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A Rectangle.<dt>b: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A Rectangle.</dl><tr><th>Returns<tr><td><dl>An array with 0 to 4 rectangles which together define the difference area of rectangle a minus rectangle b.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l106">code &raquo;</a><span class="member"><a name="goog.math.Rect.equals">goog.math.Rect.equals</a> <span class="args">( a, b )</span> &rArr; <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Compares rectangles for equality.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A Rectangle.<dt>b: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A Rectangle.</dl><tr><th>Returns<tr><td><dl>True iff the rectangles have the same left, top, width, and height, or if both are null.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l154">code &raquo;</a><span class="member"><a name="goog.math.Rect.intersection">goog.math.Rect.intersection</a> <span class="args">( a, b )</span> &rArr; <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code></span></div><p>Returns the intersection of two rectangles. Two rectangles intersect if they touch at all, for example, two zero width and height rectangles would intersect if they had the same top and left.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A Rectangle.<dt>b: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A Rectangle.</dl><tr><th>Returns<tr><td><dl>A new intersection rect (even if width and height are 0), or null if there is no intersection.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/math/rect.js.src.html#l182">code &raquo;</a><span class="member"><a name="goog.math.Rect.intersects">goog.math.Rect.intersects</a> <span class="args">( a, b )</span> &rArr; <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Returns whether two rectangles intersect. Two rectangles intersect if they touch at all, for example, two zero width and height rectangles would intersect if they had the same top and left.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A Rectangle.<dt>b: <code class="type"><a href="class_goog_math_Rect.html">goog.math.Rect</a></code><dd>A Rectangle.</dl><tr><th>Returns<tr><td><dl>Whether a and b intersect.</dl></table></div></details></div></div></section></main><nav id="topnav"><div><div id="menubutton"><label for="sidenav-toggle">Menu</label></div><form id="searchbox"><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></nav><nav id="sidenav"><input type="checkbox" id="sidenav-types-ctrl" /><input type="checkbox" id="sidenav-files-ctrl" /><input type="checkbox" id="sidenav-modules-ctrl" /><a id="sidenav-overview"><div><h4>Overview</h4></div></a><div id="sidenav-types"><label for="sidenav-types-ctrl"><h4>Types</h4></label><i>Loading</i></div><div id="sidenav-modules"><label for="sidenav-modules-ctrl"><h4>Modules</h4></label><i>Loading</i></div><div id="sidenav-files"><label for="sidenav-files-ctrl"><h4>Files</h4></label><i>Loading</i></div><a href="license.html"><div><h4>License</h4></div></a></nav><div id="push-footer"></div></div><footer><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></footer><script src="types.js"></script><script src="dossier.js"></script>