ts-hashlife
Version:
Efficient TypeScript implementation of HashLife, an optimized algorithm for simulating Conway's Game of Life with memoization and quadtree-based compression.
63 lines (62 loc) • 1.8 kB
TypeScript
export type HashLifeOptions = {
max_fps?: number;
border_width?: number;
cell_width?: number;
background_color?: string;
cell_color?: string;
ui_padding?: {
top?: number;
right?: number;
bottom?: number;
left?: number;
};
};
declare class HashLife {
private _running;
private onStop;
private max_fps;
private border_width;
private cell_width;
private background_color;
private cell_color;
private ui_padding;
private pattern;
constructor(opts?: HashLifeOptions);
get running(): boolean;
set running(value: boolean);
handleInit(canvas: HTMLCanvasElement): boolean;
handleStart: () => void;
handleStop: (callback?: () => void) => void;
handleToggle: (callback?: () => void) => void;
handleReset: () => void;
handleStep: () => void;
handleSpeedUp: () => void;
handleSlowDown: () => void;
handleFitPattern: () => void;
handleExport: (pattern_name?: string) => string;
handleLoadExampleFromFile: ({ pattern_text, pattern_id, pattern_path, title, }: {
pattern_text: string;
pattern_id?: string;
pattern_path?: string;
title?: string;
}) => void;
handleLoadRandomizedPattern: ({ density, width, height, }: {
density: number;
width: number;
height: number;
}) => void;
handleWindowResize: () => void;
handlePan: (dx: number, dy: number) => void;
handleZoom: (zoomRatio: number, x: number, y: number) => void;
handleSetUiPadding: (padding?: {
top?: number;
right?: number;
bottom?: number;
left?: number;
}) => void;
private fit_pattern;
private step;
private reset_settings;
private lazy_redraw;
}
export default HashLife;