Compare commits

...

3 commits

Author SHA1 Message Date
sgoudham
8ab44c0189
build: sign keys 2022-09-05 21:05:09 +01:00
Hamothy
9a45e09f4c
docs(README): Add eventual instructions for java 2022-09-04 15:58:53 -07:00
sgoudham
952e03013e
feat: add java library
This commit introduces support for the
catppuccin colour palette in the java
ecosystem.
2022-09-04 23:40:39 +01:00
14 changed files with 727 additions and 0 deletions

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
dist/
node_modules/
java/.idea/
java/target/

View file

@ -19,6 +19,7 @@
- Development
- [Node Package](#node-package)
- [Java Library](#java-library)
- [CSS](#css)
- [Sass](#sass)
- [Tailwind CSS](https://github.com/catppuccin/tailwindcss) (separate repository)
@ -54,6 +55,31 @@ console.log(variants.latte.lavender.hex) // #7287FD
console.log(labels.base.macchiato.hex) // #24273A
```
### Java Library
**Maven**
```xml
<!-- https://mvnrepository.com/artifact/catppuccin/palette -->
<dependency>
<groupId>com.catppuccin</groupId>
<artifactId>palette</artifactId>
<version>VERSION</version>
</dependency>
```
**Gradle**
```gradle
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/catppuccin/palette
implementation group: 'com.catppuccin', name: 'palette', version: 'VERSION'
}
```
### CSS
Import the palettes:

BIN
java.zip Normal file

Binary file not shown.

0
java/README.md Normal file
View file

133
java/pom.xml Normal file
View file

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.catppuccin</groupId>
<artifactId>palette</artifactId>
<version>0.1.0</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<licenses>
<license>
<name>MIT License</name>
<url>https://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/catppuccin/palette.git</connection>
<developerConnection>scm:git:ssh://github.com:catppuccin/palette.git</developerConnection>
<url>https://github.com/catppuccin/palette/tree/main/java</url>
</scm>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<source>17</source>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<parallel>all</parallel>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,69 @@
package com.catppuccin;
import com.catppuccin.flavor.Flavor;
import com.catppuccin.flavor.Frappe;
import com.catppuccin.flavor.Macchiato;
import com.catppuccin.flavor.Mocha;
import java.util.List;
import java.util.Objects;
import com.catppuccin.flavor.Latte;
public class Palette {
private final Flavor latte = new Latte();
private final Flavor frappe = new Frappe();
private final Flavor macchiato = new Macchiato();
private final Flavor mocha = new Mocha();
/**
* Retrieve all the flavours of the palette in the
* following order: Latte, Frappé, Macchiato and Mocha
*
* @return {@link List} of {@link Flavor}
*/
public List<Flavor> asList() {
return List.of(latte, frappe, macchiato, mocha);
}
public Flavor getLatte() {
return latte;
}
public Flavor getFrappe() {
return frappe;
}
public Flavor getMacchiato() {
return macchiato;
}
public Flavor getMocha() {
return mocha;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Palette palette = (Palette) o;
return Objects.equals(latte, palette.latte) && Objects.equals(frappe, palette.frappe) && Objects.equals(macchiato, palette.macchiato) && Objects.equals(mocha, palette.mocha);
}
@Override
public int hashCode() {
return Objects.hash(latte, frappe, macchiato, mocha);
}
@Override
public String toString() {
return "Palette{" +
"latte=" + latte +
", frappe=" + frappe +
", macchiato=" + macchiato +
", mocha=" + mocha +
'}';
}
}

View file

@ -0,0 +1,52 @@
package com.catppuccin.flavor;
public class Color extends java.awt.Color {
/**
* @see java.awt.Color#Color(int, int, int)
*/
Color(int r, int g, int b) {
super(r, g, b);
}
/**
* Converts the components of the chosen colour, as specified by the default RGB
* model, to an equivalent hexadecimal representation.
*
* @return A {@link String} containing the hex value of the chosen colour, e.g "#1e1e2e"
*/
public String getHex() {
return String.format("#%02x%02x%02x", this.getRed(), this.getGreen(), this.getBlue());
}
/**
* Converts the components of the chosen colour, as specified by the default RGB
* model, to an equivalent set of values for hue, saturation, and
* brightness that are the three components of the HSB model.
*
* @return an array of three elements containing the hue, saturation,
* and brightness (in that order), of the colour with
* the indicated red, green, and blue components.
* @see java.awt.Color#getRGB()
* @see java.awt.Color#Color(int)
* @see java.awt.image.ColorModel#getRGBdefault()
*/
public float[] getHSB() {
return java.awt.Color.RGBtoHSB(this.getRed(), this.getGreen(), this.getBlue(), null);
}
/**
* Converts the components of the chosen colour, as specified by the default RGB
* model, to an equivalent set of values for hue, saturation, and
* brightness that are the three components of the HSB model.
*
* @param values the array used to return the
* three HSB values
* @see java.awt.Color#getRGB()
* @see java.awt.Color#Color(int)
* @see java.awt.image.ColorModel#getRGBdefault()
*/
public void getHSB(float[] values) {
java.awt.Color.RGBtoHSB(this.getRed(), this.getGreen(), this.getBlue(), values);
}
}

View file

@ -0,0 +1,255 @@
package com.catppuccin.flavor;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import com.catppuccin.flavor.domain.Variant;
public abstract sealed class Flavor permits Latte, Frappe, Macchiato, Mocha {
private final Color rosewater;
private final Color flamingo;
private final Color pink;
private final Color mauve;
private final Color red;
private final Color maroon;
private final Color peach;
private final Color yellow;
private final Color green;
private final Color teal;
private final Color sky;
private final Color sapphire;
private final Color blue;
private final Color lavender;
private final Color text;
private final Color subtext1;
private final Color subtext0;
private final Color overlay2;
private final Color overlay1;
private final Color overlay0;
private final Color surface2;
private final Color surface1;
private final Color surface0;
private final Color base;
private final Color mantle;
private final Color crust;
private final Variant variant;
Flavor(Color rosewater, Color flamingo, Color pink, Color mauve, Color red, Color maroon, Color peach, Color yellow, Color green, Color teal, Color sky, Color sapphire, Color blue, Color lavender, Color text, Color subtext1, Color subtext0, Color overlay2, Color overlay1, Color overlay0, Color surface2, Color surface1, Color surface0, Color base, Color mantle, Color crust, Variant variant) {
this.rosewater = rosewater;
this.flamingo = flamingo;
this.pink = pink;
this.mauve = mauve;
this.red = red;
this.maroon = maroon;
this.peach = peach;
this.yellow = yellow;
this.green = green;
this.teal = teal;
this.sky = sky;
this.sapphire = sapphire;
this.blue = blue;
this.lavender = lavender;
this.text = text;
this.subtext1 = subtext1;
this.subtext0 = subtext0;
this.overlay2 = overlay2;
this.overlay1 = overlay1;
this.overlay0 = overlay0;
this.surface2 = surface2;
this.surface1 = surface1;
this.surface0 = surface0;
this.base = base;
this.mantle = mantle;
this.crust = crust;
this.variant = variant;
}
public List<Color> asList() {
return Arrays.asList(
rosewater,
flamingo,
pink,
mauve,
red,
maroon,
peach,
yellow,
green,
teal,
sky,
sapphire,
blue,
lavender,
text,
subtext1,
subtext0,
overlay2,
overlay1,
overlay0,
surface2,
surface1,
surface0,
base,
mantle,
crust
);
}
public Color getRosewater() {
return rosewater;
}
public Color getFlamingo() {
return flamingo;
}
public Color getPink() {
return pink;
}
public Color getMauve() {
return mauve;
}
public Color getRed() {
return red;
}
public Color getMaroon() {
return maroon;
}
public Color getPeach() {
return peach;
}
public Color getYellow() {
return yellow;
}
public Color getGreen() {
return green;
}
public Color getTeal() {
return teal;
}
public Color getSky() {
return sky;
}
public Color getSapphire() {
return sapphire;
}
public Color getBlue() {
return blue;
}
public Color getLavender() {
return lavender;
}
public Color getText() {
return text;
}
public Color getSubtext1() {
return subtext1;
}
public Color getSubtext0() {
return subtext0;
}
public Color getOverlay2() {
return overlay2;
}
public Color getOverlay1() {
return overlay1;
}
public Color getOverlay0() {
return overlay0;
}
public Color getSurface2() {
return surface2;
}
public Color getSurface1() {
return surface1;
}
public Color getSurface0() {
return surface0;
}
public Color getBase() {
return base;
}
public Color getMantle() {
return mantle;
}
public Color getCrust() {
return crust;
}
public Variant getVariant() {
return variant;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Flavor flavor = (Flavor) o;
return Objects.equals(rosewater, flavor.rosewater) && Objects.equals(flamingo, flavor.flamingo) && Objects.equals(pink, flavor.pink) && Objects.equals(mauve, flavor.mauve) && Objects.equals(red, flavor.red) && Objects.equals(maroon, flavor.maroon) && Objects.equals(peach, flavor.peach) && Objects.equals(yellow, flavor.yellow) && Objects.equals(green, flavor.green) && Objects.equals(teal, flavor.teal) && Objects.equals(sky, flavor.sky) && Objects.equals(sapphire, flavor.sapphire) && Objects.equals(blue, flavor.blue) && Objects.equals(lavender, flavor.lavender) && Objects.equals(text, flavor.text) && Objects.equals(subtext1, flavor.subtext1) && Objects.equals(subtext0, flavor.subtext0) && Objects.equals(overlay2, flavor.overlay2) && Objects.equals(overlay1, flavor.overlay1) && Objects.equals(overlay0, flavor.overlay0) && Objects.equals(surface2, flavor.surface2) && Objects.equals(surface1, flavor.surface1) && Objects.equals(surface0, flavor.surface0) && Objects.equals(base, flavor.base) && Objects.equals(mantle, flavor.mantle) && Objects.equals(crust, flavor.crust) && variant == flavor.variant;
}
@Override
public int hashCode() {
return Objects.hash(rosewater, flamingo, pink, mauve, red, maroon, peach, yellow, green, teal, sky, sapphire, blue, lavender, text, subtext1, subtext0, overlay2, overlay1, overlay0, surface2, surface1, surface0, base, mantle, crust, variant);
}
@Override
public String toString() {
return "Flavor{" +
"rosewater=" + rosewater +
", flamingo=" + flamingo +
", pink=" + pink +
", mauve=" + mauve +
", red=" + red +
", maroon=" + maroon +
", peach=" + peach +
", yellow=" + yellow +
", green=" + green +
", teal=" + teal +
", sky=" + sky +
", sapphire=" + sapphire +
", blue=" + blue +
", lavender=" + lavender +
", text=" + text +
", subtext1=" + subtext1 +
", subtext0=" + subtext0 +
", overlay2=" + overlay2 +
", overlay1=" + overlay1 +
", overlay0=" + overlay0 +
", surface2=" + surface2 +
", surface1=" + surface1 +
", surface0=" + surface0 +
", base=" + base +
", mantle=" + mantle +
", crust=" + crust +
", variant=" + variant +
'}';
}
}

View file

@ -0,0 +1,37 @@
package com.catppuccin.flavor;
import com.catppuccin.flavor.domain.Variant;
public non-sealed class Frappe extends Flavor {
public Frappe() {
super(
new Color(242, 213, 207), // Colour rosewater,
new Color(238, 190, 190), // Colour flamingo,
new Color(244, 184, 228), // Colour pink,
new Color(202, 158, 230), // Colour mauve,
new Color(231, 130, 132), // Colour red,
new Color(234, 153, 156), // maroon,
new Color(239, 159, 118), // peach,
new Color(229, 200, 144), // yellow,
new Color(166, 209, 137), // green,
new Color(129, 200, 190), // teal,
new Color(153, 209, 219), // sky,
new Color(133, 193, 220), // sapphire,
new Color(140, 170, 238), // blue,
new Color(186, 187, 241), // lavender,
new Color(198, 208, 245), // text,
new Color(181, 191, 226), // subtext1,
new Color(165, 173, 206), // subtext0,
new Color(148, 156, 187), // overlay2,
new Color(131, 139, 167), // overlay1,
new Color(115, 121, 148), // overlay0,
new Color(98, 104, 128), // surface2,
new Color(81, 87, 109), // surface1,
new Color(65, 69, 89), // surface0,
new Color(48, 52, 70), // base,
new Color(41, 44, 60), // mantle,
new Color(35, 38, 52), // crust
Variant.FRAPPE
);
}
}

View file

@ -0,0 +1,37 @@
package com.catppuccin.flavor;
import com.catppuccin.flavor.domain.Variant;
public non-sealed class Latte extends Flavor {
public Latte() {
super(
new Color(220, 138, 120), // Colour rosewater,
new Color(221, 120, 120), // Colour flamingo,
new Color(234, 118, 203), // Colour pink,
new Color(136, 57, 239), // Colour mauve,
new Color(210, 15, 57), // Colour red,
new Color(230, 69, 83), // maroon,
new Color(254, 100, 11), // peach,
new Color(223, 142, 29), // yellow,
new Color(64, 160, 43), // green,
new Color(23, 146, 153), // teal,
new Color(4, 165, 229), // sky,
new Color(32, 159, 181), // sapphire,
new Color(30, 102, 245), // blue,
new Color(114, 135, 253), // lavender,
new Color(76, 79, 105), // text,
new Color(92, 95, 119), // subtext1,
new Color(108, 111, 133), // subtext0,
new Color(124, 127, 147), // overlay2,
new Color(140, 143, 161), // overlay1,
new Color(156, 160, 176), // overlay0,
new Color(172, 176, 190), // surface2,
new Color(188, 192, 204), // surface1,
new Color(204, 208, 218), // surface0,
new Color(239, 241, 245), // base,
new Color(230, 233, 239), // mantle,
new Color(220, 224, 232), // crust
Variant.LATTE
);
}
}

View file

@ -0,0 +1,37 @@
package com.catppuccin.flavor;
import com.catppuccin.flavor.domain.Variant;
public non-sealed class Macchiato extends Flavor {
public Macchiato() {
super(
new Color(244, 219, 214), // Colour rosewater,
new Color(240, 198, 198), // Colour flamingo,
new Color(245, 189, 230), // Colour pink,
new Color(198, 160, 246), // Colour mauve,
new Color(237, 135, 150), // Colour red,
new Color(238, 153, 160), // maroon,
new Color(245, 169, 127), // peach,
new Color(238, 212, 159), // yellow,
new Color(166, 218, 149), // green,
new Color(139, 213, 202), // teal,
new Color(145, 215, 227), // sky,
new Color(125, 196, 228), // sapphire,
new Color(138, 173, 244), // blue,
new Color(183, 189, 248), // lavender,
new Color(202, 211, 245), // text,
new Color(184, 192, 224), // subtext1,
new Color(165, 173, 203), // subtext0,
new Color(147, 154, 183), // overlay2,
new Color(128, 135, 162), // overlay1,
new Color(110, 115, 141), // overlay0,
new Color(91, 96, 120), // surface2,
new Color(73, 77, 100), // surface1,
new Color(54, 58, 79), // surface0,
new Color(36, 39, 58), // base,
new Color(30, 32, 48), // mantle,
new Color(24, 25, 38), // crust
Variant.MACCHIATO
);
}
}

View file

@ -0,0 +1,37 @@
package com.catppuccin.flavor;
import com.catppuccin.flavor.domain.Variant;
public non-sealed class Mocha extends Flavor {
public Mocha() {
super(
new Color(245, 224, 220), // Colour rosewater,
new Color(242, 205, 205), // Colour flamingo,
new Color(245, 194, 231), // Colour pink,
new Color(203, 166, 247), // Colour mauve,
new Color(243, 139, 168), // Colour red,
new Color(235, 160, 172), // maroon,
new Color(250, 179, 135), // peach,
new Color(249, 226, 175), // yellow,
new Color(166, 227, 161), // green,
new Color(148, 226, 213), // teal,
new Color(137, 220, 235), // sky,
new Color(116, 199, 236), // sapphire,
new Color(137, 180, 250), // blue,
new Color(180, 190, 254), // lavender,
new Color(205, 214, 244), // text,
new Color(186, 194, 222), // subtext1,
new Color(166, 173, 200), // subtext0,
new Color(147, 153, 178), // overlay2,
new Color(127, 132, 156), // overlay1,
new Color(108, 112, 134), // overlay0,
new Color(88, 91, 112), // surface2,
new Color(69, 71, 90), // surface1,
new Color(49, 50, 68), // surface0,
new Color(30, 30, 46), // base,
new Color(24, 24, 37), // mantle,
new Color(17, 17, 27), // crust
Variant.MOCHA
);
}
}

View file

@ -0,0 +1,8 @@
package com.catppuccin.flavor.domain;
public enum Variant {
LATTE,
FRAPPE,
MACCHIATO,
MOCHA
}

View file

@ -0,0 +1,34 @@
package com.catppuccin;
import com.catppuccin.flavor.Flavor;
import com.catppuccin.flavor.Mocha;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
public class FlavorTest {
@Test
void shouldReturnHSB() {
Flavor mocha = new Mocha();
float[] expectedHSB = new float[3];
expectedHSB[0] = 240.0F / 360.0F;
expectedHSB[1] = 0.3478261F;
expectedHSB[2] = 0.18039216F;
assertThat(mocha.getBase().getHSB(), is(expectedHSB));
}
@Test
void shouldReturnHSBWhenGivenArray() {
Flavor mocha = new Mocha();
float[] actualHSB = new float[3];
mocha.getBase().getHSB(actualHSB);
assertThat(actualHSB[0], is(240.0F / 360.F));
assertThat(actualHSB[1], is(0.3478261F));
assertThat(actualHSB[2], is(0.18039216F));
}
}