Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var $sp1 = $Painter.add({
content: {
// 异步加载,这里取到的cacheCanvas应该是true
// 便于项目中“按需加载”
img: constants.png10px,
},
style: {
left: 10, top: 0,
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',
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();
Easycanvas.ImgLoader.cacheCanvas = false;
var $sp1 = $Painter.add({
content: {
// 异步加载,这里取到的cacheCanvas应该是true
// 便于项目中“按需加载”
img: constants.png10px,
},
style: {
left: 10, top: 0,
locate: 'lt',
},
});
var $sp2 = $Painter.add({
content: {
img: $Painter.imgLoader(constants.png10px + ' ', null, {canvas: true}),
},
style: {
left: 20, top: 0,
locate: 'lt',
},
});
import Easycanvas from 'src/index.js';
import constants from 'karma/case.constant.js';
var $canvas = document.createElement('canvas');
$canvas.width = 888;
$canvas.height = 888;
var $Painter = new Easycanvas.Painter();
$Painter.register($canvas);
$Painter.start();
var sprite1, obj;
Easycanvas.ImgLoader(constants.png10px, function (img) {
obj = {
name: 'root',
content: {
img: img,
},
style: {
locate: 'lt',
cutLeft: 0,
left: undefined, top: 77,
},
};
sprite1 = $Painter.add(obj);
});
describe('Featrue.add Test.', function () {
it('Default value correctly.', function (done) {
left: 0, top: 0,
},
hooks: {
beforeTick () {
this.style.left++;
},
}
},
],
});
var sprite2 = sprite1.children[0];
var sprite3 = $Painter.add({
content: {
img: constants.png10px,
},
style: {
left: 0, top: 0,
},
});
sprite2.on('custom', (number) => {
sprite2.style.top = number;
});
sprite3.on('custom', (number) => {
sprite3.style.top = number;
});
sprite3.on('fromSelf', (number) => {
sprite3.style.zIndex = 30;
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 = $Painter.add({
content: {
img: constants.png10px,
},
style: {
left: Math.random() * 100, top: Math.random() * 100,
},
children: [
{
style: {
left: 0, top: 0,
},
hooks: {
beforeTick () {
this.style.left++;
},
}
},
],