11import { tempStyles } from "./canvas" ;
2- import { debug , onDebugStateChange } from "./debug" ;
2+ import { isDebug , onDebugStateChange } from "./debug" ;
33
44export const colors = {
55 debug : "green" ,
@@ -28,7 +28,10 @@ export interface AnimationPainter {
2828 ( timestamp : number ) : void ;
2929}
3030
31- const cells : Cell [ ] [ ] = [ ] ;
31+ // Global cell state.
32+ const cells = ( ( window as any ) . cells as Cell [ ] [ ] ) || [ ] ;
33+ ( ( window as any ) . cells as Cell [ ] [ ] ) = cells ;
34+
3235const containerElement = document . querySelector ( ".container" ) ;
3336if ( ! containerElement ) throw "missing container" ;
3437
@@ -41,7 +44,7 @@ const reveal = () => {
4144 redraw ( ) ;
4245} ;
4346howItWorksElement . addEventListener ( "click" , reveal ) ;
44- if ( document . location . hash ) setTimeout ( reveal ) ;
47+ if ( document . location . hash || isDebug ( ) ) setTimeout ( reveal ) ;
4548
4649export const sizes = ( ) : { width : number ; pt : number } => {
4750 const sectionStyle = window . getComputedStyle (
@@ -132,7 +135,7 @@ const redraw = () => {
132135
133136 // Draw canvas debug info.
134137 const drawDebug = ( ) => {
135- if ( debug ) {
138+ if ( isDebug ( ) ) {
136139 tempStyles (
137140 cell . ctx ,
138141 ( ) => ( cell . ctx . strokeStyle = colors . debug ) ,
@@ -157,7 +160,7 @@ const redraw = () => {
157160 const frameTime = Date . now ( ) - startTime ;
158161 cell . ctx . clearRect ( 0 , 0 , cellWidth , cellHeight ) ;
159162 drawDebug ( ) ;
160- if ( debug ) {
163+ if ( isDebug ( ) ) {
161164 tempStyles (
162165 cell . ctx ,
163166 ( ) => ( cell . ctx . fillStyle = colors . debug ) ,
0 commit comments