node-i2djs
  • Introduction to node-i2djs
  • Getting Started
    • Installation
    • Quick Start CanvasLayer
    • Quick Start Canvas PDF Layer
    • Examples
  • API Reference
    • canvasLayer
    • canvasPdfLayer
    • Element API
    • Textures
    • Path
    • Join Action
  • Guide
    • Element types
    • Data Join-Actions
    • Canvas: Textures & Sprite animation
    • Canvas: Clipping, Masking, Pattern
Powered by GitBook
On this page
  1. API Reference

Textures

Node-i2djs allows for pre-creation of textures by loading images or custom canvas textures as bitmaps, which can then be used for rendering. The texture APIs support texture manipulations such as clipping, filters, and more.

node-I2Djs provides createTexture and createAsyncTexture, API as part of CanvasLayer.

Also, these APIs support multi image, setting src with an array of image URL.

Layer.createTexture(); - Creates texture instance. Returns Texture instance.

let textureInstance = canvasLayerInstance.createTexture({
                attr: {
                    src: "../images/coinSprite.png",
                    width: 45,
                    height: 45,
                    clip: {
                        sx: 0,
                        sy: 0,
                        swidth: 44,
                        sheight: 40,
                    },
                    onload: function () {},
                    onerror: function () {}
                },
            });

var img = canvasLayerInstance.createEl({
	el: 'image',
	attr: {
		src: textureInstance,
		width: 100,
		height: 100,
		x: 300,
		y: 0
	}
});
PreviousElement APINextPath

Last updated 2 years ago