offline-qr-code
offline-qr-code copied to clipboard
Warning for inverted QR codes (when background color is dark and foreground light)
Similar to https://github.com/rugk/offline-qr-code/issues/19 there should be warning. But this time, it should just say that you can only scan such inverted Qr codes with some QR code readers (e.g. Android "Barcode reader" with a special option).
Maybe also create a wiki page (or FAQ?), for such a thing and explain how to scan it.
Depends on https://github.com/rugk/offline-qr-code/issues/19
I have separated the luminance calculation into it's own function in the gist I posted in the other issue.
Great, but did you see that @ENT8R already created an own PR, which includes the contrast (and thus, as it seems luminance) calculation: https://github.com/rugk/offline-qr-code/pull/86/files#diff-91ba5f4df12e1b6b0629662164b3f14eR245? (Although I'd think for code style reasons, your version really looks better, so @ENT8R you use that. Of course, you can also give @LMLB push access to that branch.)
But as for this issue (i.e. "finding out which color is dark/light") I don't think we need a new function for that luminance thing. Could not the contrast ratio calculation just return -3
or +3
(or speaking in general terms -x
/+x
) depending on in which order the colors are compared?
But if it is cleaner or easier with that additional functions, so be it. :smile:
You could replace Math.max(l1, l2)
with l1
and Math.min(l1, l2)
with l2
, then it returns a number less than 1 for inverted colors (assuming rgb1
is foreground and rgb2
is background).
Sounds good…
BTW, @LMLB, – I know, I am a bit late –, but if you wanna do a PR, feel free to do so.
But I've got some other color issues in this repo, too. :smile:
I am assuming you will do no PR, @LMLB.