aboutsummaryrefslogtreecommitdiff
path: root/files/he/mozilla/javascript_code_modules/geometry.jsm/point/index.html
blob: 54b0c6fe81e4d9b7ffe9d340b07c5cca60805829 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
---
title: Point
slug: Mozilla/JavaScript_code_modules/Geometry.jsm/Point
translation_of: Mozilla/JavaScript_code_modules/Geometry.jsm/Point
---
<p>The <code>Point</code> class offers methods for performing common geometry operations on two dimensional points</p>

<h2 id="Method_overview">Method overview</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <td dir="ltr"><code>Point <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#add()" title="en/JavaScript code modules/Geometry.jsm/Point#add()">add</a>(x, y);</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>Point <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#add()" title="en/JavaScript code modules/Geometry.jsm/Point#add()">add</a>(Point);</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>Point <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#clone()" title="en/JavaScript code modules/Geometry.jsm/Point#clone()">clone</a>();</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>boolean <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#equals()" title="en/JavaScript code modules/Geometry.jsm/Point#equals()">equals</a>(x, y);</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>Point <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#equals()" title="en/JavaScript code modules/Geometry.jsm/Point#equals()">equals</a>(Point);</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>boolean <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#isZero()" title="en/JavaScript code modules/Geometry.jsm/Point#isZero()">isZero</a>();</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>Point <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#map()" title="en/JavaScript code modules/Geometry.jsm/Point#map()">map</a>(mapFunction);</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>Point <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#scale()" title="en/JavaScript code modules/Geometry.jsm/Point#scale()">scale</a>(scaleFactor);</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>Point <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#set()" title="en/JavaScript code modules/Geometry.jsm/Point#set()">set</a>(x, y);</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>Point <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#set()" title="en/JavaScript code modules/Geometry.jsm/Point#set()">set</a>(Point);</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>Point <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#subtract()" title="en/JavaScript code modules/Geometry.jsm/Point#subtract()">subtract</a>(x, y);</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code>Point <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#subtract()" title="en/JavaScript code modules/Geometry.jsm/Point#subtract()">subtract</a>(Point);</code></td>
  </tr>
  <tr>
   <td dir="ltr"><code><a href="/en/JavaScript/Reference/Global_Objects/String" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String">String</a> <a href="/en/JavaScript_code_modules/Geometry.jsm/Point#toString()" title="en/JavaScript code modules/Geometry.jsm/Point#toString()">toString</a>();</code></td>
  </tr>
 </tbody>
</table>

<h2 id="Constructor">Constructor</h2>

<p>יוצר אובייקט <code>Point</code> חדש.</p>

<pre>let p = new Point(x, y);
</pre>

<p>The new point, <code>p</code>, has the specified X and Y coordinates.</p>

<h2 id="Methods">Methods</h2>

<h3 dir="ltr" id="add()">add()</h3>

<p>Adds another point to this one.</p>

<pre>Point add(
  x,
  y
);

Point add(
  Point
);
</pre>

<h6 id="Parameters">Parameters</h6>

<dl>
 <dt><code>x</code></dt>
 <dd>The X coordinate of the point to add to the current point.</dd>
 <dt><code>y</code></dt>
 <dd>The Y coordinate of the point to add to the current point.</dd>
</dl>

<div class="note"><strong>Note:</strong> You may specify another <code>Point</code> object instead of separate X and Y coordinates.</div>

<h6 id="Return_value">Return value</h6>

<p>The value of the <code>Point</code> object after adding the specified value; this isn't a new object, just the same one you called the function on.</p>

<h3 id="clone()">clone()</h3>

<p>Creates and returns a copy of the <code>Point</code> object.</p>

<pre>Point clone();
</pre>

<h6 id="Parameters_2">Parameters</h6>

<p>None.</p>

<h6 id="Return_value_2">Return value</h6>

<p>A new <code>Point</code> object which is a duplicate of the current object.</p>

<h3 id="equals()">equals()</h3>

<p>Determines whether another point is equal to this one.</p>

<pre>boolean equals(
  x,
  y
);

boolean equals(
  Point
);
</pre>

