## triTile (`lygia`/`space`/`triTile`)

make some triangular tiles. XY provide coords inside of the tile. ZW provides tile coords

Use:

``````<vec4> triTile(<vec2> st [, <float> scale])
``````

Check it on Github

``````
#ifndef FNC_TRITILE
#define FNC_TRITILE
vec4 triTile(vec2 st) {
st *= mat2(1., -1. / 1.7320508, 0., 2. / 1.7320508);
vec4 f = vec4(st, -st);
vec4 i = floor(f);
f = fract(f);
return dot(f.xy, f.xy) < dot(f.zw, f.zw)
? vec4(f.xy, vec2(2., 1.) * i.xy)
: vec4(f.zw, -(vec2(2., 1.) * i.zw + 1.));
}

vec4 triTile(vec2 st, float scale) { return triTile(st * scale); }
#endif

``````

Use:

``````<float4> triTile(<float2> st [, <float> scale])
``````

Check it on Github

``````
#ifndef FNC_TRITILE
#define FNC_TRITILE
float4 triTile(float2 st) {
st = mult(float2x2( 1.0, -1.0 / 1.7320508,
0.0, 2.0 / 1.7320508), st);
float4 f = float4(st, -st);
float4 i = floor(f);
f = frac(f);
return dot(f.xy, f.xy) < dot(f.zw, f.zw)
? float4(f.xy, float2(2., 1.) * i.xy)
: float4(f.zw, -(float2(2., 1.) * i.zw + 1.));
}

float4 triTile(float2 st, float scale) { return triTile(st * scale); }
#endif

``````