Update lens
This commit is contained in:
1 parent
a11b1f4c31
commit
e096ea868b
7 files changed
+11
-11
No files matched your search
@@ -12,9 +12,9 @@ import com.kyant.backdrop.RoundedRectRefractionWithDispersionShaderString
|
|||||||
|
|
||||||
fun BackdropEffectScope.lens(
|
fun BackdropEffectScope.lens(
|
||||||
refractionHeight: Float,
|
refractionHeight: Float,
|
||||||
refractionAmount: Float = refractionHeight,
|
refractionAmount: Float,
|
||||||
hasDepthEffect: Boolean = false,
|
chromaticAberration: Offset = Offset.Zero,
|
||||||
chromaticAberration: Offset = Offset.Zero
|
depthEffect: Boolean = false
|
||||||
) {
|
) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return
|
||||||
if (refractionHeight <= 0f || refractionAmount <= 0f) return
|
if (refractionHeight <= 0f || refractionAmount <= 0f) return
|
||||||
@@ -29,7 +29,7 @@ fun BackdropEffectScope.lens(
|
|||||||
setFloatUniform("cornerRadii", cornerRadii)
|
setFloatUniform("cornerRadii", cornerRadii)
|
||||||
setFloatUniform("refractionHeight", refractionHeight)
|
setFloatUniform("refractionHeight", refractionHeight)
|
||||||
setFloatUniform("refractionAmount", -refractionAmount)
|
setFloatUniform("refractionAmount", -refractionAmount)
|
||||||
setFloatUniform("depthEffect", if (hasDepthEffect) 1f else 0f)
|
setFloatUniform("depthEffect", if (depthEffect) 1f else 0f)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
obtainRuntimeShader(
|
obtainRuntimeShader(
|
||||||
@@ -40,7 +40,7 @@ fun BackdropEffectScope.lens(
|
|||||||
setFloatUniform("cornerRadii", cornerRadii)
|
setFloatUniform("cornerRadii", cornerRadii)
|
||||||
setFloatUniform("refractionHeight", refractionHeight)
|
setFloatUniform("refractionHeight", refractionHeight)
|
||||||
setFloatUniform("refractionAmount", -refractionAmount)
|
setFloatUniform("refractionAmount", -refractionAmount)
|
||||||
setFloatUniform("depthEffect", if (hasDepthEffect) 1f else 0f)
|
setFloatUniform("depthEffect", if (depthEffect) 1f else 0f)
|
||||||
setFloatUniform("chromaticAberration", chromaticAberration.x, chromaticAberration.y)
|
setFloatUniform("chromaticAberration", chromaticAberration.x, chromaticAberration.y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -115,7 +115,7 @@ fun AdaptiveLuminanceGlassContent() {
|
|||||||
if (l > 0f) lerp(8f.dp.toPx(), 16f.dp.toPx(), l)
|
if (l > 0f) lerp(8f.dp.toPx(), 16f.dp.toPx(), l)
|
||||||
else lerp(8f.dp.toPx(), 2f.dp.toPx(), -l)
|
else lerp(8f.dp.toPx(), 2f.dp.toPx(), -l)
|
||||||
)
|
)
|
||||||
lens(24f.dp.toPx(), size.minDimension / 2f, true)
|
lens(24f.dp.toPx(), size.minDimension / 2f, depthEffect = true)
|
||||||
},
|
},
|
||||||
layerBlock = {
|
layerBlock = {
|
||||||
val offset = offsetAnimation.value
|
val offset = offsetAnimation.value
|
||||||
|
|||||||
+1
-1
@@ -119,7 +119,7 @@ fun ControlCenterContent() {
|
|||||||
lens(
|
lens(
|
||||||
24f.dp.toPx() * progress,
|
24f.dp.toPx() * progress,
|
||||||
48f.dp.toPx() * progress,
|
48f.dp.toPx() * progress,
|
||||||
true
|
depthEffect = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ fun DialogContent() {
|
|||||||
saturation = 1.5f
|
saturation = 1.5f
|
||||||
)
|
)
|
||||||
blur(if (isLightTheme) 16f.dp.toPx() else 8f.dp.toPx())
|
blur(if (isLightTheme) 16f.dp.toPx() else 8f.dp.toPx())
|
||||||
lens(24f.dp.toPx(), 48f.dp.toPx(), true)
|
lens(24f.dp.toPx(), 48f.dp.toPx(), depthEffect = true)
|
||||||
},
|
},
|
||||||
onDrawSurface = { drawRect(containerColor) }
|
onDrawSurface = { drawRect(containerColor) }
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -74,7 +74,7 @@ fun GlassPlaygroundContent() {
|
|||||||
lens(
|
lens(
|
||||||
refractionHeight = refractionHeightFrac * minDimension * 0.5f,
|
refractionHeight = refractionHeightFrac * minDimension * 0.5f,
|
||||||
refractionAmount = refractionAmountFrac * minDimension,
|
refractionAmount = refractionAmountFrac * minDimension,
|
||||||
hasDepthEffect = true,
|
depthEffect = true,
|
||||||
chromaticAberration = Offset(chromaticAberration, chromaticAberration)
|
chromaticAberration = Offset(chromaticAberration, chromaticAberration)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ fun LockScreenContent() {
|
|||||||
effects = {
|
effects = {
|
||||||
vibrancy()
|
vibrancy()
|
||||||
blur(4f.dp.toPx())
|
blur(4f.dp.toPx())
|
||||||
lens(12f.dp.toPx(), 24f.dp.toPx(), true)
|
lens(12f.dp.toPx(), 24f.dp.toPx(), depthEffect = true)
|
||||||
},
|
},
|
||||||
onDrawSurface = { drawRect(Color.White.copy(0.1f)) },
|
onDrawSurface = { drawRect(Color.White.copy(0.1f)) },
|
||||||
contentEffects = {
|
contentEffects = {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ fun MagnifierContent() {
|
|||||||
lens(
|
lens(
|
||||||
8f.dp.toPx(),
|
8f.dp.toPx(),
|
||||||
24f.dp.toPx(),
|
24f.dp.toPx(),
|
||||||
hasDepthEffect = true,
|
depthEffect = true,
|
||||||
chromaticAberration = DefaultChromaticAberration
|
chromaticAberration = DefaultChromaticAberration
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user