Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 1.36 KB

readme.md

File metadata and controls

46 lines (34 loc) · 1.36 KB

Image

Image rendering.

Image example

Examples

// This will override the native Image class !
import { Image } from "pencil.js";

const position = [100, 200];
const url = "url/to/my/file.png";
const options = {
    fill: "black",
    description: "Cutest cat ever !"
};
const image = new Image(position, url, options);
image.on("ready", () => {
    console.log("Image is loaded");
});

// Can be use to preload a bunch of images
Image.load([url1, url2, url3]).then(() => {
    console.log("Images ready");
});

Be aware that this example overrides Javascript's Image global. Use namespace to avoid this issue.

import * as Namespace from "@pencil.js/image";
new Namespace.Image();

ImageOptions

Inherit from RectangleOptions.

Name Type Default Comment
fill Color or String null Background color for transparent images
tint Color null Multiply the image pixels with a color
description String "" Accessibility description of the image