Class GobanCanvas

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.

Hierarchy (view full)

Implements

Constructors

Properties

__board_redraw_pen_layer_timer __borders_initialized __clock_timer? __draw_state __last_pt __set_board_height __set_board_width __update_move_tree analysis_move_counter analysis_removal_last_position analysis_removal_state? autoplaying_puzzle_move board bounded_height bounded_width bounds byoyomi_label chat_log circle_radius clock_should_be_paused_for_move_submission colored_circles? conditional_path conditional_starting_color conditional_tree config connectToReviewSent? ctx current_cmove? current_pen_mark? currently_my_cmove dirty_redraw disconnectedFromGame display_width? done_loading_review dont_draw_last_move double_click_submit draw_bottom_labels draw_left_labels draw_right_labels draw_top_labels drawing_enabled edit_color? engine errorHandler game_id game_type getPuzzlePlacementSetting? goban_id handleShiftKey heatmap? height highlight_movetree_moves interactive isInPushedAnalysis isPlayerController isPlayerOwner label_character label_mark labeling_mode? last_clock? last_emitted_clock? last_hover_square? last_label_position last_move? last_move_opacity last_move_radius last_paused_by_player_state last_paused_state last_pen_position? last_phase? last_review_message last_sound_played_for_a_stone_placement? last_stone_sound leavePushedAnalysis marked_analysis_score? message_div? message_td? message_text? message_timeout? metrics move_selected? move_tree_canvas? move_tree_container? move_tree_inner_container? no_display onError? on_game_screen one_click_submit original_square_size parent pause_control? paused_since? pen_ctx? pen_layer? pen_marks player_id preloaded_data? previous_mode puzzle_autoplace_delay ready_to_draw restrict_moves_to_movetree review_had_gamedata review_id scoring_mode sendLatencyTimer? sent_timed_out_message shadow_ctx? shadow_layer? shift_key_is_down show_variation_move_numbers showing_scores socket socket_event_bindings square_size stalling_score_estimate? stone_font_scale stone_placement_enabled stone_removal_auto_scoring_done? theme_black theme_black_stones theme_black_text_color theme_blank_text_color theme_board theme_faded_line_color theme_faded_star_color theme_line_color theme_star_color theme_stone_radius theme_white theme_white_stones theme_white_text_color themes title_div? variation_stone_opacity width THEMES THEMES_SORTED setCallbacks setTranslations

Accessors

Methods

__drawSquare _socket_on acceptRemovedStones acceptUndo annul attachPenCanvas attachShadowLayer bindPointerBindings cancelGame cancelUndo clearAnalysisDrawing clearAnalysisScores clearMark clearMessage clearPendingResignation clearTransientMark computeMetrics computeNewPlayerClock computeThemeStoneRadius connect debouncedEmitCapturedStones decodeMoves decodePrettyCoordinates defaultConfig deleteBranch deleteConditionalPath deleteCustomMark destroy detachPenCanvas detachShadowLayer disableDrawing disablePen disableStonePlacement disconnect drawPenMarks drawSquare drawingHash editPlaceByPrettyCoordinates enableDrawing enablePen enableStonePlacement encodeMove encodeMoves followConditionalPath followConditionalSegment getAnalysisScoreColorAtLocation getClockDrift getCoordinateDisplaySystem getCurrentConditionalPath getLastReviewMessage getLocation getMarks getNetworkLatency getPlayerRelativeLatency getSelectedThemes getShowUndoRequestIndicator getShowVariationMoveNumbers getStoneFontScale getWidthForSquareSize giveReviewControl hideScores incrementLabelCharacter isAnalysisDisabled isCurrentUserAPlayer isLastOfficialMove jumpToLastOfficialMove load markAnalysisScores markDirty move_tree_bindCanvasEvents move_tree_drawIsoBranchTo move_tree_drawPath move_tree_drawRecursive move_tree_drawStone move_tree_hilightNode move_tree_recursiveDrawPath move_tree_redraw nextSibling onAnalysisScoringMove onAnalysisScoringStart onAnalysisToggleStoneRemoval onLabelingMove onLabelingStart onMouseMove onMouseOut onPenMove onPenStart onTap pass pauseGame pen2xy performStoneRemovalAutoScoring placeByPrettyCoordinates playMovementSound post_config_constructor prettyCoordinates prevSibling putAnalysisRemovalAtLocation putAnalysisScoreColorAtLocation putOrClearLabel redraw rejectRemovedStones requestUndo resign resumeGame saveConditionalMoves scheduleRedrawPenLayer sendChat sendMove sendPendingResignation sendPreventEscaping sendPreventStalling sendTimedOut set setAnalyzeTool setBounds setByoYomiLabel setColoredCircles setColoredMarks setConditionalTree setCustomMark setEditColor setForRemoval setGameClock setHeatmap setLabelCharacter setLabelCharacterFromMarks setLabelPosition setLastMoveOpacity setLastOfficialMove setLastReviewMessage setLetterMark setMark setMarkByPrettyCoordinates setMarkColor setMarks setMode setModeDeferred setMoveTreeContainer setPenStyle setScoringMode setSquareSize setSquareSizeBasedOnDisplayWidth setState setStoneFontScale setStrictSekiMode setSubmit setSubscriptMark setTheme setTitle setToPreviousMode setTransientMark showFirst showMessage showNext showPrevious showScores showStallingScoreEstimate syncReviewMove toggleMark updateMoveTree updateOrRedrawMoveTree updatePlayerToMoveTitle updateScoreEstimation updateTitleAndStonePlacement watchSelectedThemes xy2ij xy2pen getCDNReleaseBase getMoveTreeNumbering getSoundEnabled getSoundVolume

