Kotlin Multi-platform Color Support. This allows using Colors in multi-platform code. Compatible with Jetpack
Compose/Multi-platform. Serialization and Palette Generation Support.
val white = Color("#FFFFFF")
val black = Color(red = 0, green = 0, blue = 0)
println("White: colorLong = ${white.colorLong}; cssValue = ${white.cssValue}")
println("Black: colorLong = ${black.colorLong}; cssValue = ${black.cssValue}")
To obtain a Color
instance, use one of the constructor functions:
Color("#FFFFFF")
Color(255, 255, 255, 255)
Color(0xFFFFFFFF)
// Or to obtain a specific Color type, like RgbaColor
RgbaColor(255, 255, 255, 255)
Using properties from the Color
interface:
// sRGB Color Int
color.colorInt
// Color components and ColorSpace encoded into a Long
color.colorLong
// CSS Value
color.cssValue
// ColorSpace
color.colorSpace
// Alpha value
color.alpha
// Specific Color components
color.component1()
// All Color Components - Example for an RGBA Color
val (red, green, blue, alpha) = color
// Color Components as a FloatArray
color.components
The library is provided through Repsy.io. Checkout the
releases page to get the latest version.
repositories {
maven { url = uri("https://repo.repsy.io/mvn/chrynan/public") }
}
implementation("com.chrynan.colors:colors-core:$VERSION")
implementation("com.chrynan.colors:colors-extension:$VERSION")
implementation("com.chrynan.colors:colors-theme:$VERSION")
implementation("com.chrynan.colors:colors-palette:$VERSION")
implementation("com.chrynan.colors:colors-compose:$VERSION")
implementation("com.chrynan.colors:colors-compose-web:$VERSION")
More detailed documentation is available in the docs folder. The entry point to the documentation can be found here.
Checkout the Android Sample Project for an example of using the library.
Copyright 2021 chRyNaN
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
http://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.