Skip to content

Instantly share code, notes, and snippets.

@mwdchang
Created December 1, 2021 04:21
Show Gist options
  • Save mwdchang/72526845994dfcf59980e543ab8f6731 to your computer and use it in GitHub Desktop.
Save mwdchang/72526845994dfcf59980e543ab8f6731 to your computer and use it in GitHub Desktop.
jsdelivr module loading example
<html>
<head>
</head>
<body>
</body>
<script type="module">
import { loadImage, hatchFilter } from 'https://cdn.jsdelivr.net/gh/mwdchang/image-util/dist/index.js';
const createCanvas = (img) => {
const canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
const context = canvas.getContext('2d');
context.putImageData(img, 0, 0);
return canvas;
};
const run = async () => {
const img = await loadImage('image_url', { width: 200, height: 200 });
const hatch = hatchFilter(img, 1.0, 0.7, 0.5, 0.25);
const hatchCanvas = createCanvas(hatch);
document.body.append(hatchCanvas);
};
run();
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment