
commonMain.render.components.AxisRenderer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chart-js Show documentation
Show all versions of chart-js Show documentation
A collection of drawing/charting utilities
package com.juul.krayon.chart.render.components
import com.juul.krayon.chart.render.Orientation
import com.juul.krayon.chart.render.Renderer
import com.juul.krayon.kanvas.Kanvas
import com.juul.krayon.kanvas.Paint
public class AxisRenderer(
private val style: Style,
) : Renderer {
public class Style(
public val orientation: Orientation,
public val stroke: Paint.Stroke?,
)
public data class Specification(
val startX: Float,
val startY: Float,
val end: Float,
)
override fun render(data: Specification, canvas: Kanvas) {
val strokePaint = style.stroke ?: return
val (endX, endY) = when (style.orientation) {
Orientation.Horizontal -> data.end to data.startY
Orientation.Vertical -> data.startX to data.end
}
canvas.drawLine(data.startX, data.startY, endX, endY, canvas.buildPaint(strokePaint))
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy