effect-motion
API Referenceeffect-motionNamespacesImageVariables

Image

Image: <ID>(id) => ImageResource<ID>;

Variable: Image

Image: <ID>(id) => ImageResource<ID>;

Defined in: packages/motion/src/Image.ts:15

Declare an image your scene uses.

Type Parameters

Type Parameter
ID extends string

Parameters

ParameterTypeDescription
idID & EnsureLiteral<ID, "Image id must be a literal string">An identifier for this image, as a literal string.

Returns

ImageResource<ID>

Remarks

Follows the same two-faced contract as Font.Font: yield* the constant in a scene to get the reference for an Image entity, and pair it with layer to provide the encoded bytes. Yielding is what puts the requirement into the scene's type.

Example

const Logo = Image.Image("logo");

const scene = Scene.make(function* () {
	const logo = yield* Logo;
	yield* Scene.instantiate("Image", { image: logo, width: 200, height: 80 });
});

On this page