Skip to content

Instantly share code, notes, and snippets.

View zurche's full-sized avatar
👋

Alejandro Zurcher zurche

👋
View GitHub Profile
drawCircle(color=Color.Red, center = topLeftControlPoint1, radius = 4f)
drawCircle(color=Color.Blue, center = topLeftControlPoint2, radius = 4f)
cubicTo(
x1 = topLeftControlPoint1.x, // First Control Point X coordinate
y1 = topLeftControlPoint1.y, // First Control Point Y coordinate
x2 = topLeftControlPoint2.x, // Second Control Point X coordinate
y2 = topLeftControlPoint2.y, // Second Control Point Y coordinate
x3 = width.times(.25f), // Line End Point X coordinate
y3 = height.times(.02f) // Line End Point Y coordinate
)
val topLeftControlPoint1 = Offset(width.times(.02f), height.times(.03f))
val topLeftControlPoint2 = Offset(width.times(.03f), height.times(.02f))
@Composable
@Preview(showBackground = true)
fun BezierTest() {
Canvas(modifier = Modifier.size(300.dp), onDraw = {
val path = Path().apply {
val width = size.width // Capturing all the available width
val height = size.height // Capturing all the available height
// Top left corner
@Composable
@Preview(showBackground = true)
fun BezierTest() {
Canvas(modifier = Modifier.size(300.dp), onDraw = {
val path = Path().apply {
// Here's were we'll draw our custom shape's path
}
@Composable
fun MonthlyCapPreview(monthlyPreview: List<Pair<String, Float>>) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
val maxMonthValue = monthlyPreview.maxBy { it.second }.second
Row(
modifier = Modifier.fillMaxHeight(.8f),
verticalAlignment = Alignment.Bottom
) {
for (pairPreview in monthlyPreview) {
val columnHeightWeight = pairPreview.second / maxMonthValue
@Composable
fun MonthlyCapPreview(monthlyPreview: List<Pair<String, Float>>) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
val maxMonthValue = monthlyPreview.maxBy { it.second }.second
Row(
modifier = Modifier.fillMaxHeight(.8f),
verticalAlignment = Alignment.Bottom
) {
for (pairPreview in monthlyPreview) {
val columnHeightWeight = pairPreview.second / maxMonthValue
@Composable
fun MonthlyCapPreview(monthlyPreview: List<Pair<String, Float>>) {
val maxMonthValue = monthlyPreview.maxBy { it.second }.second
Row(
modifier = Modifier.fillMaxSize(),
verticalAlignment = Alignment.Bottom
) {
for (pairPreview in monthlyPreview) {
val columnHeightWeight = pairPreview.second / maxMonthValue
BarView(
@Composable
fun MonthlyCapPreview(monthlyPreview: List<Pair<String, Float>>) {
val maxMonthValue = monthlyPreview.maxBy { it.second }.second //<-- We find the max Float value of our Pair List
Row(
modifier = Modifier.fillMaxSize(),
verticalAlignment = Alignment.Bottom //<--- This is important to align them as required by spec
) {
for (pairPreview in monthlyPreview) {
val columnHeightWeight = pairPreview.second / maxMonthValue //<-- We use it to get a value between 0 and 1
Card(
@Composable
fun MonthlyCapPreview(monthlyPreview: List<Pair<String, Float>>) {
TODO("Not yet implemented")
}