Colors
Doodle supports RGBA colors (via the Color
class), for rendering content to the Canvas
via paints like ColorPaint
. Colors can be created explicitly using hex notation, or you can use any of the built-in values (i.e. Red
). Colors can also be derived from others with one of the many utility functions like lighter
, darker
, or by changing opacity
.
package rendering
import io.nacular.doodle.drawing.Color
import io.nacular.doodle.drawing.darker
import io.nacular.doodle.drawing.opacity
import io.nacular.doodle.drawing.paint
fun colors() {
//sampleStart
Color(0xff0000u ) // create red
Color(0xffffffu, opacity = 0.5f) // white with 0.5 opacity
Color.Red // build-in red
Color.Blue opacity 0.5f // blue with 0.5 opacity
Color.Blue.inverted // inverse of blue
Color.Lightgray.darker(0.5f) // darker gray
Color.Blue.paint // paint from a color
//sampleEnd
}
HSL and HSV Colors
Sometimes it is more effective to work within other color spaces. Doodle has built-in utilities for HSL and HSV colors, though these colors cannot be used directly for rendering. That said, there are many utilities for easily transforming between them and RGBA.
The ColorPicker controls uses HSV internally for example.