File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1 " />
6+ < script type ="module " src ="./index.ts "> </ script >
7+ </ head >
8+ </ html >
Original file line number Diff line number Diff line change 1+ import init , {
2+ get_grid_sample ,
3+ IPoint ,
4+ init_log ,
5+ init_panic_hook ,
6+ solve ,
7+ } from "snk-js" ;
8+ import wasmUrl from "snk-js/snk_js_bg.wasm" ;
9+ import { createCanvas } from "../utils/canvas" ;
10+
11+ await init ( wasmUrl ) ;
12+ init_panic_hook ( ) ;
13+ init_log ( ) ;
14+
15+ const grid = get_grid_sample ( "cave2" ) ;
16+ const { canvas, draw, highlightCell } = createCanvas ( grid ) ;
17+ document . body . appendChild ( canvas ) ;
18+
19+ const path = solve ( grid , [
20+ IPoint . create ( 0 , - 1 ) ,
21+ IPoint . create ( 1 , - 1 ) ,
22+ IPoint . create ( 2 , - 1 ) ,
23+ IPoint . create ( 3 , - 1 ) ,
24+ ] ) ;
25+
26+ draw (
27+ { width : grid . width , height : grid . height , data : grid . cells } ,
28+ [ ] as any ,
29+ [ ] ,
30+ ) ;
31+
32+ console . log ( path ) ;
33+
34+ for ( const { x, y } of path ) highlightCell ( x , y ) ;
You can’t perform that action at this time.
0 commit comments