Created
February 21, 2020 18:05
-
-
Save collardeau/0fc88a102dc6f8a65013d17c91c2a8e7 to your computer and use it in GitHub Desktop.
Svelte: RoughJS setup
This file contains hidden or 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
<script> | |
import rough from "roughjs/bin/rough"; | |
// npm i [email protected] | |
// https://roughjs.com/ | |
let roughSvg; | |
function action(node) { | |
roughSvg = rough.svg(node); | |
const rect = roughSvg.rectangle(100, 50, 100, 50, { // x, y, width, height | |
fill: "red" | |
}); | |
node.appendChild(rect); | |
} | |
</script> | |
<svg use:action /> | |
<style> | |
svg { | |
width: 300px; | |
height: 150px; | |
background-color: white; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment