fun draw()

in sample/src/main/kotlin/org/jetbrains/desktop/sample/macos/SkikoSampleMac.kt [112:145]


    fun draw(canvas: Canvas, time: Long, scale: Double) {
        val physicalOrigin = origin.toPhysical(scale)
        val physicalSize = size.toPhysical(scale)
        val x = physicalOrigin.x.toFloat()
        val y = physicalOrigin.y.toFloat()
        val width = physicalSize.width.toFloat()
        val height = physicalSize.height.toFloat()
        Paint().use { paint ->
            paint.color = 0xFF404040.toInt()
            canvas.drawRect(Rect.makeXYWH(x, y, width, height), paint)
        }
        Paint().use { paint ->
            paint.color = 0xFFAAAAAA.toInt()
            canvas.drawRect(Rect.makeXYWH(width * 0.75f, y, width * 0.25f, height), paint)
        }

        // Draw the color-changing square
        Paint().use { paint ->
            paint.color = colors[currentColorIndex]
            val squareSize = size.height
            val squarePhysicalX = (origin.x + (size.width - squareSize) / 2) * scale
            val squarePhysicalY = origin.y * scale
            val squarePhysicalSize = squareSize * scale
            canvas.drawRect(
                Rect.makeXYWH(
                    squarePhysicalX.toFloat(),
                    squarePhysicalY.toFloat(),
                    squarePhysicalSize.toFloat(),
                    squarePhysicalSize.toFloat(),
                ),
                paint,
            )
        }
    }