Author Topic: Getting complementary colors using scripting  (Read 222 times)

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7565
    • View Profile
Getting complementary colors using scripting
« on: July 28, 2021, 06:14:46 PM »
Sample code:

Code
using UnityEngine;
using ColorStudio;

public class PaletteSample : MonoBehaviour
{
    void Start()
    {
        CSPalette palette = ScriptableObject.CreateInstance<CSPalette>();
        palette.ConfigurePalette(ColorScheme.SplitComplementary, Color.red);
        palette.BuildHueColors();

        for (int k=0;k<palette.colorsCount;k++) {
            Debug.Log(palette.colors[k]);
        }
    }

}

The code above creates a new palette with 3 colors using the Split Complementary scheme (a primary plus 2 complementary colors).
The primary colors is always at index 0 of palette.colors array. And the other 2 key colors (the complementaries) are in index 1 and 2. You will get more or less key colors depending on the chosen scheme.

« Last Edit: July 28, 2021, 06:22:14 PM by Kronnect »