diff options
Diffstat (limited to 'st')
| -rw-r--r-- | st/x.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -1596,14 +1596,18 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x void chgalpha(const Arg *arg) { - if (arg->f == -1.0f && alpha >= 0.1f) - alpha -= 0.1f; - else if (arg->f == 1.0f && alpha < 1.0f) - alpha += 0.1f; - else if (arg->f == 0.0f) - alpha = alpha_def; - else - return; + if (arg->f == 0.0f) { + /* reset */ + alpha = alpha_def; + } else { + /* relative change: clamp to [0,1] */ + float newα = alpha + arg->f; + if (newα < 0.0f) + newα = 0.0f; + else if (newα > 1.0f) + newα = 1.0f; + alpha = newα; + } dc.col[defaultbg].color.alpha = (unsigned short)(0xFFFF * alpha); /* Required to remove artifacting from borderpx */ |
