feat: wallpaper cropper sdf shader rectangle, better confirmation controls + hide passive tray icons
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#version 440
|
||||
layout(location = 0) in vec2 qt_TexCoord0;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform buf {
|
||||
mat4 qt_Matrix;
|
||||
float qt_Opacity;
|
||||
vec2 itemSize;
|
||||
vec4 cropBox;
|
||||
vec4 borderColor;
|
||||
float cornerRadius;
|
||||
float borderWidth;
|
||||
float pixelScale;
|
||||
};
|
||||
|
||||
float sdRoundBox(vec2 p, vec2 halfSize, float r) {
|
||||
vec2 q = abs(p) - halfSize + r;
|
||||
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 sz = itemSize * pixelScale;
|
||||
vec2 p = qt_TexCoord0 * sz;
|
||||
vec4 box = cropBox * pixelScale;
|
||||
float r = cornerRadius * pixelScale;
|
||||
float bw = borderWidth * pixelScale;
|
||||
|
||||
float dImage = sdRoundBox(p - sz * 0.5, sz * 0.5, r);
|
||||
float dCrop = sdRoundBox(p - (box.xy + box.zw * 0.5), box.zw * 0.5, 0.0);
|
||||
|
||||
float d = max(dImage, dCrop);
|
||||
|
||||
// ramp is exactly 1 physical pixel wide
|
||||
float outer = clamp(0.5 - d, 0.0, 1.0);
|
||||
float inner = clamp(0.5 - (d + bw), 0.0, 1.0);
|
||||
float a = outer - inner;
|
||||
|
||||
fragColor = vec4(borderColor.rgb, 1.0) * (borderColor.a * a * qt_Opacity);
|
||||
}
|
||||
Reference in New Issue
Block a user