package com.casic.electric.detector.extensions

import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.RectF

fun Int.drawCircle(color: Int): Bitmap? {
    val bitmap = Bitmap.createBitmap(this * 2, this * 2, Bitmap.Config.ARGB_8888)
    val canvas = Canvas(bitmap)
    val paint = Paint()
    val rectF = RectF(0f, 0f, (this * 2).toFloat(), (this * 2).toFloat())
    paint.color = color
    canvas.drawArc(rectF, 0f, 360f, true, paint)
    return bitmap
}

fun Int.appendZero(): String {
    return if (this < 10) {
        "0$this"
    } else {
        this.toString()
    }
}