How to use the karma/case.constant.js.png30px function in karma

To help you get started, we’ve selected a few karma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github c-zhuo / easycanvas / test / cases / feature.scale.js View on Github external
import Easycanvas from 'src/index.js';
import constants from 'karma/case.constant.js';

var $canvas = document.createElement('canvas');
$canvas.width = 888;
$canvas.height = 888;
document.body.appendChild($canvas);

var $Painter = new Easycanvas.Painter();
$Painter.register($canvas);
$Painter.start();

var sprite1;

Easycanvas.ImgLoader(constants.png30px, function (img) {
    sprite1 = $Painter.add({
        // $children[0]
        content: {
            img: img,
        },
        style: {
            left: 100, top: 100,
            width: 30, height: 30,
            locate: 'lt',
            scale: 5, // scale中心为115, 115
        },
        children: [
            {
                // $children[1]
                content: {
                    img: img,
github c-zhuo / easycanvas / test / cases / feature.perf-jumpRenderOfCoveredSprite.js View on Github external
Easycanvas.ImgLoader(constants.png30px, function (img) {
    // 跳过绘制0个
    sprites.type5 = [];
    for (var i = 0; i < 32; i++) {
        var sprite = $Painter.add({
            content: {
                img: i % 2 ? img : constants.png30px,
            },
            style: {
                left: 200, top: 200,
                width: 200, height: 300,
                zIndex: 5,
            },
        });
        sprites.type5.push(sprite);
    }
});
github c-zhuo / easycanvas / test / cases / feature.perf-jumpRenderOfCoveredSprite.js View on Github external
content: {
                img: i % 2 ? img : constants.jpg100px,
            },
            style: {
                left: 200, top: 200,
                width: 200, height: 300,
                opacity: 0.6,
                zIndex: 4,
            },
        });
        sprites.type4.push(sprite);
    }
});

Easycanvas.ImgLoader.cacheCanvas = false;
Easycanvas.ImgLoader(constants.png30px, function (img) {
    // 跳过绘制0个
    sprites.type5 = [];
    for (var i = 0; i < 32; i++) {
        var sprite = $Painter.add({
            content: {
                img: i % 2 ? img : constants.png30px,
            },
            style: {
                left: 200, top: 200,
                width: 200, height: 300,
                zIndex: 5,
            },
        });
        sprites.type5.push(sprite);
    }
});
github c-zhuo / easycanvas / test / cases / feature.load-img.js View on Github external
locate: 'lt',
    },
});

var $sp2 = $Painter.add({
    content: {
        img: $Painter.imgLoader(constants.png10px + '   ', null, {canvas: true}),
    },
    style: {
        left: 20, top: 0,
        locate: 'lt',
    },
});

var $sp3;
ImgLoader(constants.png30px, function (img) {
    $sp3 = $Painter.add({
        content: {
            img: img,
        },
        style: {
            left: 30, top: 0,
            locate: 'lt',
        },
    });
});

// 最后改成canvas,并不影响之前$sp1的类型为<img>,$sp3用的还是<img>标签
// 需要注意的是,$sp1是在add阶段进行string2img的替换,此时已经替换完毕
Easycanvas.ImgLoader.cacheCanvas = true;

describe('Feature.load-img Test.', function () {
github c-zhuo / easycanvas / test / cases / feature.perf-jumpRenderOfCoveredSprite.js View on Github external
content: {
                img: img,
            },
            style: {
                left: 200, top: 200,
                width: 400, height: 300,
                opacity: 0.5,
                zIndex: 1,
            },
        });
        sprites.type1.push(sprite);
    }
});

Easycanvas.ImgLoader.cacheCanvas = false;
Easycanvas.ImgLoader(constants.png30px, function (img) {
    // 跳过绘制4个
    sprites.type2 = [];
    for (var i = 0; i &lt; 4; i++) {
        var sprite = $Painter.add({
            content: {
                img: img,
            },
            style: {
                left: 200, top: 200,
                width: 200, height: 300,
                zIndex: 2,
            },
        });
        sprites.type2.push(sprite);
    }
});
github c-zhuo / easycanvas / test / cases / feature.rendering.js View on Github external
import Easycanvas from 'src/index.js';
import constants from 'karma/case.constant.js';

var $canvas = document.createElement('canvas');
$canvas.width = 888;
$canvas.height = 888;
document.body.appendChild($canvas);

var $Painter = new Easycanvas.Painter();
$Painter.register($canvas);
$Painter.start();

var sprite1;

Easycanvas.ImgLoader(constants.png30px, function (img) {
    sprite1 = $Painter.add({
        name: '0',
        content: {
            img: img,
        },
        style: {
            left: 100, top: 100,
            locate: 'lt',
            opacity: 0.5,
            rotate: 40,
        },
        events: {
            click: function () {
                console.log(3);
            }
        },