<script lang="ts">
    import { onMount } from "svelte";

    export let color: string;

    let canvas: HTMLCanvasElement;

    let redraws = 0;

    function redraw(color) {
        if (!canvas) return;

        redraws += 1;
        let cx = canvas.getContext("2d");
        cx.fillStyle = color;
        cx.fillRect(0, 0, cx.canvas.width, cx.canvas.height);
    }
    
    $: redraw(color);
</script>

<canvas bind:this={canvas} />
<pre>color: {color}
redraws: {redraws}</pre>
