Layers
The native elements a frame is made of, how to group and stack them, and how to clip, mask and blend them.
A frame is a stack of layers, drawn bottom to top. Each element you write, such as Rect, Text or Image, is one layer, and a Layer groups several.
import { AbsoluteFill, Layer, Rect, Text, dropShadow, linearGradient } from '@kinetographdev/core';
export const Card = () => (
<AbsoluteFill style={{ backgroundColor: '#14171f' }}>
<Layer x={320} y={180} effects={[dropShadow({ y: 12, blur: 24, color: '#00000060' })]}>
<Rect width={640} height={360} radius={32} fill={linearGradient(['#f9a8d4', '#fcd34d'], { angle: 160 })} />
<Text font="DM Sans" size={72} color="#14171f" x={48} y={140}>Layers</Text>
</Layer>
</AbsoluteFill>
);Later children are drawn over earlier ones. x and y move a layer inside its parent, so the children of the Layer above move with it.
The elements
Layer (a group), Rect, Ellipse, Path, Shape, Text (in a registered font), Image (see Assets), Video, Gif, Audio, Noise, MeshGradient, Canvas, GlslShader (see Shaders), Lottie and Scene3D (see Transforms). <div>, className, stylesheets and SVG work too, and the engine draws them; use the native elements for new work.
Every element takes id, x, y, scale, rotation, opacity, blendMode, effects, clip, mask, matte and motionBlur. The position and turn props are on Transforms. Give an id to a layer that a matte uses.
Group and arrange
Layer with layout places its children with flexbox, using CSS's names:
import { Layer, Rect } from '@kinetographdev/core';
export const Row = () => (
<Layer layout={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center', gap: 24, width: 1280, height: 400 }}>
<Rect width={200} height={120} fill="#f6c177" />
<Rect width={200} height={120} fill="#9ccfd8" layoutItem={{ flexGrow: 1 }} />
<Rect width={20} height={20} fill="#eb6f92" layoutItem={{ position: 'absolute' }} />
</Layer>
);The options are in the scene format.
Clip, mask and matte
Three props cut a layer.
import { Image, Layer, Text, radialGradient, staticFile } from '@kinetographdev/core';
export const Cutouts = () => (
<Layer>
<Image src={staticFile('images/photo.jpg')} width={320} height={240} clip={{ kind: 'inset', left: 40, radius: 16 }} />
<Image
src={staticFile('images/photo.jpg')}
width={320}
height={240}
x={360}
mask={{ mode: 'luminance', gradient: radialGradient(['#ffffff', '#000000']) }}
/>
<Image src={staticFile('images/photo.jpg')} width={320} height={240} x={720} matte={{ layer: 'word', mode: 'alpha' }} />
<Text id="word" font="DM Sans" size={120} color="#ffffff" x={720}>Wave</Text>
</Layer>
);clipcuts to a shape:polygon,inset,ellipseorpath. Its numbers can animate.maskfades the layer by a gradient.mode: 'alpha'keeps it where the gradient is opaque, and'luminance'where it is light.mattecuts the layer by another layer, the matte source, named byid. The source must be a sibling and is not drawn on its own.
Blend modes
blendMode takes the 16 modes of CSS, such as multiply, screen and overlay.
Suggested prompt
/kinetograph-markupPut the photo in a rounded card with a drop shadow, and cut the title out of it with a matte. Check it with strip.
What works
- Drawn natively: all the elements above, flexbox layout,
clip,mask,matte, the 16 blend modes and effects. - Approximated: a
backdrop-filteron a turned element, and groups that cross in 3D, are drawn as close as the engine can. These are reported. - Not supported:
<IFrame>, which needs a browser. A basic shape such asinset()asclip-pathinside an<svg>is not drawn. doctorgoes through every frame and lists each element and property that cannot be drawn, with its frames. See What works.