<h6 id="Parameters_3">Parameters</h6>

<dl>
 <dt><code>x</code></dt>
 <dd>The X coordinate of the point to compare to the current point.</dd>
 <dt><code>y</code></dt>
 <dd>The Y coordinate of the point to compare to the current point.</dd>
</dl>

<div class="note"><strong>Note:</strong> You may specify another <code>Point</code> object instead of separate X and Y coordinates.</div>

<h6 id="Return_value_3">Return value</h6>

<p><code>true</code> if the two points are equal, otherwise <code>false</code>. Equality, in this context, means that both the X and Y coordinates are the same.</p>

<h3 id="isZero()">isZero()</h3>

<p>Determines whether or not the point is (0, 0).</p>

<pre>boolean isZero();
</pre>

<h6 id="Parameters_4">Parameters</h6>

<p>None.</p>

<h6 id="Return_value_4">Return value</h6>

<p><code>true</code> if the point's X and Y coordinates are both zero; otherwise <code>false</code>.</p>

<h3 id="map()">map()</h3>

<p>Calls a specified function to manipulate the values of the point's coordinates.</p>

<pre>Point map(
  mapFunction
);
</pre>

<h6 id="Parameters_5">Parameters</h6>

<dl>
 <dt><code>mapFunction</code></dt>
 <dd>The function to call to map the parameters; this function should accept one parameters: a single coordinate value. The <code>Point</code> object will be the value of <code>this</code> within the called function.</dd>
</dl>

<h6 id="Return_value_5">Return value</h6>

<p>The value of the <code>Point</code> object after modifying its coordinates by calling the specified function; this isn't a new object, just the same one you called the function on.</p>

<h3 id="scale()">scale()</h3>

<p>Scales the point's coordinates by a specified factor.</p>

<pre>Point scale(
  scaleFactor
);
</pre>

<h6 id="Parameters_6">Parameters</h6>

<dl>
 <dt><code>scaleFactor</code></dt>
 <dd>The amount by which to scale the point.</dd>
</dl>

<h6 id="Return_value_6">Return value</h6>

<p>The value of the <code>Point</code> object after scaling its coordinates by the specified amount; this isn't a new object, just the same one you called the function on.</p>

<h3 id="set()">set()</h3>

<p>Sets the value of the <code>Point</code> object.</p>

<pre>Point set(
  x,
  y
);

Point set(
  Point
);
</pre>

<h6 id="Parameters_7">Parameters</h6>

<dl>
 <dt><code>x</code></dt>
 <dd>The X coordinate of the point.</dd>
 <dt><code>y</code></dt>
 <dd>The Y coordinate of the point.</dd>
</dl>

<div class="note"><strong>Note:</strong> You may specify another <code>Point</code> object instead of separate X and Y coordinates.</div>

<h6 id="Return_value_7">Return value</h6>

<p>The <code>Point</code> object.</p>

<h3 id="subtract()">subtract()</h3>

<p>Subtracts another point from this one.</p>

<pre>Point subtract(
  x,
  y
);

Point subtract(
  Point
);
</pre>

<h6 id="Parameters_8">Parameters</h6>

<dl>
 <dt><code>x</code></dt>
 <dd>The X coordinate of the point to subtract from the current point.</dd>
 <dt><code>y</code></dt>
 <dd>The Y coordinate of the point to subtract from the current point.</dd>
</dl>

<div class="note"><strong>Note:</strong> You may specify another <code>Point</code> object instead of separate X and Y coordinates.</div>

<h6 id="Return_value_8">Return value</h6>

<p>The value of the <code>Point</code> object after subtracting the specified value; this isn't a new object, just the same one you called the function on.</p>

<h3 id="toString()">toString()</h3>

<p>Returns a string representation of the <code>Point</code> object.</p>

<pre>String toString();
</pre>

<h6 id="Parameters_9">Parameters</h6>

<p>None.</p>

<h6 id="Return_value_9">Return value</h6>

<p>A <a href="/en/JavaScript/Reference/Global_Objects/String" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String"><code>String</code></a> object representing the point, in "(<em>x</em>,<em>y</em>)" format.</p>