Skip to content

Commit

Permalink
feat: make it all work 😎
Browse files Browse the repository at this point in the history
  • Loading branch information
nullishamy committed Mar 27, 2024
1 parent 186342b commit c0d7cf6
Show file tree
Hide file tree
Showing 23 changed files with 2,227 additions and 1,071 deletions.
File renamed without changes.
File renamed without changes.
1,694 changes: 1,694 additions & 0 deletions palette/palette.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion sources/palette/pom.xml → palette/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<dependency>
<groupId>com.catppuccin</groupId>
<artifactId>processing</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -64,6 +63,9 @@
<annotationProcessors>
<annotationProcessor>com.catppuccin.PaletteProcessor</annotationProcessor>
</annotationProcessors>
<compilerArgs>
<compilerArg>-ApalettePath=${project.basedir}/palette.json</compilerArg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand Down
44 changes: 44 additions & 0 deletions palette/src/main/java/com/catppuccin/Color.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.catppuccin;

public class Color {
private int r;
private int g;
private int b;

public Color(int r, int b, int g) {
this.r = r;
this.g = g;
this.b = b;
}

public int r() {
return this.r;
}

public int g() {
return this.g;
}

public int b() {
return this.b;
}

@Override
public String toString() {
return "Color { r=%d, g=%d, b=%d }".formatted(r, g, b);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}

if (!(obj instanceof Color)) {
return false;
}

Color other = (Color) obj;
return this.r == other.r && this.g == other.g && this.b == other.b;
}
}
32 changes: 32 additions & 0 deletions palette/src/main/java/com/catppuccin/Flavor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.catppuccin;

public interface Flavor {
String name();

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();
}
10 changes: 10 additions & 0 deletions palette/src/main/java/com/catppuccin/Palette.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.catppuccin;

@GeneratedPalette(target="com.catppuccin.BuiltinPalettes")
public class Palette
{
public static final Flavor MOCHA = com.catppuccin.BuiltinPalettes.MOCHA;
public static final Flavor MACCHIATO = com.catppuccin.BuiltinPalettes.MACCHIATO;
public static final Flavor FRAPPE = com.catppuccin.BuiltinPalettes.FRAPPE;
public static final Flavor LATTE = com.catppuccin.BuiltinPalettes.LATTE;
}
68 changes: 68 additions & 0 deletions palette/src/test/java/com/catppuccin/PaletteTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.catppuccin;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import org.junit.Test;

class Oled extends BuiltinPalettes.Mocha {
@Override
public Color base() {
return new Color(0, 0, 0);
}
}

public class PaletteTests {
@Test
public void mochaExistsAndReturnsCorrectDetails() {
assertEquals("mocha to have the correct name", "mocha", Palette.MOCHA.name());
}

@Test
public void builtinMochaExistsAndReturnsCorrectDetails() {
BuiltinPalettes.Mocha palette = BuiltinPalettes.MOCHA;
assertEquals("mocha to have the correct name", "mocha", palette.name());
}

@Test
public void frappeExistsAndReturnsCorrectDetails() {
assertEquals("frappe to have the correct name", "frappe", Palette.FRAPPE.name());
}

@Test
public void builtinFrappeExistsAndReturnsCorrectDetails() {
BuiltinPalettes.Frappe palette = BuiltinPalettes.FRAPPE;
assertEquals("frappe to have the correct name", "frappe", palette.name());
}

@Test
public void macchiatoExistsAndReturnsCorrectDetails() {
assertEquals("macchiato to have the correct name", "macchiato", Palette.MACCHIATO.name());
}

@Test
public void builtinMacchiatoExistsAndReturnsCorrectDetails() {
BuiltinPalettes.Macchiato palette = BuiltinPalettes.MACCHIATO;
assertEquals("macchiato to have the correct name", "macchiato", palette.name());
}

@Test
public void latteExistsAndReturnsCorrectDetails() {
assertEquals("latte to have the correct name", "latte", Palette.LATTE.name());
}

@Test
public void builtinLatteExistsAndReturnsCorrectDetails() {
BuiltinPalettes.Latte palette = BuiltinPalettes.LATTE;
assertEquals("latte to have the correct name", "latte", palette.name());
}

@Test
public void oledOverridesProperly() {
Flavor mocha = Palette.MOCHA;
Flavor oled = new Oled();

assertEquals("oled red and mocha red to be the same", mocha.red(), oled.red());
assertEquals("oled base is 0, 0, 0", new Color(0, 0, 0), oled.base());
assertNotEquals("oled base and mocha base to not be the same", mocha.base(), oled.base());
}
}
File renamed without changes.
10 changes: 10 additions & 0 deletions sources/processing/pom.xml → processing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>javapoet</artifactId>
<version>1.13.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface GeneratedPalette {
public String target();
}
197 changes: 197 additions & 0 deletions processing/src/main/java/com/catppuccin/POJO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
package com.catppuccin;

