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

Documentation unclear about features #33

Closed michaelWuensch closed 1 year ago

michaelWuensch commented 1 year ago

Describe the option you are trying to implement Hi, I try to create a QR code with random circle sizes and colors with the vector implementation. Is this possible? The instagram example is only provided with the deprecated method.

It feels like this should be simple, but I can't find a way how to do this. Thanks for your help.

P.S: If it is not possible yet I would love to see this feature implemented.

alexzhirkevich commented 1 year ago

Random colors for individual pixels are not available at the moment. As for random shapes, you can do it the same way as for deprecated one:

class RandomPixelShape(
    private val from : List<QrVectorShapeModifier>
) : QrVectorPixelShape {
    override fun createPath(size: Float, neighbors: Neighbors): Path {
        return from.random().createPath(size, neighbors)
    }
}
 shapes {
    darkPixel = RandomPixelShape(
        listOf(
            QrVectorPixelShape.Circle(.3f),
            QrVectorPixelShape.Circle(.5f),
            QrVectorPixelShape.Circle(.7f),
        )
    )
}
image
michaelWuensch commented 1 year ago

Thanks, this worked! I now wanted to try to make random solid colors (3 slightly different variations). I tried to make it similar like your example above, but for some reason always one color is chosen randomly for the whole QR code instead of the pixels. Does CreatePaint not get executed for every pixel?

alexzhirkevich commented 1 year ago

Random colors for individual pixels are not available at the moment.

Well...

Does CreatePaint not get executed for every pixel?

All pixels are combined to a single path before applying a paint so you can make them gradient

michaelWuensch commented 1 year ago

Ok, thanks, so it is not possible with the vector method. Damn. Thanks for your help anyway.

alexzhirkevich commented 1 year ago

Will be possible after #35.

You can test it now in a com.github.alexzhirkevich:custom-qr-generator:separate_painting-SNAPSHOT snapshot and give a feedback

michaelWuensch commented 1 year ago

Thanks, that one was fast! I am looking forward to the next release!

alexzhirkevich commented 1 year ago

Available in 2.0.0-alpha01