Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript definitions #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
declare module 'warna' {
interface RGB {
red: number
green: number
blue: number
alpha?: number
}

interface HSV {
hue: number
saturation: number
value: number
alpha?: number
}

interface HSL {
hue: number
saturation: number
luminosity: number
alpha?: number
}

type Color = string | RGB | HSV | HSL

interface ParsedColor {
rgb: RGB
hex: string
hsv: string
hsl: string
alpha: number
}

export class Gradient {
constructor(begin: number, end: number)
static getPosition(pos: number): ParsedColor
static getSlices(
slice: number,
type: 'rgb' | 'hsv' | 'hsl' | undefined,
): ParsedColor[] | ((RGB[] | string[]) & { alpha: string })
}

export function darken(color: Color, pos: number): ParsedColor
export function lighten(color: Color, pos: number): ParsedColor
export function parse(color: Color): ParsedColor
}