Constructors

Properties

__board_redraw_pen_layer_timer: any = null
__borders_initialized: boolean = false
__clock_timer?: Timeout
__draw_state: string[][]
__last_pt: {
    i: number;
    j: number;
    valid: boolean;
} = ...

Type declaration

  • i: number
  • j: number
  • valid: boolean
__set_board_height: number = -1
__set_board_width: number = -1
__update_move_tree: any = null
analysis_move_counter: number
analysis_removal_last_position: {
    i: number;
    j: number;
} = ...

Type declaration

  • i: number
  • j: number
analysis_removal_state?: boolean
autoplaying_puzzle_move: boolean = false
board: HTMLCanvasElement
bounded_height: number
bounded_width: number
bounds: GobanBounds
byoyomi_label: string = ""
chat_log: GobanChatLog = []
circle_radius: number
clock_should_be_paused_for_move_submission: boolean = false
colored_circles?: (undefined | ColoredCircle)[][]
conditional_path: string = ""
conditional_starting_color: "black" | "white" | "invalid" = "invalid"
conditional_tree: ConditionalMoveTree = ...
config: GobanConfig
connectToReviewSent?: boolean
ctx: CanvasRenderingContext2D
current_cmove?: ConditionalMoveTree
current_pen_mark?: {
    color: string;
    points: [number, number];
}

Type declaration

  • color: string
  • points: [number, number]
currently_my_cmove: boolean = false
dirty_redraw: any = null
disconnectedFromGame: boolean = true
display_width?: number
done_loading_review: boolean = false
dont_draw_last_move: boolean
double_click_submit: boolean
draw_bottom_labels: boolean
draw_left_labels: boolean
draw_right_labels: boolean
draw_top_labels: boolean
drawing_enabled: boolean = true
edit_color?: "black" | "white"
engine: GobanEngine
errorHandler: ((e) => void)

Type declaration

    • (e): void
    • Parameters

      • e: Error

      Returns void

game_id: number
game_type: string
getPuzzlePlacementSetting?: (() => PuzzlePlacementSetting)
goban_id: number = ++last_goban_id

Base fields *

handleShiftKey: ((ev) => void)

Type declaration

    • (ev): void
    • Parameters

      • ev: KeyboardEvent

      Returns void

heatmap?: NumberMatrix
height: number
highlight_movetree_moves: boolean
interactive: boolean
isInPushedAnalysis: (() => boolean)

Type declaration

    • (): boolean
    • Returns boolean

isPlayerController: (() => boolean)

Type declaration

    • (): boolean
    • Returns boolean

isPlayerOwner: (() => boolean)

Type declaration

    • (): boolean
    • Returns boolean

label_character: string
label_mark: string = "[UNSET]"
labeling_mode?: "put" | "clear"
last_clock?: AdHocClock
last_emitted_clock?: JGOFClockWithTransmitting
last_hover_square?: JGOFIntersection
last_label_position: {
    i: number;
    j: number;
} = ...

Type declaration

  • i: number
  • j: number
last_move?: MoveTree
last_move_opacity: number = 1
last_move_radius: number
last_paused_by_player_state: null | boolean = null
last_paused_state: null | boolean = null
last_pen_position?: [number, number]
last_phase?: GobanEnginePhase
last_review_message: ReviewMessage
last_sound_played_for_a_stone_placement?: string
last_stone_sound: number
leavePushedAnalysis: (() => void)

Type declaration

    • (): void
    • Returns void

marked_analysis_score?: boolean[][]
message_div?: HTMLDivElement
message_td?: HTMLElement
message_text?: HTMLDivElement
message_timeout?: number
metrics: GobanMetrics = ...
move_selected?: JGOFIntersection
move_tree_canvas?: HTMLCanvasElement
move_tree_container?: HTMLElement
move_tree_inner_container?: HTMLDivElement
no_display: boolean
onError?: ((error) => void)

Type declaration

    • (error): void
    • Parameters

      • error: Error

      Returns void

on_game_screen: boolean
one_click_submit: boolean
original_square_size: number | ((goban) => number) | "auto"

Type declaration

    • (goban): number
    • Parameters

      Returns number

