Skip to content

Commit 8881e72

Browse files
committed
Release v1.0 with non-heap-allocating API
1 parent a8c1e19 commit 8881e72

6 files changed

Lines changed: 491 additions & 537 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.iml
2+
/.vscode
23
target/
34
settings.xml
45
pom.xml.tag

README.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,62 @@ If you are using Maven, add the following to your `pom.xml` file:
1111
<dependency>
1212
<groupId>org.hsluv</groupId>
1313
<artifactId>hsluv</artifactId>
14-
<version>0.2</version>
14+
<version>1.0</version>
1515
</dependency>
16-
17-
# Documentation
1816

19-
Javadocs: http://www.javadoc.io/doc/org.hsluv/hsluv
17+
# Usage
18+
19+
The API is designed to avoid heap allocation. The `HSLuv` class defines the following public fields:
20+
21+
- RGB: `hex:String`, `rgb_r` [0;1], `rgb_g` [0;1], `rgb_r` [0;1]
22+
- CIE XYZ: `xyz_x`, `xyz_y`, `xyz_z`
23+
- CIE LUV: `luv_l`, `luv_u`, `luv_v`
24+
- CIE LUV LCh: `lch_l`, `lch_c`, `lch_h`
25+
- HSLuv: `hsluv_h` [0;360], `hsluv_s` [0;100], `hsluv_l` [0;100]
26+
- HPLuv: `hpluv_h` [0;360], `hpluv_p` [0;100], `hpluv_l` [0;100]
27+
28+
To convert between color spaces, simply set the properties of the source color space, run the
29+
conversion methods, then read the properties of the target color space.
30+
31+
Use the following methods to convert to and from RGB:
32+
33+
- HSLuv: `hsluvToRgb()`, `hsluvToHex()`, `rgbToHsluv()`, `hexToHsluv()`
34+
- HPLuv: `hpluvToRgb()`, `hpluvToHex()`, `rgbToHpluv()`, `hexToHpluv()`
35+
36+
Use the following methods to do step-by-step conversion:
37+
38+
- Forward: `hsluvToLch()` (or `hpluvToLch()`), `lchToLuv()`, `luvToXyz()`, `xyzToRgb()`, `rgbToHex()`
39+
- Backward: `hexToRgb()`, `rgbToXyz()`, `xyzToLuv()`, `luvToLch()`, `lchToHsluv()` (or `lchToHpluv()`)
40+
41+
For advanced usage, we also export the [bounding lines](https://www.hsluv.org/math/) in slope-intercept
42+
format, two for each RGB channel representing the limit of the gamut.
43+
44+
- R < 0: `r0s`, `r0i`
45+
- R > 1: `r1s`, `r1i`
46+
- G < 0: `g0s`, `g0i`
47+
- G > 1: `g1s`, `g1i`
48+
- B < 0: `b0s`, `b0i`
49+
- B > 1: `b1s`, `b1i`
50+
51+
Example:
52+
53+
```java
54+
HsluvColorConverter conv = new HsluvColorConverter();
55+
conv.hsluv_h = 10;
56+
conv.hsluv_s = 75;
57+
conv.hsluv_l = 65;
58+
conv.hsluvToHex();
59+
System.out.println(conv.hex); // Will print "#ec7d82"
60+
```
2061

2162
# Testing
2263

2364
mvn test
2465

2566
# Deployment
2667

27-
Docs:
68+
Docs:
69+
2870
- https://central.sonatype.org/publish/publish-maven/
2971
- https://central.sonatype.org/publish/requirements/gpg/
3072

@@ -59,4 +101,3 @@ Then run:
59101
mvn versions:set -DnewVersion=0.3 # bump version
60102
mvn clean deploy -P release
61103
```
62-

pom.xml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
34

45
<modelVersion>4.0.0</modelVersion>
56
<groupId>org.hsluv</groupId>
67
<artifactId>hsluv</artifactId>
78
<packaging>jar</packaging>
8-
<version>0.3</version>
9+
<version>1.0</version>
910

1011
<name>hsluv</name>
1112
<description>Human-friendly HSL</description>
@@ -48,12 +49,6 @@
4849
<version>4.13.2</version>
4950
<scope>test</scope>
5051
</dependency>
51-
<dependency>
52-
<groupId>javax</groupId>
53-
<artifactId>javaee-api</artifactId>
54-
<version>8.0.1</version>
55-
<scope>test</scope>
56-
</dependency>
5752
<dependency>
5853
<groupId>org.glassfish</groupId>
5954
<artifactId>jakarta.json</artifactId>
@@ -121,8 +116,8 @@
121116
<goal>sign</goal>
122117
</goals>
123118
<configuration>
124-
<keyname>0xD54740FB</keyname>
125-
<passphraseServerId>0xD54740FB</passphraseServerId>
119+
<keyname>EBFD22439E5C59D664D0CFC750617B51F61187C2</keyname>
120+
<passphraseServerId>EBFD22439E5C59D664D0CFC750617B51F61187C2</passphraseServerId>
126121
<gpgArguments>
127122
<arg>--pinentry-mode</arg>
128123
<arg>loopback</arg>
@@ -133,4 +128,4 @@
133128
</plugin>
134129
</plugins>
135130
</build>
136-
</project>
131+
</project>

0 commit comments

Comments
 (0)