Skip to content

Commit

Permalink
Release v1.0 with non-heap-allocating API
Browse files Browse the repository at this point in the history
  • Loading branch information
boronine committed Jun 28, 2024
1 parent a8c1e19 commit 8881e72
Show file tree
Hide file tree
Showing 6 changed files with 491 additions and 537 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.iml
/.vscode
target/
settings.xml
pom.xml.tag
Expand Down
53 changes: 47 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,62 @@ If you are using Maven, add the following to your `pom.xml` file:
<dependency>
<groupId>org.hsluv</groupId>
<artifactId>hsluv</artifactId>
<version>0.2</version>
<version>1.0</version>
</dependency>

# Documentation

Javadocs: http://www.javadoc.io/doc/org.hsluv/hsluv
# Usage

The API is designed to avoid heap allocation. The `HSLuv` class defines the following public fields:

- RGB: `hex:String`, `rgb_r` [0;1], `rgb_g` [0;1], `rgb_r` [0;1]
- CIE XYZ: `xyz_x`, `xyz_y`, `xyz_z`
- CIE LUV: `luv_l`, `luv_u`, `luv_v`
- CIE LUV LCh: `lch_l`, `lch_c`, `lch_h`
- HSLuv: `hsluv_h` [0;360], `hsluv_s` [0;100], `hsluv_l` [0;100]
- HPLuv: `hpluv_h` [0;360], `hpluv_p` [0;100], `hpluv_l` [0;100]

To convert between color spaces, simply set the properties of the source color space, run the
conversion methods, then read the properties of the target color space.

Use the following methods to convert to and from RGB:

- HSLuv: `hsluvToRgb()`, `hsluvToHex()`, `rgbToHsluv()`, `hexToHsluv()`
- HPLuv: `hpluvToRgb()`, `hpluvToHex()`, `rgbToHpluv()`, `hexToHpluv()`

Use the following methods to do step-by-step conversion:

- Forward: `hsluvToLch()` (or `hpluvToLch()`), `lchToLuv()`, `luvToXyz()`, `xyzToRgb()`, `rgbToHex()`
- Backward: `hexToRgb()`, `rgbToXyz()`, `xyzToLuv()`, `luvToLch()`, `lchToHsluv()` (or `lchToHpluv()`)

For advanced usage, we also export the [bounding lines](https://www.hsluv.org/math/) in slope-intercept
format, two for each RGB channel representing the limit of the gamut.

- R < 0: `r0s`, `r0i`
- R > 1: `r1s`, `r1i`
- G < 0: `g0s`, `g0i`
- G > 1: `g1s`, `g1i`
- B < 0: `b0s`, `b0i`
- B > 1: `b1s`, `b1i`

Example:

```java
HsluvColorConverter conv = new HsluvColorConverter();
conv.hsluv_h = 10;
conv.hsluv_s = 75;
conv.hsluv_l = 65;
conv.hsluvToHex();
System.out.println(conv.hex); // Will print "#ec7d82"
```

# Testing

mvn test

# Deployment

Docs:
Docs:

- https://central.sonatype.org/publish/publish-maven/
- https://central.sonatype.org/publish/requirements/gpg/

Expand Down Expand Up @@ -59,4 +101,3 @@ Then run:
mvn versions:set -DnewVersion=0.3 # bump version
mvn clean deploy -P release
```

19 changes: 7 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>org.hsluv</groupId>
<artifactId>hsluv</artifactId>
<packaging>jar</packaging>
<version>0.3</version>
<version>1.0</version>

<name>hsluv</name>
<description>Human-friendly HSL</description>
Expand Down Expand Up @@ -48,12 +49,6 @@
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.json</artifactId>
Expand Down Expand Up @@ -121,8 +116,8 @@
<goal>sign</goal>
</goals>
<configuration>
<keyname>0xD54740FB</keyname>
<passphraseServerId>0xD54740FB</passphraseServerId>
<keyname>EBFD22439E5C59D664D0CFC750617B51F61187C2</keyname>
<passphraseServerId>EBFD22439E5C59D664D0CFC750617B51F61187C2</passphraseServerId>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
Expand All @@ -133,4 +128,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Loading

0 comments on commit 8881e72

Please sign in to comment.