Android 19*10的数组颜色按照中心点旋转10度
fun rotateColors(colors: Array<IntArray>, degrees: Float): Array<IntArray> { val newColors = Array(10) { IntArray(19) { Color.BLACK } } val centerX = 9f val centerY = 4.5f val radians = Math.toRadians(degrees.toDouble()) val sin = Math.sin(radians) val cos = Math.cos(radians) for (y in 0 until 10) { for (x in 0 until 19) { val offsetX = x - centerX val offsetY = y - centerY val rotatedX = cos * offsetX - sin * offsetY + centerX val rotatedY = sin * offsetX + cos * offsetY + centerY val originalX = rotatedX.toInt() val originalY = rotatedY.toInt() if (originalX in 0 until 19 && originalY in 0 until 10) { newColors[y][x] = colors[originalY][originalX] } } } return newColors }