import java.util.Map;

public class POJO {
public static class Root {
public Flavor latte;
public Flavor frappe;
public Flavor macchiato;
public Flavor mocha;

@Override
public String toString() {
return "Root { latte=%s, frappe=%s, macchiato=%s, mocha=%s}".formatted(latte, frappe, macchiato, mocha);
}
}

public class Flavor {
private String name;
private long order;
private boolean dark;
private Map<String, Color> colors;

public String getName() {
return name;
}

public void setName(String value) {
this.name = value;
}

public long getOrder() {
return order;
}

public void setOrder(long value) {
this.order = value;
}

public boolean isDark() {
return dark;
}

public boolean isLight() {
return !isDark();
}

public void setDark(boolean value) {
this.dark = value;
}

public Map<String, Color> getColors() {
return colors;
}

public void setColors(Map<String, Color> value) {
this.colors = value;
}

@Override
public String toString() {
return "Flavor { name=%s, order=%d, dark=%b, colors=%s }".formatted(name, order, dark, colors);
}
}

public class Color {
private String name;
private long order;
private String hex;
private RGB rgb;
private Hsl hsl;
private boolean accent;

public String getName() {
return name;
}

public void setName(String value) {
this.name = value;
}

public long getOrder() {
return order;
}

public void setOrder(long value) {
this.order = value;
}

public String getHex() {
return hex;
}

public void setHex(String value) {
this.hex = value;
}

public RGB getRGB() {
return rgb;
}

public void setRGB(RGB value) {
this.rgb = value;
}

public Hsl getHsl() {
return hsl;
}

public void setHsl(Hsl value) {
this.hsl = value;
}

public boolean getAccent() {
return accent;
}

public void setAccent(boolean value) {
this.accent = value;
}

@Override
public String toString() {
return "Color { name=%s, order=%d, hex=%s, rgb=%s, hsl=%s, accent=%b }".formatted(name, order, hex, rgb, hsl, accent);
}
}

public class Hsl {
private double h;
private double s;
private double l;

public double getH() {
return h;
}

public void setH(double value) {
this.h = value;
}

public double getS() {
return s;
}

public void setS(double value) {
this.s = value;
}

public double getL() {
return l;
}

public void setL(double value) {
this.l = value;
}

@Override
public String toString() {
return "HSL { %f %f %f }".formatted(h, s, l);
}
}

public class RGB {
private int r;
private int g;
private int b;

public int getR() {
return r;
}

public void setR(int value) {
this.r = value;
}

public int getG() {
return g;
}

public void setG(int value) {
this.g = value;
}

public int getB() {
return b;
}

public void setB(int value) {
this.b = value;
}

@Override
public String toString() {
return "RGB { %d %d %d }".formatted(r, g, b);
}
}
}
Loading

0 comments on commit c0d7cf6

Please sign in to comment.