import * as scrawl from '../source/scrawl.js';
import { reportSpeed, addImageDragAndDrop } from './utilities.js';import * as scrawl from '../source/scrawl.js';
import { reportSpeed, addImageDragAndDrop } from './utilities.js';const canvas = scrawl.library.canvas.mycanvas;
scrawl.importDomImage('.flowers');Create the filter
const myFilter = scrawl.makeFilter({
name: 'newsprint',
method: 'newsprint',
width: 1,
});Create the target entity
const piccy = scrawl.makePicture({
name: 'base-piccy',
asset: 'iris',
width: '100%',
height: '100%',
copyWidth: '100%',
copyHeight: '100%',
method: 'fill',
filters: ['newsprint'],
});Function to display frames-per-second data, and other information relevant to the demo
const report = reportSpeed('#reportmessage', function () {@ts-expect-error
return ` Effect width: ${width.value}px\n Opacity: ${opacity.value}`;
});Create the Display cycle animation
const demoAnimation = scrawl.makeRender({
name: "demo-animation",
target: canvas,
afterShow: report,
});scrawl.observeAndUpdate({
event: ['input', 'change'],
origin: '.controlItem',
target: myFilter,
useNativeListener: true,
preventDefault: true,
updates: {
width: ['width', 'round'],
opacity: ['opacity', 'float'],
},
});Setup form
const width = document.querySelector('#width'),
opacity = document.querySelector('#opacity');@ts-expect-error
width.value = 1;@ts-expect-error
opacity.value = 1;addImageDragAndDrop(canvas, '#my-image-store', piccy);console.log(scrawl.library);