Created
December 1, 2021 04:21
-
-
Save mwdchang/72526845994dfcf59980e543ab8f6731 to your computer and use it in GitHub Desktop.
jsdelivr module loading example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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