Skip to content

🎨 A tiny (Kotlin) library for generating attractive colors

License

Notifications You must be signed in to change notification settings

brian-norman/RandomKolor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 color (RGB) randomly
val rgbString = RandomKolor().randomColor()
// Generate a light blue (HEX)
val rgbString = RandomKolor().randomColor(hue = ColorHue(BLUE), luminosity = Luminosity.LIGHT, format = Format.HEX)
// Generate three light oranges (HSL)
val rgbStrings = RandomKolor().randomColors(count = 3, hue = ColorHue(ORANGE), luminosity = Luminosity.LIGHT, format = Format.HSL)

Acknowledgements

TODO

  • Add alpha to RGB

About

🎨 A tiny (Kotlin) library for generating attractive colors

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages