lygia
/space
/sprite
)returns a coordinate of a sprite cell
Use:
<vec2> sprite(<vec2> st, <vec2> grid, <float> index)
#ifndef FNC_SPRITE
#define FNC_SPRITE
vec2 sprite(vec2 st, vec2 grid, float index) {
index += grid.x;
vec2 f = 1.0/grid;
vec2 cell = vec2(floor(index), grid.y - floor(index * f.x) );
// cell.y = grid.y - cell.y;
return fract( (st+cell)*f );
}
#endif
Use:
<float2> sprite(<float2> st, <float2> grid, <float> index)
#ifndef FNC_SPRITE
#define FNC_SPRITE
float2 sprite(float2 st, float2 grid, float index) {
float2 f = 1.0/grid;
float2 cell = float2(floor(index), floor(index * f.x) );
cell.y = grid.y - cell.y;
return frac( (st+cell)*f );
}
#endif
Use:
<float2> sprite(<float2> st, <float2> grid, <float> index)
#ifndef FNC_SPRITE
#define FNC_SPRITE
float2 sprite(float2 st, float2 grid, float index) {
index += grid.x;
float2 f = 1.0/grid;
float2 cell = float2(floor(index), grid.y - floor(index * f.x) );
// cell.y = grid.y - cell.y;
return fract( (st+cell)*f );
}
#endif
Use:
<vec2f> sprite(<vec2f> st, <vec2f> grid, <f32> index)
fn sprite(st: vec2f, grid: vec2f, index: f32) -> vec2f {
let i = index + grid.x;
let f = 1.0 / grid;
let cell = vec2f(floor(i), grid.y - floor(i * f.x));
// cell.y = grid.y - cell.y;
return fract((st + cell) * f);
}
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository