Addon for Godot Engine 4.4+ (Mono/.NET enabled) that allows you to create beautiful palettes with a simple and intuitive custom resource. Color generation is based on the cosine formula greatly inspired by Inigo Quilez article.
Recommended way to install Cosineful Palettes is through GodotEnv. In your addons.jsonc file add:
{
"addons": {
// ... other addons ...
"cosineful_palettes": {
"url": "https://github.com/maxusify/cosineful-palettes",
"subfolder": "addons/cosineful_palettes"
}
}
}After that you can install the addon by running:
godotenv addons install
dotnet buildMake sure you have BUILT the project and ENABLED addon in your Godot project settings!
You can create CosinefulPalette resource through editor inspector:
If you want to create CosinefulPalette resource programmatically, you can use the Create method:
CosinefulPalette palette = CosinefulPalette.Create(
brightness: new Vector3(0.25f, 0.25f, 0.25f),
contrast: new Vector3(0.33f, 0.33f, 0.33f),
frequency: new Vector3(0.5f, 0.5f, 0.5f),
range: new Vector3(0.5f, 0.5f, 0.5f)
);If random outcome is desired, simply use empty Create method:
CosinefulPalette palette = CosinefulPalette.Create();You can also query the palette as follows:
using CosinefulPalettes;
using Godot;
public partial class MyNode : Node
{
[Export] public CosinefulPalette Palette { get; set; } = null!;
public override void _Ready()
{
// Query the palette using offset value
// 0.5f means middle of the gradient.
Color colorFromOffset = Palette.GetColor(0.5f);
// Query the palette using index value.
// Here we are querying color with index of 1.
Color colorFromIndex = Palette.GetColor(1);
// Query all colors in the palette.
Color[] colors = Palette.GetColorsArray();
// Query the palette as a gradient.
Gradient gradient = Palette.GetColorsGradient();
// We can randomize the palette and get new colors.
Palette.Randomize(1337);
// .. or we can set the component values ourselves.
Palette.Brightness = new Vector3(0.25f, 0.25f, 0.25f);
Palette.Contrast = new Vector3(0.33f, 0.33f, 0.33f);
Palette.Frequency = new Vector3(0.5f, 0.5f, 0.5f);
Palette.Range = new Vector3(0.5f, 0.5f, 0.5f);
// ...
}
}
