-
Notifications
You must be signed in to change notification settings - Fork 0
Style
hhh edited this page Mar 16, 2020
·
8 revisions
/**
* The interface of canvas style properties
*/
interface CanvasStyle {
/**
* @default null
*/
fillStyle: null | string | CanvasGradient | CanvasPattern;
/**
* @default null
*/
strokeStyle: null | string | CanvasGradient | CanvasPattern;
/**
* @default 1
*/
lineWidth: number;
/**
* @default 'butt'
*/
lineCap: CanvasLineCap;
/**
* @default 'miter'
*/
lineJoin: CanvasLineJoin;
/**
* @default 0
*/
lineDashOffset: number;
/**
* @default null
*/
lineDash: null | number[];
/**
* @default 10
*/
miterLimit: number;
/**
* @default 'inherit'
*/
direction: CanvasDirection;
/**
* @default '18px sans-serif'
*/
font: string;
/**
* @default 'left'
*/
textAlign: CanvasTextAlign;
/**
* @default 'top'
*/
textBaseline: CanvasTextBaseline;
/**
* @default null
*/
shadowColor: null | string;
/**
* @default 0
*/
shadowBlur: number;
/**
* @default 0
*/
shadowOffsetX: number;
/**
* @default 0
*/
shadowOffsetY: number;
/**
* @default 1
*/
opacity: number;
/**
* The canvas pixel ratio
* @default window.devicePixelRatio
*/
ratio: number;
/**
* When this is set, the bounds of the node will be rendered
* (useful for debugging)
* @default null
*/
boundsStyle: null | string | CanvasGradient | CanvasPattern;
/**
* @default 1
*/
boundsWidth: number;
/**
* @default 'miter'
*/
boundsJoin: CanvasLineJoin;
/**
* @default 0
*/
boundsDashOffset: number;
/**
* @default null
*/
boundsDash: null | number[];
/**
* @default 1
*/
boundsOpacity: number;
}
namespace Style {
/**
* The defaults of canvas styles (mutable)
*/
const defaults: CanvasStyle;
/**
* Apply the style to the canvas context
* (bounds styles are ignored; use `Style.applyBounds` if needed)
*/
const apply: (context: CanvasRenderingContext2D, style: CanvasStyle) => void;
/**
* Apply bounds style to the canvas context
*/
const applyBounds: (context: CanvasRenderingContext2D, style: CanvasStyle) => void;
/**
* Compute the style properties from the child's and its parent's styles
*/
const compute: (output: CanvasStyle, parentStyle: CanvasStyle, childStyle: Partial<CanvasStyle>) => void;
}