blend-text-core
v1.0.0
Published
Core utilities for BlendText library. Pure TypeScript with no DOM dependencies.
Downloads
10
Readme
@blend-text/core
Core utilities for BlendText library. Pure TypeScript with no DOM dependencies.
Functions
parseCssColor(input: string): RgbColor
Parses CSS color strings into RGB objects.
Supported formats:
- Hex:
#ff0000,#f00 - RGB:
rgb(255, 0, 0) - HSL:
hsl(0, 100%, 50%) - Named:
red,blue, etc.
interpolateRgb(a: RgbColor, b: RgbColor, t: number): RgbColor
Interpolates between two RGB colors.
t=0returns colorat=1returns colorb- Values are clamped to [0,1]
computeLayerTransforms(params: TransformParams): LayerTransform[]
Computes position and color for each text layer.
computeBounds(params: BoundsParams): Bounds
Calculates padding needed to prevent clipping.
Types
interface RgbColor {
r: number
g: number
b: number
}
interface LayerTransform {
x: number
y: number
color: string
strokeWidth?: number
isTop: boolean
}