// Comparison of color lists generated by interpolating from
// PINK to BLUE in different color models

import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.color.palettes.rangeTo
import org.openrndr.extra.color.spaces.toHSLUVa
import org.openrndr.math.Vector2
import org.openrndr.math.map
import org.openrndr.shape.Rectangle

fun main() = application {
    program {
        val numColors = 10
        val colorLists = listOf(
                ColorRGBa.PINK..ColorRGBa.BLUE.toHSVa() blend numColors,
                ColorRGBa.PINK..ColorRGBa.BLUE blend numColors,
                ColorRGBa.PINK..ColorRGBa.BLUE.toHSLUVa() blend numColors,
                ColorRGBa.PINK..ColorRGBa.BLUE.toXSVa() blend numColors,
                ColorRGBa.PINK..ColorRGBa.BLUE.toLUVa() blend numColors,
                ColorRGBa.PINK..ColorRGBa.BLUE.toLCHUVa() blend numColors
        )
        extend {
            drawer.clear(ColorRGBa.WHITE)
            drawer.stroke = null
            colorLists.forEachIndexed { listId, colorList ->
                val x = map(0.0, 2.0,
                        width * 0.2, width * 0.8, listId % 3.0)
                val y = map(0.0, 1.0,
                        height * 0.3, height * 0.7, (listId / 3) * 1.0)
                colorList.forEachIndexed { colorId, color ->
                    drawer.fill = color
                    drawer.rectangle(
                            Rectangle.fromCenter(Vector2(x, y),
                                    180.0 - colorId * 150.0 / numColors))
                }
            }
        }
    }
}