lygia
/space
/scale
)scale a 2D space variable
Use:
scale(<vec2> st, <vec2|float> scale_factor [, <vec2> center])
#ifndef FNC_SCALE
#define FNC_SCALE
vec2 scale(in float st, in float s, in vec2 center) { return (st - center) * s + center; }
vec2 scale(in float st, in float s) {
#ifdef CENTER_2D
return scale(st, s, CENTER_2D);
#else
return scale(st, s, vec2(0.5));
#endif
}
vec2 scale(in vec2 st, in vec2 s, in vec2 center) { return (st - center) * s + center; }
vec2 scale(in vec2 st, in float s, in vec2 center) { return scale(st, vec2(s), center); }
vec2 scale(in vec2 st, in vec2 s) {
#ifdef CENTER_2D
return (st - CENTER_2D) * s + CENTER_2D;
#else
return (st - 0.5) * s + 0.5;
#endif
}
vec2 scale(in vec2 st, in float s) {
#ifdef CENTER_2D
return (st - CENTER_2D) * s + CENTER_2D;
#else
return (st - 0.5) * s + 0.5;
#endif
}
vec3 scale(in vec3 st, in vec3 s, in vec3 center) { return (st - center) * s + center; }
vec3 scale(in vec3 st, in float s, in vec3 center) { return (st - center) * s + center; }
vec3 scale(in vec3 st, in vec3 s) {
#ifdef CENTER_3D
return (st - CENTER_3D) * s + CENTER_3D;
#else
return (st - 0.5) * s + 0.5;
#endif
}
vec3 scale(in vec3 st, in float s) {
#ifdef CENTER_3D
return (st - CENTER_3D) * s + CENTER_3D;
#else
return (st - 0.5) * s + 0.5;
#endif
}
// For tiles
vec4 scale(in vec4 st, float s) { return vec4(scale(st.xy, s), st.zw); }
vec4 scale(in vec4 st, vec2 s) { return vec4(scale(st.xy, s), st.zw); }
#endif
Use:
scale(<float2> st, <float2|float> scale_factor [, <float2> center])
#ifndef FNC_SCALE
#define FNC_SCALE
float scale(in float st, in float s, in float center) {
return (st - center) * s + center;
}
float scale(in float st, in float s) {
#ifdef CENTER_2D
return scale(st, s, CENTER);
#else
return scale(st, s, .5);
#endif
}
float2 scale(in float2 st, in float2 s, in float2 center) {
return (st - center) * s + center;
}
float2 scale(in float2 st, in float value, in float2 center) {
return scale(st, float2(value, value), center);
}
float2 scale(in float2 st, in float2 s) {
#ifdef CENTER_2D
return scale(st, s, CENTER_2D);
#else
return scale(st, s, float2(.5, .5));
#endif
}
float2 scale(in float2 st, in float value) {
return scale(st, float2(value, value));
}
float3 scale(in float3 st, in float3 s, in float3 center) {
return (st - center) * s + center;
}
float3 scale(in float3 st, in float value, in float3 center) {
return scale(st, float3(value, value, value), center);
}
float3 scale(in float3 st, in float3 s) {
#ifdef CENTER_3D
return scale(st, s, CENTER_3D);
#else
return scale(st, s, float3(.5, .5, .5));
#endif
}
float3 scale(in float3 st, in float value) {
return scale(st, float3(value, value, value));
}
#endif
Use:
scale(<float2> st, <float2|float> scale_factor [, <float2> center])
#ifndef FNC_SCALE
#define FNC_SCALE
float2 scale(float st, float s, float2 center) { return (st - center) * s + center; }
float2 scale(float st, float s) {
#ifdef CENTER_2D
return scale(st, s, CENTER_2D);
#else
return scale(st, s, float2(0.5));
#endif
}
float2 scale(float2 st, float2 s, float2 center) { return (st - center) * s + center; }
float2 scale(float2 st, float s, float2 center) { return scale(st, float2(s), center); }
float2 scale(float2 st, float2 s) {
#ifdef CENTER_2D
return (st - CENTER_2D) * s + CENTER_2D;
#else
return (st - 0.5) * s + 0.5;
#endif
}
float2 scale(float2 st, float s) {
#ifdef CENTER_2D
return (st - CENTER_2D) * s + CENTER_2D;
#else
return (st - 0.5) * s + 0.5;
#endif
}
float3 scale(float3 st, float3 s, float3 center) { return (st - center) * s + center; }
float3 scale(float3 st, float s, float3 center) { return (st - center) * s + center; }
float3 scale(float3 st, float3 s) {
#ifdef CENTER_3D
return (st - CENTER_3D) * s + CENTER_3D;
#else
return (st - 0.5) * s + 0.5;
#endif
}
float3 scale(float3 st, float s) {
#ifdef CENTER_3D
return (st - CENTER_3D) * s + CENTER_3D;
#else
return (st - 0.5) * s + 0.5;
#endif
}
// For tiles
float4 scale(float4 st, float s) { return float4(scale(st.xy, s), st.zw); }
float4 scale(float4 st, float2 s) { return float4(scale(st.xy, s), st.zw); }
#endif
fn scale(st: vec2f, s: vec2f) -> vec2f {
return (st - 0.5) * s + 0.5;
}
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