Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('can change color', (done) => {
label.text = 'some blue text';
label.fontSize = 30;
label.color = ex.Color.Blue.clone();
expect(label.color.toString()).toBe(ex.Color.Blue.toString());
label.update(engine, 100);
label.draw(engine.ctx, 100);
expect(label.color.toString()).toBe(ex.Color.Blue.toString());
ensureImagesLoaded(engine.canvas, 'src/spec/images/LabelSpec/bluetext.png').then(([canvas, image]) => {
expect(canvas).toEqualImage(image, 1);
done();
});
});
it('can be drawn with actor', (done) => {
const edgeActor = new ex.Actor({
pos: new ex.Vector(150, 100),
color: ex.Color.Blue,
body: new ex.Body({
collider: new ex.Collider({
shape: ex.Shape.Edge(ex.Vector.Zero, new ex.Vector(300, 300))
})
})
});
scene.add(edgeActor);
scene.draw(engine.ctx, 100);
ensureImagesLoaded(engine.canvas, 'src/spec/images/CollisionShapeSpec/edge.png').then(([canvas, image]) => {
expect(canvas).toEqualImage(image);
done();
});
});
it('to enable bold text', (done) => {
label.text = 'some bold text';
label.fontFamily = 'Arial';
label.fontSize = 30;
label.color = ex.Color.Black;
label.bold = true;
label.draw(engine.ctx, 100);
ensureImagesLoaded(engine.canvas, 'src/spec/images/LabelSpec/boldtext-linux.png').then(([canvas, image]) => {
expect(canvas).toEqualImage(image, 0.98);
done();
});
});
x: 0,
y: 0,
width: 62,
height: 64,
rotation: 0,
anchor: new ex.Vector(0.0, 0.0),
scale: new ex.Vector(1, 1),
flipVertical: false,
flipHorizontal: false
});
sprite.lighten();
sprite.draw(engine.ctx, 0, 0);
ensureImagesLoaded(engine.canvas, 'src/spec/images/SpriteSpec/icon-lightened.png').then(([canvas, image]) => {
expect(canvas).toEqualImage(image);
done();
});
});
});
engine.currentScene.camera.zoom(0.2, 1000).then(() => {
ensureImagesLoaded(engine.canvas, 'src/spec/images/CameraSpec/zoomout.png').then(([canvas, image]) => {
expect(canvas).toEqualImage(image, 0.995);
done();
});
});
});
engine.currentScene.camera.zoom(5, 1000).then(() => {
ensureImagesLoaded(engine.canvas, 'src/spec/images/CameraSpec/zoomin.png').then(([canvas, image]) => {
expect(canvas).toEqualImage(image, 0.995);
done();
});
});
});
x: 0,
y: 0,
width: 62,
height: 64,
rotation: 0,
anchor: new ex.Vector(0.0, 0.0),
scale: new ex.Vector(1, 1),
flipVertical: false,
flipHorizontal: false
});
sprite.invert();
sprite.draw(engine.ctx, 0, 0);
ensureImagesLoaded(engine.canvas, 'src/spec/images/SpriteSpec/icon-inverted.png').then(([canvas, image]) => {
expect(canvas).toEqualImage(image);
done();
});
});
});
particleSprite: null,
emitterType: ex.EmitterType.Circle,
radius: 20,
particleRotationalVelocity: 3,
randomRotation: false,
random: new ex.Random(1337)
});
emitter.emitParticles(10);
emitter.update(engine, 100);
emitter.update(engine, 100);
emitter.update(engine, 100);
emitter.draw(engine.ctx);
ensureImagesLoaded(engine.canvas, 'src/spec/images/ParticleSpec/Particles.png').then(([canvas, image]) => {
expect(canvas).toEqualImage(image);
done();
});
});
});
x: 0,
y: 0,
width: 62,
height: 64,
rotation: 0,
anchor: new ex.Vector(0.0, 0.0),
scale: new ex.Vector(1, 1),
flipVertical: false,
flipHorizontal: false
});
sprite.darken();
sprite.draw(engine.ctx, 0, 0);
ensureImagesLoaded(engine.canvas, 'src/spec/images/SpriteSpec/icon-darkened.png').then(([canvas, image]) => {
expect(canvas).toEqualImage(image);
done();
});
});
});
y: 30,
cellWidth: 64,
cellHeight: 48,
rows: 3,
cols: 7
});
const spriteTiles = new ex.SpriteSheet(texture, 1, 1, 64, 48);
tm.registerSpriteSheet('default', spriteTiles);
tm.data.forEach(function(cell: ex.Cell) {
cell.solid = true;
cell.pushSprite(new ex.TileSprite('default', 0));
});
tm.draw(engine.ctx, 100);
ensureImagesLoaded(engine.canvas, 'src/spec/images/TileMapSpec/TileMap.png').then(([canvas, image]) => {
expect(canvas).toEqualImage(image);
done();
});
});
});