Created
November 10, 2020 09:46
-
-
Save svinouze/e3aece645cd9feeeb75f6b9b13db6625 to your computer and use it in GitHub Desktop.
This file contains 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
class SegmentCoordinatesComputer { | |
fun segmentCoordinates(position: Int, segmentCount: Int, width: Float, spacing: Float): SegmentCoordinates { | |
[...] | |
} | |
fun progressCoordinates(progress: Int, segmentCount: Int, width: Float, spacing: Float): SegmentCoordinates { | |
val segmentWidth = (width - spacing * (segmentCount - 1)) / segmentCount | |
val isLast = progress == segmentCount | |
val topRight = segmentWidth * progress + spacing * max(0, progress - 1) | |
val bottomRight = segmentWidth * progress + spacing * max(0, progress - 1) | |
return SegmentCoordinates(0f, topRight, 0f, bottomRight) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment