Build apps faster with our new App builder! Check it out →

HypnoticCanvas

Android
⚖️ License Apache License 2.0
Added on 11/23/2024

Maven Central

HypnoticCanvas

[!NOTE]
This README is under construction.

HypnoticCanvas is a library providing a convenient Modifier offering mesmerising shaders as background in your Compose based UI.

https://github.com/mikepenz/HypnoticCanvas/assets/1476232/ee120f1c-d18a-43c4-a7bc-a2d245e01482

Setup

Core-module

implementation "com.mikepenz.hypnoticcanvas:hypnoticcanvas:${version}"

[!NOTE]
All shaders provided in the core module are licensed either under MIT or Apache 2.0 license.

Shader-module

implementation "com.mikepenz.hypnoticcanvas:hypnoticcanvas-shaders:${version}"

[!IMPORTANT]
Shaders in this module have non permissive licenses. Ensure to read the LICENSE section of the README.

Usage

Box(
    modifier = Modifier
        .fillMaxSize()
        .shaderBackground(BlackCherryCosmos)
)

// Usage of Shader with configurations
Box(
    modifier = Modifier
        .fillMaxSize()
        .shaderBackground(
            MeshGradient(
                arrayOf(Color(0xFFFF15E5), Color(0xFFFAAEF7), Color(0xFF6903F9)),
                scale = 1f
            )
        )
)

Compatiblity

HypnoticCanvas is built with Compose Multiplatform, meaning that it supports different platforms:

PlatformSupportedLink
Android
Desktop (JVM)
iOS
WasmSample

Build & Run Sample App

Run Desktop App

./gradlew sample:run

Run Web App

./gradlew sample:wasmJsRun

Update aboutLibraries.json

 ./gradlew sample:exportLibraryDefinitions -PaboutLibraries.exportPath=src/commonMain/composeResources/files/

Credit

The base project setup is strongly based on the haze project by Chris Banes, Licensed under Apache License 2.0

The individual shaders are based on the respective shaders licenses. More details below.

Shaders core-module

NameAuthorLicenseNote
MeshGradientMike PenzMIT License
MesmerizingLensMike PenzMIT License
GlossyGradientsGiorgi AzmaipharashviliMIT LicenseRights bought for this shader on Fiverr, included in this project under MIT.

Shaders shaders-module

NameAuthorLicenseNote
BlackCherryCosmos2 via viaaxiomcruxCC BY-NC-SA 3.0 DEEDShader does not specifically include license, however found the shader it appears to be based on.
GoldenMagmaTAKUSAKUCC BY-NC-SA 3.0 DEED
IceReflectionTAKUSAKUCC BY-NC-SA 3.0 DEED
InkFlowTAKUSAKUCC BY-NC-SA 3.0 DEED
OilFlowTAKUSAKUCC BY-NC-SA 3.0 DEED
PurpleLiquidfouadCC BY-NC-SA 3.0 DEED
RainbowWaterflyloCC BY-NC-SA 3.0 DEED
StageTAKUSAKUCC BY-NC-SA 3.0 DEED

License

The core project code in this repository is licensed as under Apache 2.0. SPDX-License-Identifier: Apache-2.0.

All Shaders are provided under their respective Authors license.

Shaders in the hypnoticcanvas module are licensed either as MIT, or Apache 2.0. Shaders in the hypnoticcanvas-shaders module are licensed as SPDX-License-Identifier: CC-BY-NC-SA-3.0.

Core module License

The source code for the core module is licensed under Apache 2.0, with the shaders provided in the core module as MIT License.

Copyright 2024 Mike Penz
 
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Shaders module License

Shaders in this module are most from ShaderToy.com and are licensed Attribution-NonCommercial-ShareAlike 3.0 Unported. Which is the default license as outlined by ShaderToy.com