Skip to content

Commit c067e3d

Browse files
author
Christopher Strauss
committed
plastische Steine
1 parent 661a879 commit c067e3d

File tree

1 file changed

+14
-4
lines changed
  • src/main/client/src/feature/game

1 file changed

+14
-4
lines changed

src/main/client/src/feature/game/paint.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,22 @@ function paintTerritory({canvasRef, grid, territoryRadius}, grid_x, grid_y, styl
136136
}
137137

138138
function paintStone({canvasRef, grid, stoneRadius}, grid_x, grid_y, color) {
139-
let style = color === BLACK ?
140-
"rgba(0,0,0)" :
141-
"rgba(255,255,255)"
139+
let outerStyle = color === BLACK ?
140+
"#505050" :
141+
"#fff"
142+
let innerStyle = color === BLACK ?
143+
"rgba(80,80,80,0)" :
144+
"hsla(0,0%,100%,0)"
142145
let [x, y] = grid[grid_y][grid_x]
143146
let ctx = canvasRef.current.getContext("2d")
144-
ctx.fillStyle = style
147+
ctx.fillStyle = color === BLACK ? "#111" : "#ddd"
148+
ctx.beginPath()
149+
ctx.arc(x, y, stoneRadius, 0, TAU)
150+
ctx.fill()
151+
let gradient = ctx.createRadialGradient(x - (stoneRadius/4), y - (stoneRadius/4), 0, x - (stoneRadius/4), y - (stoneRadius/4), stoneRadius)
152+
gradient.addColorStop(color === BLACK ? 0.55 : 0.7, innerStyle);
153+
gradient.addColorStop(color === BLACK ? 0.1 : 0.2, outerStyle);
154+
ctx.fillStyle = gradient
145155
ctx.beginPath()
146156
ctx.arc(x, y, stoneRadius, 0, TAU)
147157
ctx.fill()

0 commit comments

Comments
 (0)