Skip to content

editor / cyclicItem

Function: cyclicItem() ​

cyclicItem<T>(items, index, fallback): T

Defined in: geometry/cyclic-item.ts:15

Item of a cyclic list at any integer index: indices are taken modulo the list length (Q11).

Index −1 is the last item, index n the first one. The index is reduced with a non-negative modulo, ((i mod n) + n) mod n, not with the sign-keeping % of JavaScript alone (ADR-0025).

Type Parameters ​

T ​

T

type of the items: a vertex, or a value per vertex

Parameters ​

items ​

readonly T[]

vertices of a contour, or one value per vertex, in drawing order

index ​

number

position, wrapped around the list

fallback ​

T

value returned when the list is empty

Returns ​

T

the item at index mod n, or fallback for an empty list

Kind ​

geometry

See ​

DERIV-turning-angle