
import { TinyColor } from "./color.uts";
import { UxColorOptions, UxColorInput } from '../../types/color.uts';

export class Color {
	
	/**
	 * 实例颜色类
	 * @param color UxColorInput 任意颜色值
	 * @param opts UxColorOptions 颜色配置
	 */
	newColor(color : UxColorInput = '', opts : UxColorOptions = {} as UxColorOptions) : TinyColor {
		return new TinyColor(color, opts);
	}
	
	/**
	 * 随机颜色组
	 * @param len 指定数量 默认 10
	 */
	randomColors(len: number | null): string[] {
		let random = (min : number, max : number) : number => {
			if (min >= 0 && max > 0 && max >= min) {
				const gab = max - min + 1
				return Math.floor(Math.random() * gab + min)
			}
		
			return 0
		}
		
		let count = len ?? 10
		
		let _colors: string[] = [
			"#F53F3F",
			"#F99057",
			"#F7BA1E",
			"#FADC19",
			"#B5E241",
			"#00B42A",
			"#07828B",
			"#206CCF",
			"#7BC0FC",
			"#A871E3",
			"#F08EE6",
			"#CB1E83",
			"#93D1B3",
			"#FCFDC7",
			"#539BF9",
		]
		
		let colors: string[] = []
		for (let i = 0; i < count; i++) {
			colors.push(_colors[random(0, _colors.length - 1)])
		}
		
		return colors
	}
}

