Image Layers Renderer
The Image Layers Renderer is a plugin designed to work with the Image Layers Generator of the Art Engine. Its purpose is to take the output generated by the Image Layers Generator, which consists of item attributes and their corresponding layered images, and render those layered images into temporary files. These temporary files can then be utilized for further processing or artwork creation.
Adding the plugin
- Import the plugin object:
const { ArtEngine, renderers } = require("@hashlips-lab/art-engine");
- Setup a base path:
const BASE_PATH = __dirname;
- Add the plugin to an instance of the Art Engine:
const ae = new ArtEngine({
cachePath: `${BASE_PATH}/cache`,
outputPath: `${BASE_PATH}/output`,
useCache: false,
renderers: [
new renderers.ImageLayersRenderer({
width: 2048, // Specify the width of the rendered image
height: 2048, // Specify the height of the rendered image
});
// Add more renderers if needed...
]
// Add inputs, generators, and exporters as required...
});
Parameters
width
(number): The width of the rendered image in pixels.height
(number): The height of the rendered image in pixels.imageProcessor
(optional): An optional custom image processor that implements theImageProcessorInterface
. If not provided, the defaultSharpImageProcessor
will be used.
Interfaces
Base
This plugin adheres to the base renderer interface called RendererInterface<RendererDataType>
.
Custom
The Image Layers Renderer plugin serves as a prime example of a renderer in the Art Engine ecosystem. It adheres to the core renderer interface and specializes in producing static layered images based on the provided attributes.
The StaticLayeredImagesRendererInterface is a custom interface specifically crafted for the Image Layers Renderer. It encapsulates the structure of rendered static layered images:
export default interface StaticLayeredImagesRendererInterface {
path: string;
}
The Image Layers Renderer class is defined as follows:
export class ImageLayersRenderer
implements RendererInterface<StaticLayeredImagesRendererInterface> {
// Implementation details
}
This interface indicates that the rendered output consists of an image file path representing the static layered image.
The Image Layers Renderer leverages the provided attributesGetter
to access the data generated by the Image Layers Attributes Generator. By processing this data, the renderer assembles and renders the desired static layered images.