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: 'my-filter',
method: 'randomNoise',
width: 6,
height: 6,
level: 0.5,
});Create the target entity
const piccy = scrawl.makePicture({
name: 'base-piccy',
asset: 'iris',
width: '100%',
height: '100%',
copyWidth: '100%',
copyHeight: '100%',
method: 'fill',
filters: ['my-filter'],
});Function to display frames-per-second data, and other information relevant to the demo
const report = reportSpeed('#reportmessage', function () {@ts-expect-error
return ` Width: ${width.value}, Height: ${height.value}\n Level: ${level.value}\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'],
height: ['height', 'round'],
opacity: ['opacity', 'float'],
level: ['level', 'float'],
noWrap: ['noWrap', 'boolean'],
includeRed: ['includeRed', 'boolean'],
includeGreen: ['includeGreen', 'boolean'],
includeBlue: ['includeBlue', 'boolean'],
includeAlpha: ['includeAlpha', 'boolean'],
},
});Setup form
const width = document.querySelector('#width'),
height = document.querySelector('#height'),
level = document.querySelector('#level'),
opacity = document.querySelector('#opacity');@ts-expect-error
width.value = 6;@ts-expect-error
height.value = 6;@ts-expect-error
level.value = 0.5;@ts-expect-error
opacity.value = 1;@ts-expect-error
document.querySelector('#noWrap').options.selectedIndex = 0;@ts-expect-error
document.querySelector('#includeRed').options.selectedIndex = 1;@ts-expect-error
document.querySelector('#includeGreen').options.selectedIndex = 1;@ts-expect-error
document.querySelector('#includeBlue').options.selectedIndex = 1;@ts-expect-error
document.querySelector('#includeAlpha').options.selectedIndex = 1;addImageDragAndDrop(canvas, '#my-image-store', piccy);console.log(scrawl.library);