File tree 1 file changed +8
-0
lines changed
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { Point } from "./point.class" ;
2
2
import { Region } from "./region.class" ;
3
3
4
+ /**
5
+ * {@link centerOf } returns the center {@link Point } for a given {@link Region }
6
+ * @param target {@link Region } to determine the center {@link Point} for
7
+ */
4
8
export const centerOf = async ( target : Region | Promise < Region > ) : Promise < Point > => {
5
9
const targetRegion = await target ;
6
10
const x = Math . floor ( targetRegion . left + targetRegion . width / 2 ) ;
@@ -9,6 +13,10 @@ export const centerOf = async (target: Region | Promise<Region>): Promise<Point>
9
13
return new Point ( x , y ) ;
10
14
} ;
11
15
16
+ /**
17
+ * {@link randomPointIn } returns a random {@link Point } within a given {@link Region }
18
+ * @param target {@link Region } the random {@link Point} has to be within
19
+ */
12
20
export const randomPointIn = async ( target : Region | Promise < Region > ) : Promise < Point > => {
13
21
const targetRegion = await target ;
14
22
const x = Math . floor ( targetRegion . left + Math . random ( ) * targetRegion . width ) ;
You can’t perform that action at this time.
0 commit comments