Created
June 10, 2025 12:38
-
-
Save TemMax/5bbb01b87b1e864f340e681c1d22f109 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class DualLineFill( | |
private val fillBefore: Fill, | |
private val fillAfter: Fill, | |
) : LineCartesianLayer.LineFill { | |
private val paintBefore = Paint().apply { color = fillBefore.color } | |
private val paintAfter = Paint().apply { color = fillAfter.color } | |
private var markerX: Float? = null | |
fun updateMarkerX(x: Float?) { | |
markerX = x | |
} | |
override fun draw( | |
context: CartesianDrawingContext, | |
halfLineThickness: Float, | |
verticalAxisPosition: Axis.Position.Vertical?, | |
) { | |
with(context) { | |
fillBefore.brush?.applyTo(size = layerBounds.size, p = paintBefore, alpha = 1f) | |
fillAfter.brush?.applyTo(size = layerBounds.size, p = paintAfter, alpha = 1f) | |
canvas.withSave { | |
canvas.translate(layerBounds.left, layerBounds.top) | |
canvas.drawRect(0f, 0f, layerBounds.width, layerBounds.height, paintBefore) | |
markerX?.let { x -> | |
canvas.drawRect(x, 0f, layerBounds.width, layerBounds.bottom, paintAfter) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment