feat: improve ghost piece visibility with three-layer design for better accessibility

This commit is contained in:
cmclark00 2025-03-30 15:54:36 -04:00
parent e23d33e2e2
commit 03ff049bef

View file

@ -179,6 +179,26 @@ class GameView @JvmOverloads constructor(
private var isPulsing = false
private var linesToPulse = mutableListOf<Int>() // Track which lines are being cleared
private val ghostPaint = Paint().apply {
style = Paint.Style.STROKE
strokeWidth = 2f
color = Color.WHITE
alpha = 180 // Increased from 100 for better visibility
}
private val ghostBackgroundPaint = Paint().apply {
style = Paint.Style.FILL
color = Color.WHITE
alpha = 30 // Very light background for better contrast
}
private val ghostBorderPaint = Paint().apply {
style = Paint.Style.STROKE
strokeWidth = 1f
color = Color.WHITE
alpha = 100 // Subtle border for better definition
}
init {
// Start with paused state
pause()
@ -578,15 +598,43 @@ class GameView @JvmOverloads constructor(
val piece = gameBoard.getCurrentPiece() ?: return
val ghostY = gameBoard.getGhostY()
// Draw semi-transparent background for each block
for (y in 0 until piece.getHeight()) {
for (x in 0 until piece.getWidth()) {
if (piece.isBlockAt(x, y)) {
val boardX = piece.x + x
val boardY = ghostY + y
// Draw ghost piece regardless of vertical position
if (boardX >= 0 && boardX < gameBoard.width) {
drawBlock(canvas, boardX, boardY, true, false)
val screenX = boardLeft + boardX * blockSize
val screenY = boardTop + boardY * blockSize
// Draw background
canvas.drawRect(
screenX + 1f,
screenY + 1f,
screenX + blockSize - 1f,
screenY + blockSize - 1f,
ghostBackgroundPaint
)
// Draw border
canvas.drawRect(
screenX + 1f,
screenY + 1f,
screenX + blockSize - 1f,
screenY + blockSize - 1f,
ghostBorderPaint
)
// Draw outline
canvas.drawRect(
screenX + 1f,
screenY + 1f,
screenX + blockSize - 1f,
screenY + blockSize - 1f,
ghostPaint
)
}
}
}