mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 02:37:59 +08:00

Update approach of dealing with file extensions differences between typescript & node. Leverages `rewriteRelativeImportExtensions` that was added in typescript 5.7 [1], and that is recommended path by node to run typescript in the future [2] [1] https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-7.html#path-rewriting-for-relative-paths [2] https://nodejs.org/api/typescript.html#type-stripping
46 lines
966 B
TypeScript
46 lines
966 B
TypeScript
import { assert } from 'chai';
|
|
|
|
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
|
|
|
|
describe('Noise', function () {
|
|
// ======================================================
|
|
it('noise tween', function (done) {
|
|
var stage = addStage();
|
|
|
|
loadImage('darth-vader.jpg', (imageObj) => {
|
|
var layer = new Konva.Layer();
|
|
const darth = new Konva.Image({
|
|
x: 10,
|
|
y: 10,
|
|
image: imageObj,
|
|
draggable: true,
|
|
});
|
|
|
|
layer.add(darth);
|
|
stage.add(layer);
|
|
|
|
darth.cache();
|
|
darth.filters([Konva.Filters.Noise]);
|
|
darth.noise(1);
|
|
layer.draw();
|
|
|
|
var tween = new Konva.Tween({
|
|
node: darth,
|
|
duration: 5.0,
|
|
noise: 0,
|
|
easing: Konva.Easings.EaseInOut,
|
|
});
|
|
|
|
darth.on('mouseover', function () {
|
|
tween.play();
|
|
});
|
|
|
|
darth.on('mouseout', function () {
|
|
tween.reverse();
|
|
});
|
|
|
|
done();
|
|
});
|
|
});
|
|
});
|