Color touching color

  1. What browsers show this problem?

Chromium Version 76.0.3809.87 (Official Build) Built on Ubuntu , running on Ubuntu 18.04 (64-bit)

Also Firefox 68.0.1 (64-bit)

  1. Please share an example project (if possible).

https://snap.berkeley.edu/snap/snap.html#present:Username=colinbye&ProjectName=touching%20problem

  1. Describes the steps to reproduce this issue.

run project

  1. What does Snap! currently do?

Depending on which direction the wagon sprite approaches the colours sprite the color touching block produces different answers

  1. What should Snap! do instead?

Answer should be Touching regardless of direction

Hmm, works for me. Gang?

Doesn't work for me (e.g I get same issue as OP)
Win 10 Chrome

image

Fails here too. Here's a simplified version:

https://snap.berkeley.edu/snap/snap.html#present:Username=bromagosa&ProjectName=touching%20problem%20remix

Fails in Chrome 75.0.3770.100 @Win 10 full screen
Works as expected in design mode with medium stage.
Don't work at all with small stage (always "not touching")

With default canvas antialiasing single source pixel makes colorful pattern. Resolution, color depth, stage scale may result in different pattern. Maybe there are even no single pixel with exactly this "yellow" touching "green".
Sometimes color matching can be based on range instead of exact. For ex: RGB values with stripped 1-2 lower bits.
Attached screen dump enlarged with Paint.
image
.
Maybe single pixel-wide objects on edge are unintenionally cropped by rouding of position and/or dimension. I made red pixel sticked to the yellow "nose" and color detection works flawless.
image

Ah, thanks for debugging it! Maybe it works for me because of my retina display.

It's tempting to turn off antialiasing and just live with jaggies but sharp edges.

Under DEV mode there is color sensing with tolerance. touching%20problem%20remix%20script%20pic
For me sensing with tolerance>0 works as expected for this case.

Boy, you learn something every day! I guess this is something Jens is still playing with.

I've looked further at this. I've modified the original sprite so that it now has blocks of solid colour and produced a simpler version of the project

https://snap.berkeley.edu/snap/snap.html#present:Username=colinbye&ProjectName=touching%20problem%202

This still displays the same behaviour.

Here's a blown up version of what appears when the sprite is to the right of the colour sprite and the project says Not Touching.

Checked different sprite positions and found that probably first row and first column of pixels is ignored during the touching test. Dad said it's probably a typical problem "does indexing start from 1 or from 0?".

I verified my son's findings and tested
Morph.prototype.isTouching@morphic.js with changed dimensions

.getImageData(0, 0, oImg.width, oImg.height)
This way it works as expected.

BTW. how to proceed bug submited by forum which lead to Guthub PR and
what should be "first choice" for submitting bugs: GH/Issues or this forum.
:

Wow, thanks, team! A bug report with the solution attached is the best kind! :~)

If you have a Github account then Github is best. Certainly for a PR Github is essential. But this bug might not have been fixed so quickly if reported on Github, which has a smaller audience following Snap!, so I don't know for sure. A bug that doesn't get fixed here will end up copied to Github by one of the staff.

Submited PR Sprite touching : first row, column included, Issue #2476 by DarDoro · Pull Request #2477 · jmoenig/Snap · GitHub

Thank you!

Here:
Windows 10 with
FF 68.0.1 (64-Bit) > works fine
Chrome Version 76.0.3809.100 (Official Build) (64-bit) > works also fine
Sorry, I couldn't reproduce the problem.

Can You try
https://snap.berkeley.edu/snap/snap.html#present:Username=dardoro&ProjectName=untouchables
with:
Browser zoom: 100%
Disabled Retina
Small stage (non full screen) or windowed browser (800x600 window)
OR
forced large stage dimension (it's prevents automatic sprite enlarge)

Yes, it seems to have something to do with the dithering of the sprites in smaller windows. Beyond a certain size (approx. 3 times the usual size) it works good, under that it doesn't touch.