package com.isidroid.rendering.ext

import com.isidroid.rendering.model.PrintCanvas

fun PrintCanvas.rotate() = copy(
    width = height,
    height = width,
    marginTop = marginLeft,
    marginLeft = marginTop,
    printWidth = printHeight,
    printHeight = printWidth
)

internal fun scaledPrintCanvas(sizes: PrintCanvas, scale: Float): PrintCanvas {
    val width = sizes.width * scale
    val height = sizes.height * scale
    val printWidth = sizes.printWidth * scale
    val printHeight = sizes.printHeight * scale

    val marginLeft = sizes.marginLeft * scale
    val marginTop = sizes.marginTop * scale
    val marginRight = width - printWidth - marginLeft
    val marginBottom = height - printHeight - marginTop

    return PrintCanvas(
        width = width,
        height = height,
        printWidth = printWidth,
        printHeight = printHeight,
        marginLeft = marginLeft,
        marginTop = marginTop,
        marginRight = marginRight,
        marginBottom = marginBottom
    )
}