Skip to content

Instantly share code, notes, and snippets.

@williamngan
Last active March 20, 2022 07:52
Show Gist options
  • Save williamngan/d18e4a6d9fc2fbd19e6907561b908a88 to your computer and use it in GitHub Desktop.
Save williamngan/d18e4a6d9fc2fbd19e6907561b908a88 to your computer and use it in GitHub Desktop.
This is a quick test of Pts (https://ptsjs.org) with Svelte (https://svelte.dev)
<script>
/* This is a quick test of Pts (https://ptsjs.org) with Svelte (https://svelte.dev) */
import { onMount } from "svelte";
import { CanvasSpace, Rectangle } from "pts";
let container, space, form;
onMount(() => {
space = new CanvasSpace(container).setup({bgcolor: "#52f"});
form = space.getForm();
space.add( time => {
form.fillOnly("#f06").point(space.pointer, 200, "circle");
form.strokeOnly("#fff", 5).lines(
Rectangle.corners(space.innerBound).map(r => [r, space.pointer])
);
form.fillOnly("#0c9").point(space.pointer, 100, "circle");
});
space.bindMouse().bindTouch().play();
});
</script>
<style>
#pts { width: 100%; height: 100%; }
</style>
<div id="pts" bind:this={container} />
@williamngan
Copy link
Author

Not sure why the tab-spacing are displayed incorrectly here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment