offline-qr-code icon indicating copy to clipboard operation
offline-qr-code copied to clipboard

Warning for inverted QR codes (when background color is dark and foreground light)

Open rugk opened this issue 6 years ago • 6 comments

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

rugk avatar Apr 16 '18 13:04 rugk

I have separated the luminance calculation into it's own function in the gist I posted in the other issue.

LMLB avatar May 20 '18 18:05 LMLB

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:

rugk avatar May 20 '18 21:05 rugk

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).

LMLB avatar May 21 '18 07:05 LMLB

Sounds good…

rugk avatar May 21 '18 07:05 rugk

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:

rugk avatar Aug 05 '18 18:08 rugk

I am assuming you will do no PR, @LMLB.

rugk avatar Apr 24 '19 18:04 rugk