@@ -49,6 +49,7 @@ export interface GobanCanvasConfig extends GobanConfig {
49
49
board_div ?: HTMLElement ;
50
50
title_div ?: HTMLElement ;
51
51
move_tree_container ?: HTMLElement ;
52
+ last_move_opacity ?: number ;
52
53
}
53
54
54
55
interface ViewPortInterface {
@@ -104,6 +105,7 @@ export class GobanCanvas extends GobanCore implements GobanCanvasInterface {
104
105
private shadow_ctx ?: CanvasRenderingContext2D ;
105
106
private handleShiftKey : ( ev : KeyboardEvent ) => void ;
106
107
108
+ private last_move_opacity : number = 1 ;
107
109
public move_tree_container ?: HTMLElement ;
108
110
private move_tree_inner_container ?: HTMLDivElement ;
109
111
private move_tree_canvas ?: HTMLCanvasElement ;
@@ -162,6 +164,7 @@ export class GobanCanvas extends GobanCore implements GobanCanvasInterface {
162
164
this . board = createDeviceScaledCanvas ( 10 , 10 ) ;
163
165
this . board . setAttribute ( "id" , "board-canvas" ) ;
164
166
this . board . className = "StoneLayer" ;
167
+ this . last_move_opacity = config [ "last_move_opacity" ] ?? 1 ;
165
168
const ctx = this . board . getContext ( "2d" , { willReadFrequently : true } ) ;
166
169
if ( ctx ) {
167
170
this . ctx = ctx ;
@@ -217,6 +220,10 @@ export class GobanCanvas extends GobanCore implements GobanCanvasInterface {
217
220
this . ready_to_draw = true ;
218
221
this . redraw ( true ) ;
219
222
}
223
+ public setLastMoveOpacity ( opacity : number ) : void {
224
+ this . last_move_opacity = opacity ;
225
+ }
226
+
220
227
public enablePen ( ) : void {
221
228
this . attachPenCanvas ( ) ;
222
229
}
@@ -2082,7 +2089,7 @@ export class GobanCanvas extends GobanCore implements GobanCanvasInterface {
2082
2089
ctx . save ( ) ;
2083
2090
ctx . beginPath ( ) ;
2084
2091
ctx . lineWidth = this . square_size * 0.075 ;
2085
- // ctx.globalAlpha = 0.6 ;
2092
+ ctx . globalAlpha = this . last_move_opacity ;
2086
2093
const r = Math . max ( 1 , this . metrics . mid * 0.35 ) * 0.8 ;
2087
2094
ctx . moveTo ( cx - r , cy ) ;
2088
2095
ctx . lineTo ( cx + r , cy ) ;
@@ -2113,18 +2120,20 @@ export class GobanCanvas extends GobanCore implements GobanCanvasInterface {
2113
2120
draw_last_move = false ;
2114
2121
ctx . restore ( ) ;
2115
2122
} else {
2123
+ ctx . save ( ) ;
2116
2124
ctx . beginPath ( ) ;
2117
2125
ctx . strokeStyle = color ;
2118
2126
ctx . lineWidth = this . square_size * 0.075 ;
2127
+ ctx . globalAlpha = this . last_move_opacity ;
2119
2128
let r = this . square_size * this . last_move_radius ;
2120
2129
if ( this . submit_move ) {
2121
- //ctx.globalAlpha = 0.6;
2122
2130
r = this . square_size * 0.3 ;
2123
2131
}
2124
2132
2125
2133
r = Math . max ( 0.1 , r ) ;
2126
2134
ctx . arc ( cx , cy , r , 0 , 2 * Math . PI , false ) ;
2127
2135
ctx . stroke ( ) ;
2136
+ ctx . restore ( ) ;
2128
2137
}
2129
2138
}
2130
2139
}
0 commit comments