소스 검색

LibGfx: Add Color::with_opacity(float opacity)

This returns the color with its alpha scaled by the opacity.
MacDue 2 년 전
부모
커밋
120e5b6b6f
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      Userland/Libraries/LibGfx/Color.h

+ 5 - 0
Userland/Libraries/LibGfx/Color.h

@@ -331,6 +331,11 @@ public:
             alpha());
             alpha());
     }
     }
 
 
+    constexpr Color with_opacity(float opacity) const
+    {
+        return with_alpha(alpha() * opacity);
+    }
+
     constexpr Color darkened(float amount = 0.5f) const
     constexpr Color darkened(float amount = 0.5f) const
     {
     {
         return Color(red() * amount, green() * amount, blue() * amount, alpha());
         return Color(red() * amount, green() * amount, blue() * amount, alpha());