`java.scene.paint.color` is really annoying to wor...
# tornadofx
h
java.scene.paint.color
is really annoying to work with. it'd be nice if you could do things like:
Copy code
val myColor = Color(0.5, 0.5, 0.5)
myColor.saturation += 0.5
myColor.opacity *= 0.3
etc, but nope!
a
You can add some extension properties to the class.
h
Not really. These are already properties of the class, they are just immutable
This is what I came up with:
Copy code
fun Color.hued(shift: Double) = deriveColor(shift, 1.0, 1.0, 1.0)

fun Color.saturated(scalar: Double) = deriveColor(0.0, scalar, 1.0, 1.0)


fun Color.brightened(scalar: Double) = deriveColor(0.0, 1.0, scalar, 1.0)

fun Color.reddened(scalar: Double) = Color(scalar * red, green, blue, opacity)

fun Color.greened(scalar: Double) = Color(red, scalar * green, blue, opacity)

fun Color.blued(scalar: Double) = Color(red, green, scalar * blue, opacity)

fun Color.opaqued(scalar: Double) = Color(red, green, blue, scalar * opacity)
But it didn't really help me anyhow, because I wanted to manipulate the the
fill
color, but it's of type
Paint
, which doesn't have any of those values.
very frustrating to use