UNPKG

goban

Version:

[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/online-go/goban)

111 lines (110 loc) 4.59 kB
import { OGSConnectivity } from "./OGSConnectivity"; import { GobanConfig } from "../GobanBase"; export declare const GOBAN_FONT = "Verdana,Arial,sans-serif"; export type ShadowTheme = "none" | "low" | "mid" | "high" | "custom" | "default" | "anime"; export interface CustomShadowConfig { black?: { gradientTransform?: string; shadow_color?: string; }; white?: { gradientTransform?: string; shadow_color?: string; }; } export interface GobanSelectedThemes { "board": string; "white": string; "black": string; "removal-graphic": "square" | "x"; "removal-scale": number; "stone-shadows"?: ShadowTheme; "custom-shadow-config"?: CustomShadowConfig; } export type LabelPosition = "all" | "none" | "top-left" | "top-right" | "bottom-right" | "bottom-left"; export interface GobanMetrics { width: number; height: number; mid: number; offset: number; } export interface CaptureDisplayConfig { stone_color: "black" | "white"; stone_count: number; stone_radius?: number; stone_overlap?: number; max_stones?: number; } export interface CaptureDisplay { readonly element: HTMLCanvasElement | SVGSVGElement; updateStoneCount(count: number): void; destroy(): void; } /** * Goban serves as a base class for our renderers as well as a namespace for various * classes, types, and enums. * * You can't create an instance of a Goban directly, you have to create an instance of * one of the renderers, such as GobanSVG. */ export declare abstract class Goban extends OGSConnectivity { static THEMES: import("./themes").ThemesInterface; static THEMES_SORTED: { [key: string]: import("./themes").GobanTheme[]; white: import("./themes").GobanTheme[]; black: import("./themes").GobanTheme[]; board: import("./themes").GobanTheme[]; }; protected abstract setTheme(themes: GobanSelectedThemes, dont_redraw: boolean): void; parent: HTMLElement; protected title_div?: HTMLElement; evaluation_bar_container?: HTMLDivElement; evaluation_bar_div?: HTMLDivElement; private analysis_scoring_color?; private analysis_scoring_last_position; private _evaluation; private _evaluation_bar_width; constructor(config: GobanConfig, preloaded_data?: GobanConfig); destroy(): void; set evaluation(value: number); get evaluation(): number; protected getSelectedThemes(): GobanSelectedThemes; protected putOrClearLabel(x: number, y: number, mode?: "put" | "clear"): boolean; protected getAnalysisScoreColorAtLocation(x: number, y: number): "black" | "white" | string | undefined; protected putAnalysisScoreColorAtLocation(x: number, y: number, color?: "black" | "white" | string, sync_review_move?: boolean): void; protected putAnalysisRemovalAtLocation(x: number, y: number, removal?: boolean): void; /** Marks scores on the board when in analysis mode. Note: this will not * clear existing scores, this is intentional as I think it's the expected * behavior of reviewers */ markAnalysisScores(): void; setSquareSizeBasedOnDisplayWidth(display_width: number, suppress_redraw?: boolean): void; set evaluation_bar_width(width: number); get evaluation_bar_width(): number; static computeEvaluationBarWidth(display_width: number): number; static computeSquareSizeFromDisplayWidth(display_width: number, config: { bounded_width: number; bounded_height: number; draw_left_labels: boolean; draw_right_labels: boolean; draw_top_labels: boolean; draw_bottom_labels: boolean; evaluation_bar: boolean; }): number; setLabelPosition(label_position: LabelPosition): void; protected onAnalysisToggleStoneRemoval(ev: MouseEvent | TouchEvent): void; /** Clears any analysis scores on the board */ clearAnalysisScores(): void; setSquareSize(new_ss: number, suppress_redraw?: boolean): void; setStoneFontScale(new_ss: number, suppress_redraw?: boolean): void; computeMetrics(): GobanMetrics; protected onAnalysisScoringStart(ev: MouseEvent | TouchEvent): void; protected onAnalysisScoringMove(ev: MouseEvent | TouchEvent): void; protected normalizeCaptureConfig(config: CaptureDisplayConfig): Required<CaptureDisplayConfig>; protected calculateCaptureDisplayDimensions(config: Required<CaptureDisplayConfig>, count: number): { radius: number; displayCount: number; stone_spacing: number; width: number; height: number; }; }