- All color class constructors are now public to avoid warning when using
copy()
(#65) HSV.toSRGB()
with NaN a hue value now returns a greyscaleRGB
color instead of a NaN color. (#67)- Update Kotlin to 2.1.0
- Publish artifacts for the
watchosArm32
target (thanks @ReneeVandervelde)
- Update Kotlin to 2.0.0
- Publish artifacts for the
JS
andwasmJs
targets for the jetpack-compose extensions. - Added support to
formatCssString
andColor.parse
for color spaces added in recent updates to the CSS color spec:oklab
,oklch
,srgb-linear
,xyz-d50
andxyz-d65
. - Added
customColorSpaces
forColor.parse
andColor.formatCssString
to allow non-standard color spaces to be used in color strings. - Added
min
andmax
properties toColorComponentInfo
to get the reference range for the component. - Support percentage format for all values in
Color.parse
with reference range scaling from the new drafts of CSS Color Module 4. - Added
clamp()
function to all color models to clamp the color components to their valid range.
Color.parse
now parseslch()
andlab()
functions with the with D50 white points instead of D65 in order to comply with the latest draft of CSS Color Module 4.Color.parse
no longer clamps out-of-gamut values by default. Use the newclamp
method on the returned color if desired.
ColorSpace.equals
will now properly return true when comparing color companions with the space they represent e.g.XYZ == XYZ65
- Support the CSS "none" keyword for
NaN
values inColor.parse
andColor.formatCssString
- Publish artifacts for the
wasmJs
target. This target is experimental.
- Use unique namespace for all android extensions and disable BuildConfig generation. Thanks to @frett for the contribution (#45)
- Publish
linuxArm64
target. This target is not tested on CI.
- Updated Kotlin to 1.9.0
- Publish JVM artifacts with Java 8 bytecode
- The core module now publishes multiplatform targets for
iosSimulatorArm64
,tvosSimulatorArm64
, andwatchosSimulatorArm64
. - The Jetpack Compose extensions module
colormath-ext-jetpack-compose
now publishes multiplatform targets for JVM and iOS in addition to the existing android target.
- Updated Kotlin to 1.8
- Updated Kotlin to 1.7.10
hueOr
extension to colors likeHSV
that returns the color's hue or a fallback value if the hue is undefined.
- Updated Kotlin to 1.6.0
- Fix shared immutability for background threads on Kotlin Native
- Optional modules with extensions for converting between Colormath colors and other platform representations.
- Unspecified alpha values now default to fully opaque
- New color models:
Oklab
,Oklch
,HWB
,HPLuv
,HSLuv
,LCHab
,LCHuv
,JzAzBz
,JzCzHz
,ICtCp
- New RGB color spaces:
Linear sRGB
,ACES
,ACEScc
,ACEScct
,ACEScg
,Adobe RGB
,BT.2020
,BT.709
,DCI P3
,Display P3
,ProPhoto
- Other color spaces:
LABColorSpace
,LCHabColorSpace
,LCHuvColorSpace
,LUVColorSpace
,XYZColorSpace
- WCAG contrast:
wcagLuminance
,wcagContrastRatio
,mostContrasting
,firstWithContrast
- Color difference:
euclideanDistance
,differenceCIE76
,differenceCIE94
,differenceCIE2000
,differenceCMC
,differenceEz
- Transforms:
Color.map
,mix
,multiplyAlpha
,divideAlpha
,createChromaticAdapter
,RGBColorSpace.converterTo
- Interpolation:
Color.interpolate
,ColorSpace.interpolator
- Color metadata:
ColorSpace
,Color.space
,Color.toArray
,ColorSpace.create
- CSS parsing and rendering now support all CSS color strings
RGBInt
: an inline class that storesRGB
colors packed in a single Int. Create instances directly, or convert to it withRGB.toRGBInt()
- Publish
macosArm64
target.
- All
Color
classes now store their color components asFloat
RGB
,XYZ
, HSV,
HSL, and
HWBnow store their rectangular components normalized to
[0, 1]`.- Renamed
Color.fromCss
toColor.parse
. - All
Color
constructors now usealpha
as name of their final parameter. - Replace
toCssRgb
andtoCssHsl
withfromatCssString
that supports all color models. - All color models moved from the package
com.github.ajalt.colormath
tocom.github.ajalt.colormath.model
- Updated Kotlin to 1.5.30
- Removed the previously deprecated
ConvertibleColor
typealias. - Removed the
CssColors
object. UseColor.fromCss
instead. - Removed
Ansi16
companion object color constants. - Removed
Color.toHex()
. UseRGB.toHex()
instead.
- Added CIE LUV colorspace support
- Added CIE LCH(uv) colorspace support
- Added HWB colorspace support
- Added
lab()
andhwb()
support toColor.fromCss
- JS target now publishes IR format in addition to legacy jars
- Updated Kotlin to 1.5.0
Color.fromCss
now clamps out-of-range values in accordance with the CSS Color Module Level 4 spec
- Added multiplatform support.
- Moved maven coordinates to
com.github.ajalt.colormath:colormath:2.0.0
.
- Renamed
ConvertibleColor
toColor
. The old name is left as a deprecated type alias.
- Fix
RGB(255,255, 255).toLAB()
throwing an exception due to rounding precision.
hueAsRad()
,hueAsGrad()
, andhueAsTurns()
extensions forHSL
andHSV
classes.toHex()
now has arenderAlpha
parameter that lets you render the color's alpha channel in the hex. By default the alpha will be added if it's < 1.toCssRgb()
andtoCssHsl()
extensions to render colors as CSS color functionsRGB.toPackedInt()
to convert a color to a single integer.
withNumberSign
parameter oftoHex
now defaults totrue
ColorMath.parseCssColor()
renamed toConvertableColor.fromCss()
andColorMath.cssKeywordColors
toCssColors.colorsByName
- All colors now have an
alpha
channel, defaulting to 1 (fully opaque). For colorspaces that support transparency, you can pass an alpha value into their constructors. ColorMath.parseCssColor()
can parse all valid HTML/CSS colors, including rgb, hsl, and named colors.ColorMath.cssKeywordColors
is a map of HTML/CSS color names to RGB the colors they represent.
- Switch rounding methods to use
kotlin.math
rounding, which can slightly change conversion results in some cases.
- Add ability to construct RGB instances from packed integers or Bytes