From 9a8a9f215403d58e703e15a90c74f245db948a59 Mon Sep 17 00:00:00 2001 From: Gordon Woodhull Date: Fri, 11 Aug 2023 22:30:13 -0400 Subject: [PATCH] clip pipes to tile polygons this addresses #91 but it has its own glitches --- src/lib/puzzle/ClipPolygon.svelte | 17 +++++++++++++++++ src/lib/puzzle/Puzzle.svelte | 11 +++++++++++ src/lib/puzzle/Tile.svelte | 1 + src/lib/puzzle/grids/abstractgrid.js | 9 +++++++++ src/lib/puzzle/grids/polygonutils.js | 26 ++++++++++++++++---------- 5 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 src/lib/puzzle/ClipPolygon.svelte diff --git a/src/lib/puzzle/ClipPolygon.svelte b/src/lib/puzzle/ClipPolygon.svelte new file mode 100644 index 00000000..084b7342 --- /dev/null +++ b/src/lib/puzzle/ClipPolygon.svelte @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/src/lib/puzzle/Puzzle.svelte b/src/lib/puzzle/Puzzle.svelte index d10defe0..5e6688eb 100644 --- a/src/lib/puzzle/Puzzle.svelte +++ b/src/lib/puzzle/Puzzle.svelte @@ -2,6 +2,7 @@ import { settings } from '$lib/stores'; import { controls } from '$lib/puzzle/controls'; import Tile from '$lib/puzzle/Tile.svelte'; + import ClipPolygon from '$lib/puzzle/ClipPolygon.svelte'; import { onMount, onDestroy, createEventDispatcher, tick } from 'svelte'; import { PipesGame } from '$lib/puzzle/game'; import { Solver } from './solver'; @@ -330,6 +331,16 @@ on:contextmenu|preventDefault={() => {}} on:save={save.soon} > + + {#each $visibleTiles as visibleTile, i (visibleTile.key)} + + {/each} + {#each $visibleTiles as visibleTile, i (visibleTile.key)} { if ((direction & tile) > 0) { const angle = this.angle_offset + this.angle_unit * index; - const dx = this.radius_in * Math.cos(angle); - const dy = this.radius_in * Math.sin(angle); + const radius = this.radius_in * 1.2; + const dx = radius * Math.cos(angle); + const dy = radius * Math.sin(angle); path += ` l ${dx} ${-dy} L 0 0`; } });