Auto Draft

3
(2)
Created on September 03, 2019, Last modified on June 08, 2021

The lng.Tools class contains some useful functions for creating often used textures for:

  • rounded rectangles (lng.Tools.getRoundRect(w, h, radius, strokeWidth, strokeColor, fill, fillColor))
  • drop shadow rectangle (lng.Tools.getShadowRect(w, h, radius = 0, blur = 5, margin = blur * 2))
  • SVG rendering (lng.Tools.createSvg(cb, stage, url, w, h))
class TextureDemo extends lng.Application {
    static _template() {
        return {
            x: 50,
            y: 50,
            RoundRectangle: {
                zIndex: 2,
                texture: lng.Tools.getRoundRect(150, 40, 4, 3, 0xffff00ff, true, 0xff00ffff),
            },
            Shadow: {
                x: 10,
                y: 10,
                zIndex: 1,
                color: 0x66000000,
                texture: lng.Tools.getShadowRect(150, 40, 4, 10, 15),
            }
        }
    }
}

const options = {stage: {w: window.innerWidth, h: window.innerHeight, useImageWorker: false}};
const app = new TextureDemo(options);
document.body.appendChild(app.stage.getCanvas());

Give feedback

Rating - 3 / 5. . Reviews - 2

No votes so far! Be the first to rate this post.

Go To Top