goban-engine
Version:
This contains the built Go engine that is used by the Goban package. There are no display components in this package, only the logic for playing the game of Go, making it suitable for usage in node.js or other server-side environments.
101 lines (100 loc) • 4.15 kB
TypeScript
import { GobanBase } from "../../GobanBase";
import { ShadowTheme, CustomShadowConfig } from "../Goban";
export interface GobanThemeBackgroundCSS {
"background-color"?: string;
"background-image"?: string;
"background-size"?: string;
}
export interface GobanThemeBackgroundReactStyles {
backgroundColor?: string;
backgroundImage?: string;
backgroundSize?: string;
}
export interface SVGStop {
offset: number;
color: string;
}
export interface SVGStoneParameters {
id: string;
fill?: string;
stroke?: string;
stroke_scale?: number;
gradient?: {
stops: SVGStop[];
type?: "radial" | "linear";
x1?: number;
x2?: number;
y1?: number;
y2?: number;
cx?: number;
cy?: number;
r?: number;
fx?: number;
fy?: number;
};
url?: string;
}
export interface GradientStopConfig {
offset: string;
color: string;
opacity: string;
}
export interface ShadowConfig {
gradientTransform: string;
actualShadowColor: string;
stops: GradientStopConfig[];
}
export declare class GobanTheme {
name: string;
styles: {
[style_name: string]: string;
};
protected parent?: GobanTheme;
constructor(parent?: GobanTheme);
get theme_name(): string;
sort(): number;
preRenderBlack(_radius: number, _seed: number, _deferredRenderCallback: () => void): any;
preRenderWhite(_radius: number, _seed: number, _deferredRenderCallback: () => void): any;
preRenderBlackSVG(defs: SVGDefsElement, radius: number, _seed: number, _deferredRenderCallback: () => void): string[];
preRenderWhiteSVG(defs: SVGDefsElement, radius: number, _seed: number, _deferredRenderCallback: () => void): string[];
preRenderShadowSVG(defs: SVGDefsElement, color: string, shadow_color: string, shadow_theme?: ShadowTheme, custom_config?: CustomShadowConfig): void;
/**
* Gets the shadow configuration for a given theme
*/
private getShadowConfig;
/**
* Creates a radial gradient SVG element with the given configuration
*/
private createRadialGradient;
/**
* Creates a single SVG stop element
*/
private createGradientStop;
placeWhiteStone(ctx: CanvasRenderingContext2D, _shadow_ctx: CanvasRenderingContext2D | null, _stone: any, cx: number, cy: number, radius: number): void;
placeBlackStone(ctx: CanvasRenderingContext2D, _shadow_ctx: CanvasRenderingContext2D | null, _stone: any, cx: number, cy: number, radius: number): void;
placeStoneShadowSVG(shadow_cell: SVGGraphicsElement | undefined, cx: number, cy: number, radius: number, color: string, shadow_theme?: ShadowTheme): SVGElement | undefined;
private placeStoneSVG;
placeWhiteStoneSVG(cell: SVGGraphicsElement, shadow_cell: SVGGraphicsElement | undefined, stone: string, cx: number, cy: number, radius: number, shadow_theme?: ShadowTheme): [SVGElement, SVGElement | undefined];
placeBlackStoneSVG(cell: SVGGraphicsElement, shadow_cell: SVGGraphicsElement | undefined, stone: string, cx: number, cy: number, radius: number, shadow_theme?: ShadowTheme): [SVGElement, SVGElement | undefined];
getStone(x: number, y: number, stones: any, _goban: GobanBase): any;
getStoneHash(x: number, y: number, stones: any, _goban: GobanBase): string;
stoneCastsShadow(_radius: number): boolean;
getPreferredShadowTheme(): ShadowTheme;
getWhiteStoneColor(): string;
getBlackStoneColor(): string;
getWhiteTextColor(_color?: string): string;
getBlackTextColor(_color?: string): string;
getBackgroundCSS(): GobanThemeBackgroundCSS;
getReactStyles(): GobanThemeBackgroundReactStyles;
getLineColor(): string;
getFadedLineColor(): string;
getStarColor(): string;
getFadedStarColor(): string;
getBlankTextColor(): string;
/** Returns the color that should be used for labels */
getLabelTextColor(): string;
getShadowColor(_color?: string): string;
renderSVG(params: SVGStoneParameters, radius: number): SVGGraphicsElement;
def_uid(base: string): string;
protected getCDNReleaseBase(): string;
}