selenium-webdriver
Version:
The official WebDriver JavaScript bindings from the Selenium project
22 lines (21 loc) • 17.2 kB
HTML
<meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>goog.math.Coordinate</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.Coordinate</h1><a class="source" href="source/lib/goog/math/coordinate.js.src.html#l32">code »</a></header><section><p>Class for representing coordinates and positions.<h2>Constructor</h2><div class="ctor wrap-details public"><div><div class="ctor"><span class="member">goog.math.Coordinate <span class="args">( opt_x, opt_y )</span></span></div><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>opt_x: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>Left, defaults to 0.<dt>opt_y: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>Top, defaults to 0.</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/coordinate.js.src.html#l167">code »</a><span class="member"><a name="ceil">ceil</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div><p>Rounds the x and y fields to the next larger integer values.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This coordinate 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/coordinate.js.src.html#l51">code »</a><span class="member"><a name="clone">clone</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div><p>Returns a new copy of the coordinate.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A clone of this 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/coordinate.js.src.html#l178">code »</a><span class="member"><a name="floor">floor</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div><p>Rounds the x and y fields to the next smaller integer values.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This coordinate 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/coordinate.js.src.html#l265">code »</a><span class="member"><a name="rotateDegrees">rotateDegrees</a> <span class="args">( degrees, opt_center )</span></span></div><p>Rotates this coordinate clockwise about the origin (or, optionally, the given
center) by the given angle, in degrees.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>degrees: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The angle by which to rotate this coordinate
clockwise about the given center, in degrees.<dt>opt_center: <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a>=</code><dd>The center of rotation. Defaults
to (0, 0) if not given.</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/coordinate.js.src.html#l244">code »</a><span class="member"><a name="rotateRadians">rotateRadians</a> <span class="args">( radians, opt_center )</span></span></div><p>Rotates this coordinate clockwise about the origin (or, optionally, the given
center) by the given angle, in radians.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>radians: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The angle by which to rotate this coordinate
clockwise about the given center, in radians.<dt>opt_center: <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a>=</code><dd>The center of rotation. Defaults
to (0, 0) if not given.</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/coordinate.js.src.html#l189">code »</a><span class="member"><a name="round">round</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div><p>Rounds the x and y fields to the nearest integer values.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This coordinate 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/coordinate.js.src.html#l228">code »</a><span class="member"><a name="scale">scale</a> <span class="args">( sx, opt_sy )</span> ⇒ <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div><p>Scales this coordinate by the given scale factors. The x and y values are
scaled by <code >sx</code> and <code >opt_sy</code> respectively. If <code >opt_sy</code>
is not given, then <code >sx</code> is used for both x and y.</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 coordinate 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/coordinate.js.src.html#l62">code »</a><span class="member"><a name="toString">toString</a> <span class="args">( )</span> ⇒ <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 the coordinate.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>In the form (50, 73).</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/coordinate.js.src.html#l206">code »</a><span class="member"><a name="translate">translate</a> <span class="args">( tx, opt_ty )</span> ⇒ <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div><p>Translates this box by the given offsets. If a <code >goog.math.Coordinate</code>
is given, then the x and y values are translated by the coordinate's x and y.
Otherwise, x and y 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 x by or the
the coordinate to translate this coordinate 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 y by.</dl><tr><th>Returns<tr><td><dl>This coordinate 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/coordinate.js.src.html#l37">code »</a><span class="member"><a name="x">x</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>X-value</summary></details></div></div><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/math/coordinate.js.src.html#l43">code »</a><span class="member"><a name="y">y</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Y-value</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/coordinate.js.src.html#l114">code »</a><span class="member"><a name="goog.math.Coordinate.azimuth">goog.math.Coordinate.azimuth</a> <span class="args">( a )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Returns the angle from the origin to a coordinate.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <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 angle, in degrees, clockwise from the positive X
axis to <code >a</code>.</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/coordinate.js.src.html#l146">code »</a><span class="member"><a name="goog.math.Coordinate.difference">goog.math.Coordinate.difference</a> <span class="args">( a, b )</span> ⇒ <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div><p>Returns the difference between two coordinates as a new
goog.math.Coordinate.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code><dd>A Coordinate.<dt>b: <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>A Coordinate representing the difference
between <code >a</code> and <code >b</code>.</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/coordinate.js.src.html#l91">code »</a><span class="member"><a name="goog.math.Coordinate.distance">goog.math.Coordinate.distance</a> <span class="args">( a, b )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Returns the distance between two coordinates.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code><dd>A Coordinate.<dt>b: <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 <code >a</code> and <code >b</code>.</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/coordinate.js.src.html#l74">code »</a><span class="member"><a name="goog.math.Coordinate.equals">goog.math.Coordinate.equals</a> <span class="args">( a, b )</span> ⇒ <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 coordinates for equality.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <code class="type"><a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code><dd>A Coordinate.<dt>b: <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>True iff the coordinates are equal, 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/coordinate.js.src.html#l103">code »</a><span class="member"><a name="goog.math.Coordinate.magnitude">goog.math.Coordinate.magnitude</a> <span class="args">( a )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Returns the magnitude of a coordinate.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <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 origin and <code >a</code>.</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/coordinate.js.src.html#l131">code »</a><span class="member"><a name="goog.math.Coordinate.squaredDistance">goog.math.Coordinate.squaredDistance</a> <span class="args">( a, b )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Returns the squared distance between two coordinates. Squared distances can
be used for comparisons when the actual value is not required.
Performance note: eliminating the square root is an optimization often used
in lower-level languages, but the speed difference is not nearly as
pronounced in JavaScript (only a few percent.)</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code><dd>A Coordinate.<dt>b: <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 <code >a</code> and <code >b</code>.</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/coordinate.js.src.html#l158">code »</a><span class="member"><a name="goog.math.Coordinate.sum">goog.math.Coordinate.sum</a> <span class="args">( a, b )</span> ⇒ <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code></span></div><p>Returns the sum of two coordinates as a new goog.math.Coordinate.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>a: <code class="type">!<a href="class_goog_math_Coordinate.html">goog.math.Coordinate</a></code><dd>A Coordinate.<dt>b: <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>A Coordinate representing the sum of the two
coordinates.</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>