import { vec2 , vec3 , vec4 } from 'gl-matrix' ; import { clamp , clamp2 , clamp3 , clamp4 } from './gl-matrix-extensions' ; import { assert , logIf , LogLevel } from './auxiliaries' ; namespace tuples { /**
     * Auxiliary 2-tuple of GLsizei values.
     */ export type GLsizei2 = [ GLsizei , GLsizei ] ; /**
     * Auxiliary 3-tuple of GLsizei values.
     */ export type GLsizei3 = [ GLsizei , GLsizei , GLsizei ] ; /**
     * Auxiliary 4-tuple of GLsizei values.
     */ export type GLsizei4 = [ GLsizei , GLsizei , GLsizei , GLsizei ] ; /**
     * Auxiliary 2-tuple of GLfloat values.
     */ export type GLfloat2 = [ GLfloat , GLfloat ] ; /**
     * Auxiliary 3-tuple of GLfloat values.
     */ export type GLfloat3 = [ GLfloat , GLfloat , GLfloat ] ; /**
     * Auxiliary 4-tuple of GLfloat values.
     */ export type GLfloat4 = [ GLfloat , GLfloat , GLfloat , GLfloat ] ; /**
     * Auxiliary 3-tuple of GLclampf values.
     */ export type GLclampf2 = [ GLclampf , GLclampf ] ; /**
     * Auxiliary 3-tuple of GLclampf values.
     */ export type GLclampf3 = [ GLclampf , GLclampf , GLclampf ] ; /**
     * Auxiliary 4-tuple of GLclampf values.
     */ export type GLclampf4 = [ GLclampf , GLclampf , GLclampf , GLclampf ] ; /**
     * Auxiliary 5-tuple of GLclampf values.
     */ export type GLclampf5 = [ GLclampf , GLclampf , GLclampf , GLclampf , GLclampf ] ; param buffer returns export function tuple2 < T extends GLsizei | GLclampf | GLfloat > ( buffer ) { assert ( buffer . length === 2 , `expected length of buffer to be 2, given ${ buffer . length }` ) ; return [ buffer [ 0 ] as T , buffer [ 1 ] as T ] ; } param buffer returns export function tuple3 < T extends GLsizei | GLclampf | GLfloat > ( buffer ) { assert ( buffer . length === 3 , `expected length of buffer to be 3, given ${ buffer . length }` ) ; return [ buffer [ 0 ] as T , buffer [ 1 ] as T , buffer [ 2 ] as T ] ; } param buffer returns export function tuple4 < T extends GLsizei | GLclampf | GLfloat > ( buffer ) { assert ( buffer . length === 4 , `expected length of buffer to be 4, given ${ buffer . length }` ) ; return [ buffer [ 0 ] as T , buffer [ 1 ] as T , buffer [ 2 ] as T , buffer [ 3 ] as T ] ; } param value param semantic returns export function clampf ( value , semantic ? ) { const valueV1 = clamp ( value , 0.0 , 1.0 ) ; logIf ( semantic !== undefined && value < 0.0 || value > 1.0 , LogLevel . Info , `${ semantic } clamped to [${ valueV1 }], given [${ value }]` ) ; return valueV1 ; } param tuple param semantic returns export function clampf2 ( tuple , semantic ? ) { const tupleV2 = vec2 . fromValues ( tuple [ 0 ] , tuple [ 1 ] ) ; if ( tuple [ 0 ] < 0.0 || tuple [ 0 ] > 1.0 || tuple [ 1 ] < 0.0 || tuple [ 1 ] > 1.0 ) { clamp2 ( tupleV2 , tupleV2 , vec2 . fromValues ( 0.0 , 0.0 ) , vec2 . fromValues ( 1.0 , 1.0 ) ) ; logIf ( semantic !== undefined , LogLevel . Info , `${ semantic } clamped to [${ tupleV2 }], given [${ tuple }]` ) ; } return tuple2 < typeof tuple [ 0 ] > ( tupleV2 ) ; } param tuple param semantic returns export function clampf3 ( tuple , semantic ? ) { const tupleV3 = vec3 . fromValues ( tuple [ 0 ] , tuple [ 1 ] , tuple [ 2 ] ) ; if ( tuple [ 0 ] < 0.0 || tuple [ 0 ] > 1.0 || tuple [ 1 ] < 0.0 || tuple [ 1 ] > 1.0 || tuple [ 2 ] < 0.0 || tuple [ 2 ] > 1.0 ) { clamp3 ( tupleV3 , tupleV3 , vec3 . fromValues ( 0.0 , 0.0 , 0.0 ) , vec3 . fromValues ( 1.0 , 1.0 , 1.0 ) ) ; logIf ( semantic !== undefined , LogLevel . Info , `${ semantic } clamped to [${ tupleV3 }], given [${ tuple }]` ) ; } return tuple3 < typeof tuple [ 0 ] > ( tupleV3 ) ; } param tuple param semantic returns export function clampf4 ( tuple , semantic ? ) { const tupleV4 = vec4 . fromValues ( tuple [ 0 ] , tuple [ 1 ] , tuple [ 2 ] , tuple [ 3 ] ) ; if ( tuple [ 0 ] < 0.0 || tuple [ 0 ] > 1.0 || tuple [ 1 ] < 0.0 || tuple [ 1 ] > 1.0 || tuple [ 2 ] < 0.0 || tuple [ 2 ] > 1.0 || tuple [ 3 ] < 0.0 || tuple [ 3 ] > 1.0 ) { clamp4 ( tupleV4 , tupleV4 , vec4 . fromValues ( 0.0 , 0.0 , 0.0 , 0.0 ) , vec4 . fromValues ( 1.0 , 1.0 , 1.0 , 1.0 ) ) ; logIf ( semantic !== undefined , LogLevel . Info , `${ semantic } clamped to [${ tupleV4 }], given [${ tuple }]` ) ; } return tuple4 < typeof tuple [ 0 ] > ( tupleV4 ) ; } param tuple export function duplicate2 < T extends GLclampf | GLfloat | GLsizei > ( tuple ) { return [ tuple [ 0 ] , tuple [ 1 ] ] ; } param tuple export function duplicate3 < T extends GLclampf | GLfloat | GLsizei > ( tuple ) { return [ tuple [ 0 ] , tuple [ 1 ] , tuple [ 2 ] ] ; } param tuple export function duplicate4 < T extends GLclampf | GLfloat | GLsizei > ( tuple ) { return [ tuple [ 0 ] , tuple [ 1 ] , tuple [ 2 ] , tuple [ 3 ] ] ; } param tuple0 param tuple1 returns export function equals2 < T extends GLclampf | GLfloat | GLsizei > ( t0 , t1 ) { return t0 [ 0 ] === t1 [ 0 ] && t0 [ 1 ] === t1 [ 1 ] ; } param tuple0 param tuple1 returns export function equals3 < T extends GLclampf | GLfloat | GLsizei > ( t0 , t1 ) { return t0 [ 0 ] === t1 [ 0 ] && t0 [ 1 ] === t1 [ 1 ] && t0 [ 2 ] === t1 [ 2 ] ; } param tuple0 param tuple1 returns export function equals4 < T extends GLclampf | GLfloat | GLsizei > ( t0 , t1 ) { return t0 [ 0 ] === t1 [ 0 ] && t0 [ 1 ] === t1 [ 1 ] && t0 [ 2 ] === t1 [ 2 ] && t0 [ 3 ] === t1 [ 3 ] ; } } export = tuples ;