mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 18:11:24 +01:00
fix: skip coastline out points wip
This commit is contained in:
parent
3215b6f0d2
commit
19d7f239c1
9 changed files with 262 additions and 64 deletions
|
|
@ -8,6 +8,27 @@ export function unique<T>(array: T[]) {
|
|||
return [...new Set(array)];
|
||||
}
|
||||
|
||||
export function sliceFragment<T>(array: T[], index: number, zone: number) {
|
||||
if (zone + 1 + zone >= array.length) {
|
||||
return array.slice();
|
||||
}
|
||||
|
||||
const start = index - zone;
|
||||
const end = index + zone;
|
||||
|
||||
if (start < 0) {
|
||||
return array.slice(0, end).concat(array.slice(start));
|
||||
}
|
||||
|
||||
if (end >= array.length) {
|
||||
return array.slice(start).concat(array.slice(0, end % array.length));
|
||||
}
|
||||
|
||||
return array.slice(start, end);
|
||||
}
|
||||
|
||||
window.sliceFragment = sliceFragment;
|
||||
|
||||
interface ICreateTypesArrayLength {
|
||||
maxValue: number;
|
||||
length: number;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue