react-pdf-builder
Version:
Build beautiful PDF documents in React.
67 lines (66 loc) • 2.11 kB
TypeScript
/**
* Class with utility functions for working with gradients.
*/
export declare class Gradients {
/**
* Converts string gradient colors to proper gradient stops with offset percentages, and ensures at least 2 gradient stops are present.
*
* Returns a GradientStop[] array.
*/
static normalizeGradientStops(gradient?: GradientStop[] | string[]): GradientStop[];
/**
* Converts a gradient type to an object with coordinates.
*/
static toGradientCoords(gradientType: GradientType): {
x1: number;
y1: number;
x2: number;
y2: number;
};
/**
* The underlying library seems to have an issue with `0` and `1` values for linear gradients. This adjusts them slightly.
*/
static safeLinearCoords(coords: {
x1: number;
y1: number;
x2: number;
y2: number;
}): {
x1: number;
y1: number;
x2: number;
y2: number;
};
/**
* The underlying library seems to have an issue with `0` and `1` values for radial gradients. This adjusts them slightly.
*/
static safeRadialCoords(coords: {
x: number;
y: number;
}): {
cx: number;
cy: number;
};
}
/**
* Read the [documentation for GradientType](https://justinmahar.github.io/react-pdf-builder/?path=/docs/documentation-components-gradientbackdrop--docs)
*/
export declare enum GradientType {
leftToRight = "leftToRight",
rightToLeft = "rightToLeft",
topToBottom = "topToBottom",
bottomToTop = "bottomToTop",
topLeftToBottomRight = "topLeftToBottomRight",
bottomLeftToTopRight = "bottomLeftToTopRight",
bottomRightToTopLeft = "bottomRightToTopLeft",
topRightToBottomLeft = "topRightToBottomLeft",
radial = "radial"
}
/**
* Read the [documentation for GradientStop](https://justinmahar.github.io/react-pdf-builder/?path=/docs/documentation-components-gradientbackdrop--docs#gradient-stops)
*/
export interface GradientStop {
offset: string | number;
stopColor: string;
stopOpacity?: string | number;
}