summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-11-26 19:37:20 +0000
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-11-26 19:37:20 +0000
commitafe688e6ab3e021feca8c398d31469109a32a41b (patch)
tree862af1e38a9131675f92eee160752f097e495c85 /src/render
parent493fc009533b5d5b94c5d11d32bcd730094e5669 (diff)
allow 360 degrees of freedom in gradients
Diffstat (limited to 'src/render')
-rw-r--r--src/render/OpenGL.cpp2
-rw-r--r--src/render/shaders/Border.hpp19
2 files changed, 19 insertions, 2 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index 5a4ccca6..2d9f9314 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -852,7 +852,7 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad,
glUniform4fv(m_RenderData.pCurrentMonData->m_shBORDER1.gradient, grad.m_vColors.size(), (float*)grad.m_vColors.data());
glUniform1i(m_RenderData.pCurrentMonData->m_shBORDER1.gradientLength, grad.m_vColors.size());
- glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.angle, grad.m_fAngle);
+ glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.angle, (int)(grad.m_fAngle / (PI / 180.0)) % 360 * (PI / 180.0));
glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.alpha, a);
wlr_box transformedBox;
diff --git a/src/render/shaders/Border.hpp b/src/render/shaders/Border.hpp
index fc48e108..c2be9880 100644
--- a/src/render/shaders/Border.hpp
+++ b/src/render/shaders/Border.hpp
@@ -23,7 +23,24 @@ vec4 getColorForCoord(vec2 normalizedCoord) {
if (gradientLength < 2)
return gradient[0];
- float sine = sin(angle);
+ float finalAng = 0.0;
+
+ if (angle > 4.71 /* 270 deg */) {
+ normalizedCoord[1] = 1.0 - normalizedCoord[1];
+ finalAng = 6.28 - angle;
+ } else if (angle > 3.14 /* 180 deg */) {
+ normalizedCoord[0] = 1.0 - normalizedCoord[0];
+ normalizedCoord[1] = 1.0 - normalizedCoord[1];
+ finalAng = angle - 3.14;
+ } else if (angle > 1.57 /* 90 deg */) {
+ normalizedCoord[0] = 1.0 - normalizedCoord[0];
+ finalAng = 3.14 - angle;
+ } else {
+ finalAng = angle;
+ }
+
+ float sine = sin(finalAng);
+
float progress = (normalizedCoord[1] * sine + normalizedCoord[0] * (1.0 - sine)) * float(gradientLength - 1);
int bottom = int(floor(progress));
int top = bottom + 1;