mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
Add clamped to option background_image_layout
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#define tex_right 1
|
||||
#define tex_bottom 1
|
||||
|
||||
uniform float tiled;
|
||||
uniform float unscaled;
|
||||
uniform vec2 translate; // [ left, top ]
|
||||
uniform vec4 sizes; // [ window_width, window_height, image_width, image_height ]
|
||||
|
||||
@@ -28,16 +28,12 @@ const vec2 tex_map[] = vec2[4](
|
||||
);
|
||||
|
||||
|
||||
float scale_factor(float window, float image) {
|
||||
return window / image;
|
||||
}
|
||||
|
||||
float tiling_factor(int i) {
|
||||
return tiled * scale_factor(sizes[i], sizes[i + 2]) + (1 - tiled);
|
||||
float unscaling_factor(int i) {
|
||||
return unscaled * (sizes[i] / sizes[i + 2]) + (1 - unscaled);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 tex_coords = tex_map[gl_VertexID];
|
||||
texcoord = vec2(tex_coords[0] * tiling_factor(0) - translate[0], tex_coords[1] * tiling_factor(1) - translate[1]);
|
||||
texcoord = vec2(tex_coords[0] * unscaling_factor(0) - translate[0], tex_coords[1] * unscaling_factor(1) - translate[1]);
|
||||
gl_Position = vec4(pos_map[gl_VertexID], 0, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user