
Animated, customizable shader backgrounds via a simple modifier; ships with mesh gradient, glossy and lens shaders, supports texture uniforms and custom shader implementations.
A fork of https://github.com/mikepenz/HypnoticCanvas with removed fluff and updates to support the newer Compose Skia API.
Add the library as a dependency to your Kotlin Multiplatform project. Replace VERSION with the desired release (click the badge above to see the latest).
hypnoticcanvas = { module = "dev.brahmkshatriya.hypnoticcanvas:lib", version = "VERSION" }The library provides a shaderBackground modifier. Use it.
import com.mikepenz.hypnoticcanvas.shaderBackground
import com.mikepenz.hypnoticcanvas.shaders.GlossyGradients
//...
Box(Modifier.fillMaxSize().shaderBackground(GlossyGradients))You can also take a look at the examples module for more examples.
Custom shaders can be created by implementing the Shader interface.
Texture-style uniforms are supported too. In AGSL/SkSL, declare them as uniform shader and sample them with .eval(...).
override fun applyUniforms(runtimeEffect: RuntimeEffect, time: Float, width: Float, height: Float) {
super.applyUniforms(runtimeEffect, time, width, height)
runtimeEffect.setShaderUniform("uWaveform", ImageShader(waveformBitmap))
}Example shaders included in the library are:
A fork of https://github.com/mikepenz/HypnoticCanvas with removed fluff and updates to support the newer Compose Skia API.
Add the library as a dependency to your Kotlin Multiplatform project. Replace VERSION with the desired release (click the badge above to see the latest).
hypnoticcanvas = { module = "dev.brahmkshatriya.hypnoticcanvas:lib", version = "VERSION" }The library provides a shaderBackground modifier. Use it.
import com.mikepenz.hypnoticcanvas.shaderBackground
import com.mikepenz.hypnoticcanvas.shaders.GlossyGradients
//...
Box(Modifier.fillMaxSize().shaderBackground(GlossyGradients))You can also take a look at the examples module for more examples.
Custom shaders can be created by implementing the Shader interface.
Texture-style uniforms are supported too. In AGSL/SkSL, declare them as uniform shader and sample them with .eval(...).
override fun applyUniforms(runtimeEffect: RuntimeEffect, time: Float, width: Float, height: Float) {
super.applyUniforms(runtimeEffect, time, width, height)
runtimeEffect.setShaderUniform("uWaveform", ImageShader(waveformBitmap))
}Example shaders included in the library are: