All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.org.jetbrains.letsPlot.livemap.mapengine.MapRenderContext.kt Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2023. JetBrains s.r.o.
 * Use of this source code is governed by the MIT license that can be found in the LICENSE file.
 */

package org.jetbrains.letsPlot.livemap.mapengine

import org.jetbrains.letsPlot.commons.geometry.DoubleVector
import org.jetbrains.letsPlot.core.canvas.CanvasProvider
import org.jetbrains.letsPlot.core.canvas.Context2d
import org.jetbrains.letsPlot.livemap.core.graphics.RenderObject
import org.jetbrains.letsPlot.livemap.mapengine.viewport.Viewport

open class MapRenderContext internal constructor(
    open val viewport: Viewport,
    val canvasProvider: CanvasProvider
) {
    fun draw(context: Context2d, origin: DoubleVector, renderObject: RenderObject) {
        draw(context, origin.x, origin.y, renderObject)
    }

    private fun draw(context: Context2d, x: Double, y: Double, renderObject: RenderObject) {
        context.save()
        context.translate(x, y)
        renderObject.render(context)
        context.restore()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy