alexzhirkevich / custom-qr-generator

Android library for creating QR codes with logo, custom shapes, colors, background image. Powered by ZXing
MIT License
173 stars 18 forks source link

Need option to make all eyes different colours #29

Closed hardikbhalodi closed 1 year ago

hardikbhalodi commented 1 year ago

Is it possible to give different colours to eyes? right now colour applying to all eyes.

alexzhirkevich commented 1 year ago

Not possible at the moment and is not likely to be. Too colourful QR codes are hardly recognisable for scanners. Avoid doing it

alexzhirkevich commented 1 year ago

Will be possible after #35 with this code:

class DifferentColor() : QrVectorColor {

    override val mode: QrPaintMode = QrPaintMode.Separate

    override fun Paint.paint(width: Float, height: Float, neighbors : Neighbors) {
        when {
            neighbors.bottom &  neighbors.right -> // top left eye
            neighbors.bottomLeft -> top right eye
            neighbors.topRight -> // bottom left eye
            neighbors.topLeft -> // bottom right eye
        }
    }
}
alexzhirkevich commented 1 year ago

Available in 2.0.0-alpha01 with the code above