@diffusionstudio/core-v4
Version:
2D motion graphics and video rendering engine
300 lines (299 loc) • 5.36 kB
TypeScript
import { hex, Percent } from '../types';
import { FontStyle, FontWeight, GradientType, LineCap, LineJoin, PatternRepetition, TextAlign, TextBaseline } from './types';
/**
* Defines the properties of a point
*/
export interface Point {
/**
* The x coordinate of the point
*/
x: number;
/**
* The y coordinate of the point
*/
y: number;
}
export interface RelativePoint {
/**
* The x coordinate of the point
*/
x: number | Percent;
/**
* The y coordinate of the point
*/
y: number | Percent;
}
/**
* Defines the properties of a rectangle
*/
export interface Rect extends Partial<Point> {
/**
* The width of the rectangle
*/
width: number;
/**
* The height of the rectangle
*/
height: number;
}
/**
* Defines the properties of a rounded rectangle
*/
export interface RoundRect extends Rect {
/**
* The radius of the rounded corners
*/
radius?: number;
}
/**
* Defines the properties of a circle
*/
export interface Circle {
/**
* The x coordinate of the circle
*/
cx: number;
/**
* The y coordinate of the circle
*/
cy: number;
/**
* The radius of the circle
*/
radius: number;
}
/**
* Defines a circle with a width and height
*/
export interface Ellipse {
/**
* The x coordinate of the ellipse
*/
cx: number;
/**
* The y coordinate of the ellipse
*/
cy: number;
/**
* The width of the ellipse
*/
width: number;
/**
* The height of the ellipse
*/
height: number;
}
/**
* Defines the stroke properties that
* can be applied to a shape
*/
export interface Stroke {
/**
* The color of the stroke
*/
color?: hex;
/**
* The width of the stroke
*/
width?: number;
/**
* The line cap style to use
*/
lineCap?: LineCap;
/**
* The line join style to use
*/
lineJoin?: LineJoin;
/**
* The miter limit to use
*/
miterLimit?: number;
/**
* The opacity of the stroke
*/
opacity?: number;
}
/**
* Defines the shadow properties that
* can be applied to a shape
*/
export interface Shadow {
/**
* The color of the shadow
*/
color?: hex;
/**
* The horizontal offset of the shadow
*/
offsetX?: number;
/**
* The vertical offset of the shadow
*/
offsetY?: number;
/**
* The blur of the shadow
*/
blur?: number;
/**
* The opacity of the shadow
*/
opacity?: number;
}
/**
* Defines the fill properties that
* can be applied to a shape
*/
export interface FillOptions {
/**
* The color of the fill
*/
color: hex | Gradient | Pattern;
/**
* The opacity of the fill
*/
opacity?: number;
}
/**
* Defines the properties of a gradient stop
*/
export interface GradientStop {
/**
* The offset of the gradient stop
*/
offset: number;
/**
* The color of the gradient stop
*/
color: string;
}
/**
* Defines the properties of a gradient
*/
export interface Gradient {
/**
* The type of gradient to use
*/
type: GradientType;
/**
* The stops of the gradient
*/
stops: GradientStop[];
}
/**
* Defines the properties of a pattern
*/
export interface Pattern {
/**
* The image to use for the pattern
*/
image: HTMLImageElement | HTMLCanvasElement;
/**
* The repetition of the pattern
*/
repetition: PatternRepetition;
}
/**
* Defines the properties of an image
*/
export interface ImageOptions {
/**
* The x coordinate of the image
*/
x?: number;
/**
* The y coordinate of the image
*/
y?: number;
/**
* The width of the image
*/
width: number;
/**
* The height of the image
*/
height: number;
/**
* The rotation of the image in degrees
*/
rotation?: number;
}
/**
* Defines the properties of a font
*/
export interface Font {
/**
* The size of the font
*/
size: number;
/**
* The family of the font
*/
family: string;
/**
* The weight of the font
*/
weight?: FontWeight;
/**
* The style of the font
*/
style?: FontStyle;
}
/**
* Defines the properties of text
*/
export interface TextOptions {
/**
* The font to use
*/
font?: Font;
/**
* The color of the text
*/
color?: string;
/**
* The alignment of the text
*/
alignment?: TextAlign;
/**
* The baseline of the text
*/
baseline?: TextBaseline;
}
/**
* Defines the properties of a transform
*/
export interface Transform {
/**
* The translation of the transform
*/
translate?: Point;
/**
* The scale of the transform
*/
scale?: Point;
/**
* The rotation of the transform
*/
rotate?: number;
}
/**
* Defines the properties of a glow
*/
export interface Glow {
/**
* The color of the glow
*/
color?: hex;
/**
* The radius of the glow
*/
radius?: number;
/**
* The intensity of the glow
*/
intensity?: number;
/**
* The opacity of the glow
*/
opacity?: number;
}