๐ŸŽจ A tiny (Kotlin) library for generating attractive colors

Overview

RandomKolor

๐ŸŽจ A tiny (Kotlin) library for generating attractive colors

Inspired by David Merfield's randomColor.js. You can use the library to generate attractive random colors on Android apps.

This project comes with a sample app which demonstrates some of the functionality:

Installation

The library is hosted on JitPack

  1. Add it in your root build.gradle at the end of repositories:
allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
  1. Add the dependency
dependencies {
    implementation 'com.github.brian-norman:RandomKolor:1.0'
}

Options

  • hue โ€“ Controls the hue of the generated color. You can pass in a color: Color.RED, Color.ORANGE, Color.YELLOW, Color.Green, Color.BLUE, Color.Purple, Color.PINK and Color.MONOCHROME are currently supported.
  • luminosity โ€“ Controls the luminosity of the generated color. Library supports: Luminosity.RANDOM, Luminosity.BRIGHT, Luminosity.LIGHT, Luminosity.DARK
  • count โ€“ An integer which specifies the number of colors to generate.

API

fun randomColor(hue: Hue = RandomHue, luminosity: Luminosity = Luminosity.RANDOM, format: Format = Format.RGB): String
fun randomColors(count: Int, hue: Hue = RandomHue, luminosity: Luminosity = Luminosity.RANDOM, format: Format = Format.RGB): List<String>

Examples

// Generate an attractive RGB randomly
val rgbString = RandomKolor().randomColor()
// Generate a light blue RGB 
val rgbString = RandomKolor().randomColor(hue = ColorHue(BLUE), luminosity = Luminosity.LIGHT)
// Generate three light blue oranges
val rgbStrings = RandomKolor().randomColors(count = 3, hue = ColorHue(ORANGE), luminosity = Luminosity.LIGHT)

Acknowledgements

TODO

  • Currently only RGB is supported, would like to support other formats
  • Add alpha to RGB
You might also like...
Utility library that extends Jetpack Compose Colors with Material Design2 colors, Color swatches like in Flutter
Utility library that extends Jetpack Compose Colors with Material Design2 colors, Color swatches like in Flutter

๐Ÿš€๐ŸŒˆโ™พ Utility library that expands Compose Colors with Material Design2 colors, color swatches, Material Design 3 Tonal Palettes, color names, and utility functions to convert between HSL, HSV, RGB, HCT models and to HEX or from HEX

A list of most useful resources for designing android apps such as all material colors and dimens, 180 Gradient background + html, social, flat, fluent, metro colors.

Timer UI Login UI Fitness UI Material-Resources-Library A list of most useful resources for designing android apps such as all material colors and dim

Android Library to rapidly develop attractive and insightful charts in android applications.
Android Library to rapidly develop attractive and insightful charts in android applications.

williamchart Williamchart is an Android Library to rapidly implement attractive and insightful charts in android applications. Note: WilliamChart v3 h

Attractive, stylish and customizable toast library for Android.

FabToast min SDK 16 (Jelly Bean 4.1) written in Java To download the demo app for this library from Google Playstore so you can see it in action, clic

Android Library to rapidly develop attractive and insightful charts in android applications.
Android Library to rapidly develop attractive and insightful charts in android applications.

williamchart Williamchart is an Android Library to rapidly implement attractive and insightful charts in android applications. Note: WilliamChart v3 h

The ShowcaseView library is designed to highlight and showcase specific parts of apps to the user with an attractive and flat overlay.
The ShowcaseView library is designed to highlight and showcase specific parts of apps to the user with an attractive and flat overlay.

The ShowcaseView library is designed to highlight and showcase specific parts of apps to the user with an attractive and flat overlay.

[] Easily create a simple, attractive and seamless custom action bar style for your Android application

Android Action Bar Style Generator ####DEPRECATED: Consider using Toolbar or its support library equivalent.#### The Android Action Bar Style Generato

App to simulate making lemonada juice in form of attractive application

Project: Lemonade App - Starter Code Starter code for the first independent project for Android Basics in Kotlin Introduction This is the starter code

Micro Template ๐Ÿ“ƒ A very tiny and simple text templating library for Kotlin.

Micro Template ๐Ÿ“ƒ A very tiny and simple text templating library for Kotlin. It has very limited features, so it's intended to be used for short templ

A Kotlin binding to webview, a tiny cross-platform webview library, supports Java and Native.
A Kotlin binding to webview, a tiny cross-platform webview library, supports Java and Native.

webviewko provides a Kotlin/JVM and a Kotlin/Native(experimental) binding to webview, a tiny cross-platform webview library to build modern cross-platform GUIs using WebView2, WebKit and WebKitGTK.

A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisation and okio

Store A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisatio

HubSpot Kotlin SDK ๐Ÿงบ Implementation of HubSpot API for Java/Kotlin in tiny SDK