parent: HTMLElement
pause_control?: AdHocPauseControl
paused_since?: number
pen_ctx?: CanvasRenderingContext2D
pen_layer?: HTMLCanvasElement
pen_marks: any[]
player_id: number
preloaded_data?: GobanConfig
previous_mode: string
puzzle_autoplace_delay: number
ready_to_draw: boolean = false
restrict_moves_to_movetree: boolean
review_had_gamedata: boolean
review_id: number
scoring_mode: boolean | "stalling-scoring-mode"
sendLatencyTimer?: Timeout
sent_timed_out_message: boolean = false
shadow_ctx?: CanvasRenderingContext2D
shadow_layer?: HTMLCanvasElement
shift_key_is_down: boolean
show_variation_move_numbers: boolean
showing_scores: boolean = false
socket_event_bindings: [keyof GobanSocketEvents, (() => void)][] = []
square_size: number = 10
stalling_score_estimate?: StallingScoreEstimate
stone_font_scale: number
stone_placement_enabled: boolean
stone_removal_auto_scoring_done?: boolean = false
theme_black: GobanTheme
theme_black_stones: any[] = []
theme_black_text_color: string = HOT_PINK
theme_blank_text_color: string = HOT_PINK
theme_board: GobanTheme
theme_faded_line_color: string = HOT_PINK
theme_faded_star_color: string = HOT_PINK
theme_line_color: string = ""
theme_star_color: string = ""
theme_stone_radius: number = 10
theme_white: GobanTheme
theme_white_stones: any[] = []
theme_white_text_color: string = HOT_PINK
themes: GobanSelectedThemes = ...
title_div?: HTMLElement
variation_stone_opacity: number
width: number
THEMES: ThemesInterface = THEMES
THEMES_SORTED: {
    black: GobanTheme[];
    board: GobanTheme[];
    white: GobanTheme[];
    [key: string]: GobanTheme[];
} = THEMES_SORTED

Type declaration

setCallbacks: ((newCallbacks) => void) = setGobanCallbacks

Type declaration

    • (newCallbacks): void
    • Set's callback functions to be called in various situations. You can set any or all of the callbacks, only the provided callbacks will be updated.

      Parameters

      Returns void

setTranslations: ((_catalog, _debug_mode?) => void) = setGobanTranslations

Type declaration

    • (_catalog, _debug_mode?): void
    • Parameters

      Returns void

Accessors

  • get analyze_subtool(): string
  • Returns string

  • set analyze_subtool(analyze_subtool): void
  • Parameters

    • analyze_subtool: string

    Returns void

  • get destroyed(): boolean
  • Returns boolean

  • get is_game_record(): boolean
  • True if the game is a game record of a real life game

    Returns boolean

  • get review_controller_id(): undefined | number
  • Returns undefined | number

  • set review_controller_id(review_controller_id): void
  • Parameters

    • review_controller_id: undefined | number

    Returns void

  • get review_owner_id(): undefined | number
  • Returns undefined | number

  • set review_owner_id(review_owner_id): void
  • Parameters

    • review_owner_id: undefined | number

    Returns void

  • get submit_move(): undefined | (() => void)
  • Returns undefined | (() => void)

  • set submit_move(submit_move): void
  • Parameters

    • submit_move: undefined | (() => void)

    Returns void

Methods

  • Decodes a move string like "A11" into a move object like {x: 0, y: 10}. Also handles the special cases like ".." and "pass" which map to {x: -1, y: -1}.

    Parameters

    • coordinates: string

    Returns JGOFMove

  • 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

    Returns void

  • Parameters

    • event: TouchEvent | MouseEvent
    • double_tap: boolean
    • right_click: boolean
    • press_duration_ms: number

    Returns void

  • Goban calls some abstract methods as part of the construction process. Because our subclasses might (and do) need to do some of their own config before these are called, we set this function to be called by our subclass after it's done it's own internal config stuff.

    Returns GobanEngine

  • When we think our clock has runout, send a message to the server letting it know. Otherwise we have to wait for the server grace period to expire for it to time us out.

    Returns void

  • Parameters

    • colored_marks: {
          [key: string]: {
              color: string;
              move: string;
          };
      }
      • [key: string]: {
            color: string;
            move: string;
        }
        • color: string
        • move: string

    Returns void

  • Called when a location is marked or unmarked for removal

    Parameters

    • x: number
    • y: number
    • removed: boolean
    • emit_stone_removal_updated: boolean = true

    Returns void

  • This is a callback that gets called by GobanEngine.getState to save and board state as it pushes and pops state. Our renderers can override this to save state they need.

    Parameters

    • marks: {
          [mark: string]: string;
      }
      • [mark: string]: string
    • Optional dont_draw: boolean

    Returns void

  • Parameters

    • x: number
    • y: number
    • mark: string | number
    • Optional force_label: boolean
    • Optional force_put: boolean

    Returns boolean

  • Parameters

    Returns {
        remove: (() => any);
    }

    • remove: (() => any)
        • (): any
        • Returns any

  • Parameters

    • x: number
    • y: number
    • anti_slip: boolean = true

    Returns {
        i: number;
        j: number;
        valid: boolean;
    }

    • i: number
    • j: number
    • valid: boolean