mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Opacity filter on Android (#44454)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44454 tsia Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D56847475 fbshipit-source-id: bbd51e8c744914f1d2caf392996d20ab03b3fb6f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b0e746e4bb
commit
00f3867ac3
+17
-1
@@ -35,9 +35,10 @@ internal object FilterHelper {
|
||||
"grayscale" -> createGrayscaleEffect(amount, chainedEffects)
|
||||
"sepia" -> createSepiaEffect(amount, chainedEffects)
|
||||
"saturate" -> createSaturateEffect(amount, chainedEffects)
|
||||
"hue-rotate" -> createHueRotateEffect(amount, chainedEffects)
|
||||
"hueRotate" -> createHueRotateEffect(amount, chainedEffects)
|
||||
"invert" -> createInvertEffect(amount, chainedEffects)
|
||||
"blur" -> createBlurEffect(amount, chainedEffects)
|
||||
"opacity" -> createOpacityEffect(amount, chainedEffects)
|
||||
else -> throw IllegalArgumentException("Invalid filter name: $filterName")
|
||||
}
|
||||
}
|
||||
@@ -63,6 +64,7 @@ internal object FilterHelper {
|
||||
"saturate" -> createSaturateColorMatrix(amount)
|
||||
"hueRotate" -> createHueRotateColorMatrix(amount)
|
||||
"invert" -> createInvertColorMatrix(amount)
|
||||
"opacity" -> createOpacityColorMatrix(amount)
|
||||
else -> throw IllegalArgumentException("Invalid color matrix filter: $filterName")
|
||||
}
|
||||
|
||||
@@ -117,6 +119,20 @@ internal object FilterHelper {
|
||||
return matrix
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/filter-effects-1/#opacityEquivalent
|
||||
public fun createOpacityEffect(
|
||||
amount: Float,
|
||||
chainedEffects: RenderEffect? = null
|
||||
): RenderEffect {
|
||||
return createColorMatrixEffect(createOpacityColorMatrix(amount), chainedEffects)
|
||||
}
|
||||
|
||||
public fun createOpacityColorMatrix(amount: Float): ColorMatrix {
|
||||
val matrix = ColorMatrix()
|
||||
matrix.setScale(1f, 1f, 1f, amount)
|
||||
return matrix
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/filter-effects-1/#contrastEquivalent
|
||||
public fun createContrastEffect(
|
||||
amount: Float,
|
||||
|
||||
Reference in New Issue
Block a user