@bitbybit-dev/base
Version:
Bit By Bit Developers Base CAD Library to Program Geometry
130 lines (129 loc) • 4.53 kB
TypeScript
import * as Inputs from "../inputs";
import { MathBitByBit } from "./math";
export declare class Color {
private readonly math;
constructor(math: MathBitByBit);
/**
* Creates and returns a hex color string (pass-through for color input).
* Example: '#FF5733' → '#FF5733'
* @param inputs Color hex
* @returns color string
* @group create
* @shortname color
* @drawable false
*/
hexColor(inputs: Inputs.Color.HexDto): Inputs.Base.Color;
/**
* Converts hex color to RGB object with r, g, b values (0-255 range).
* Example: '#FF5733' → {r: 255, g: 87, b: 51}
* @param inputs Color hex
* @returns rgb color
* @group convert
* @shortname hex to rgb
* @drawable false
*/
hexToRgb(inputs: Inputs.Color.HexDto): Inputs.Base.ColorRGB;
/**
* Converts RGB values to hex color string (supports custom min/max ranges, auto-remaps to 0-255).
* Example: r=255, g=87, b=51 with range [0,255] → '#ff5733'
* Example: r=1, g=0.5, b=0.2 with range [0,1] → '#ff7f33'
* @param inputs Color hext
* @returns hex color
* @group convert
* @shortname rgb to hex
* @drawable false
*/
rgbToHex(inputs: Inputs.Color.RGBMinMaxDto): Inputs.Base.Color;
/**
* Converts RGB object to hex color string (supports custom min/max ranges).
* Example: {r: 1, g: 0.5, b: 0.2} with range [0,1] → '#ff7f33'
* @param inputs Color hext
* @returns hex color string
* @group convert
* @shortname rgb obj to hex
* @drawable false
*/
rgbObjToHex(inputs: Inputs.Color.RGBObjectMaxDto): Inputs.Base.Color;
/**
* Converts hex color to RGB and remaps values to a custom range.
* Example: '#FF5733' mapped to [0,1] → {r: 1, g: 0.341, b: 0.2}
* Example: '#FF5733' mapped to [0,100] → {r: 100, g: 34.1, b: 20}
* @param inputs Color hext
* @returns rgb color
* @group convert
* @shortname hex to rgb mapped
* @drawable false
*/
hexToRgbMapped(inputs: Inputs.Color.HexDtoMapped): Inputs.Base.ColorRGB;
/**
* Extracts the red channel value from hex color (can be mapped to custom range).
* Example: '#FF5733' with range [0,1] → 1
* @param inputs Color hext
* @returns rgb color
* @group hex to
* @shortname red
* @drawable false
*/
getRedParam(inputs: Inputs.Color.HexDtoMapped): number;
/**
* Extracts the green channel value from hex color (can be mapped to custom range).
* Example: '#FF5733' with range [0,1] → 0.341
* @param inputs Color hext
* @returns rgb color
* @group hex to
* @shortname green
* @drawable false
*/
getGreenParam(inputs: Inputs.Color.HexDtoMapped): number;
/**
* Extracts the blue channel value from hex color (can be mapped to custom range).
* Example: '#FF5733' with range [0,1] → 0.2
* @param inputs Color hext
* @returns blue param
* @group hex to
* @shortname blue
* @drawable false
*/
getBlueParam(inputs: Inputs.Color.HexDtoMapped): number;
/**
* Extracts the red channel value from RGB object.
* Example: {r: 255, g: 87, b: 51} → 255
* @param inputs Color rgb
* @returns red param
* @group rgb to
* @shortname red
* @drawable false
*/
rgbToRed(inputs: Inputs.Color.RGBObjectDto): number;
/**
* Extracts the green channel value from RGB object.
* Example: {r: 255, g: 87, b: 51} → 87
* @param inputs Color rgb
* @returns green param
* @group rgb to
* @shortname green
* @drawable false
*/
rgbToGreen(inputs: Inputs.Color.RGBObjectDto): number;
/**
* Extracts the blue channel value from RGB object.
* Example: {r: 255, g: 87, b: 51} → 51
* @param inputs Color rgb
* @returns blue param
* @group rgb to
* @shortname blue
* @drawable false
*/
rgbToBlue(inputs: Inputs.Color.RGBObjectDto): number;
/**
* Inverts a hex color (flips RGB channels: 255-r, 255-g, 255-b).
* With blackAndWhite=true → returns '#000000' or '#ffffff' based on brightness.
* Example: '#FF5733' → '#00a8cc', '#FF5733' with blackAndWhite=true → '#ffffff'
* @param inputs hex color and black and white option
* @returns inverted color
* @group hex to
* @shortname invert color
* @drawable false
*/
invert(inputs: Inputs.Color.InvertHexDto): Inputs.Base.Color;
}