Skip to content

Commit ddc676b

Browse files
committed
(#87) Location API docs
1 parent 49bfa6d commit ddc676b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: lib/location.function.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { Point } from "./point.class";
22
import { Region } from "./region.class";
33

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+
*/
48
export const centerOf = async (target: Region | Promise<Region>): Promise<Point> => {
59
const targetRegion = await target;
610
const x = Math.floor(targetRegion.left + targetRegion.width / 2);
@@ -9,6 +13,10 @@ export const centerOf = async (target: Region | Promise<Region>): Promise<Point>
913
return new Point(x, y);
1014
};
1115

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+
*/
1220
export const randomPointIn = async (target: Region | Promise<Region>): Promise<Point> => {
1321
const targetRegion = await target;
1422
const x = Math.floor(targetRegion.left + Math.random() * targetRegion.width);

0 commit comments

Comments
 (0)