HubSpot Kotlin SDK ๐Ÿงบ Implementation of HubSpot API for Java/Kotlin in tiny SDK

Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.
Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.

Palette Helper is a simple utility app made to generate color palettes of images using Google's fantastic Palette library. It's mostly a for-fun pet p

Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.
Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.

Palette Helper is a simple utility app made to generate color palettes of images using Google's fantastic Palette library. It's mostly a for-fun pet p

Functional Kotlin & Arrow based library for generating and verifying JWTs and JWSs

kJWT Functional Kotlin & Arrow based library for generating and verifying JWTs and JWSs. JWS JWT The following Algorithms are supported: HS256 HS384 H

An Android library for scanning documents based on CameraX API and a tiny version of OpenCV

Document Scanner with tiny OpenCV example1.mp4 Document Scanner is an Android library (kotlin based) for scanning documents based on CameraX API and a

Tiny library to ease the use of environment variables with support for .env files

asimov/environment Tiny library to ease the use of environment variables with support for .env files. Installation Gradle (Kotlin) repositories {

A tiny Kotlin API for cheap logging on top of Android's normal Log class.
A tiny Kotlin API for cheap logging on top of Android's normal Log class.

A tiny Kotlin API for cheap logging on top of Android's normal Log class.

Android library for auto generating SQL schema and Content provider

Android-AnnotatedSQL Android library for auto generating SQL schema and Content Provider by annotations. You will get a full-featured content provider

Comments
  • [Improved] Better way to clamp the hue value

    [Improved] Better way to clamp the hue value

    Instead of manually checking if value == 0 or 360, you can use Kotlin's coerceIn extension function to automatically clamp the value between the specified range.

    opened by KaustubhPatange 0
  • Feature request: publish the library to mavenCentral()

    Feature request: publish the library to mavenCentral()

    I would prefer to be able to fetch the library from mavenCentral() instead of having to add jitpack.io as additional repository.

    Any reason why is not published there? I know that it's a little tricky to publish something there but, if you need help, I have already published a library and I could provide support: https://github.com/leinardi/FloatingActionButtonSpeedDial/

    opened by leinardi 0
  • better hsv to rgb maybe.

    better hsv to rgb maybe.

    I have found a better way to convert the color from hsv to rgb.maybe.

    in the method setFormat, it call the HSVtoRGB method to convert to rgb. then I get a method from android.graphics.color that names Color.HSVToColor() image then I try to use the method to calculate the color. and it turn out to be the same result : the test code: image the test result pick one: image

    so I think we should use the method from android.graphics.color priority

    opened by qihigh 0
Owner
Brian Norman
Android Engineer @SeatGeek
Brian Norman
A list of most useful resources for designing android apps such as all material colors and dimens, 180 Gradient background + html, social, flat, fluent, metro colors.

Timer UI Login UI Fitness UI Material-Resources-Library A list of most useful resources for designing android apps such as all material colors and dim

Next 37 Jul 24, 2022
Android Material Design Colors

Android-Material-Design-Colors Android-Material-Design-Colors provides color definitions of the Material Design. Demo Usage R.color.md_color_value or

wada811 197 Jan 2, 2023
How to use Material You colors in your app

A small tool that help to see the colors generated by Material You.

Dmitry 25 Oct 14, 2022
Color.kt is a modern color science library for Kotlin Multiplatform and Java.

Color.kt is a modern color science library for Kotlin Multiplatform and Java. It includes modern perceptually-uniform color spaces and color appearance models, such as Oklab and ZCAM.

Danny Lin 45 Oct 11, 2022
A modern color science library for Kotlin Multiplatform and Java

Color.kt Color.kt is a modern color science library for Kotlin Multiplatform and Java. It includes modern perceptually-uniform color spaces and color

Weeb Project (WIP) 0 Oct 21, 2021
Color.kt is a modern color science library for Kotlin Multiplatform and Java.

Color.kt is a modern color science library for Kotlin Multiplatform and Java. It includes modern perceptually-uniform color spaces and color

SOSP-OS 0 Jan 21, 2022
Color picker library for Android

andColorPicker โ€” Color Picker library for Android ?? Handy, ?? flexible, and โšก lightning-fast Android color picker views and utilities. ?? Features Cl

side.codes 216 Jan 7, 2023
Little image processing library

Poliwhirl Description This is a small image processing library done to find good color for icon background. It uses CIEDE2000 to determine what colors

Anton Potapov 24 Sep 7, 2022
Color Picker โ€” beautiful library for Android

Color Picker โ€” beautiful library for Android Features Simple dialog builder ARGB, RGB & HSV color models Dark theme support Sliders with gradient back

Dmitriy 35 Dec 20, 2022
Hex string encoder/decoder for Kotlin/Multiplatform

Hex string encoder/decoder for Kotlin/Multiplatform. Supports Android, iOS, JavaScript and plain JVM environments.

Sascha Peilicke 5 Jul 23, 2022