alexzhirkevich/custom-qr-generator

Documentation unclear about features

Closed this issue · 7 comments

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.

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

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?

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

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

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

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

Available in 2.0.0-alpha01