RandomCoordinateGenerator.ts 458 B

123456789101112
  1. class RandomCoordinateGenerator {
  2. private definedCoordinates = [];
  3. public generate (minX : number, maxX : number, minY : number, maxY : number) {
  4. let coordinates : Array<number>;
  5. do {
  6. coordinates = [randomRange(minX, maxX), randomRange(minY, maxY)];
  7. } while (this.definedCoordinates.includes(coordinates.join(";")));
  8. this.definedCoordinates.push(coordinates.join(";"));
  9. return coordinates;
  10. }
  11. }