package com.example.FinanceTracker.Components;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

@Component
public class ColourComponent {

    public static int[] RED = { 255, 0, 0 };
    public static int[] GREEN = { 0, 255, 0 };
    public static int[] BLUE = { 0, 0, 255 };

    public List<int[]> getLighterColours(int[] rgb) throws Exception {

        List<int[]> rgbValues = new ArrayList<>();

        if (rgb.length != 3) {
            throw new Exception("RGB does not meet required length of 3");
        }

        while ((rgb[0] != 255) || (rgb[1] != 255) || (rgb[2] != 255)) {
            rgbValues.add(rgb.clone());

            if (rgb[0] > 255 || rgb[1] > 255 || rgb[2] > 255) {
                throw new Exception("An RGB attribute if greater than 255");
            }

            rgb[0] = rgb[0] + 10;
            rgb[1] = rgb[1] + 10;
            rgb[2] = rgb[2] + 10;

            if (rgb[0] >= 255)
                rgb[0] = 255;
            if (rgb[1] >= 255)
                rgb[1] = 255;
            if (rgb[2] >= 255)
                rgb[2] = 255;

        }

        return rgbValues;

    }


    public void convertToArrayOfShades(List<int[]> rgbColour){
        ArrayList<String> colours = new ArrayList<>();

        try {
            for (int[] colour : rgbColour) {
                colours.add("rgb(" + colour[0] + "," + colour[1] + "," + colour[2] + ")");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
