TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/OmarMtya/enginejs-module/llms.txt
Use this file to discover all available pages before exploring further.
Imagen class is the bridge between a browser Image object and Engine.js’s rendering pipeline. Wrap any HTMLImageElement in an Imagen instance, hand it to a Transform, and Engine.js will call drawImage on every frame — scaling the image to fit the figure’s anchura and altura dimensions automatically.
The Imagen Class
Imagen is a thin data container. It holds the image source and an optional Sprite instance (covered in Sprites). For static (non-animated) images, you only need the first argument.
| Parameter | Type | Required | Description |
|---|---|---|---|
src | HTMLImageElement | ✅ | A native browser Image object with its .src property set to a valid URL |
sprite | Sprite | ❌ | A Sprite instance for sprite-sheet animation. Pass null (or omit) for a static image |
Attaching an Image to a Figure
Create an HTMLImageElement
Use the browser’s built-in
Image constructor and set its src to the path of your asset.Wrap it in Imagen
Pass the
Image object as the first argument to $g.Imagen. Leave the second argument empty for a static image.Assign it to a Transform
Pass your
Imagen instance to the imagen property of a Transform. Set anchura and altura to control the rendered size on the canvas.Full Example
Here is a complete, self-contained example that places a 64 × 64 hero sprite on the canvas:How Engine.js Renders the Image
When a figure’stipo is 'imagen' and no Sprite is attached, Engine.js calls the following on every frame:
src.width × src.height) and then scaled to the figure’s transform.anchura × transform.altura on the canvas. Resize the figure by changing those two Transform properties.
Next Steps
Static images are great for backgrounds, tiles, and props that don’t move through frames. When you need frame-by-frame animation from a sprite sheet, see Sprites to learn how to use theSprite class together with Imagen.
Sprites
Animate sprite sheets with the
Sprite classTransform
All position, size, and appearance properties
Figures
Creating and registering figures in a scene
Imagen API
Full
Imagen and Sprite API reference