Class

PointLight

A light that radiates equally in every direction from a single point in front of the surface, like a bare bulb.

IlluminateSample

@Sampled
@Composable
fun IlluminateSample() {
    // Since our light color is white, we set a darker background so that its visible.
    val backgroundColor = remember { Color.Black }
    val surfaceShape = remember { RoundedCornerShape(24.dp) }
    Box(
        Modifier.size(160.dp)
            .background(backgroundColor)
            .illuminate(
                lights =
                    listOf(
                        PointLight(
                            color = Color.White,
                            // Above the top-left corner of the lit composable.
                            position = LightPosition.Local(DpOffset(x = 0.dp, y = 0.dp)),
                            elevation = 48.dp,
                            falloffRadius = 320.dp,
                            intensity = 1f,
                        )
                    ),
                surfaceMaterial =
                    SurfaceMaterial.diffuse(Color.White).specular(Color.White, shininess = 32f),
                surfaceGeometrySpec =
                    SurfaceGeometrySpec.convex(
                        shape = surfaceShape,
                        thickness = 1.dp,
                        bevelWidth = 12.dp,
                    ),
            )
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: