5 kyu
Canvas Fun #3: Draw Screen Unlock Pattern
Loading description...
Puzzles
Graphics
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
I don't like this. My perfectly valid solution is getting rejected, because of floating point errors. My math and drawing procedures are solid, but because the test cases expect bit-to-bit accuracy (which can be impossible to achieve cross-browser/cross-OS with Canvas), my solution isn't not going through.
For example, take a look at my drawing vs. test case here: https://i.imgur.com/q0YkNSp.png You might not even see the difference, yet there are sub-pixel inaccuracies, and I'm absolutely sure it's not my code that's causing those. It's inherent to Canvas API implementations.
Check out this page: https://browserleaks.com/canvas
As you can see, it will give you a uniqueness percentage, of how your browser draws a set of drawing instructions. The uniqueness is likely quite high too. What this means, is that your browser produces a different image from other browsers, so by definition, expecting pixel-perfect, bit-to-bit accuracy in this Kata is misguided.
The way I see it, there are two ways around this problem:
Instead of checking for bit-to-bit accuracy, calculate the difference between test and actual images, and check if it's below a certain threshold. Problem with this is that it might allow some actual bugs go through, or it might not let a valid, but complex image go through
Instead of using pre-rendered data for the test-cases, generate the test data within the tests, so that differences in canvas rendering will also be present in the test images.
Sorry for not actually taking a look at the kata in detail, however browser compatibility problems are very unlikely here. All tests are run on the server in a pretty well-defined environment.
For details the kata author would need to chime in...
This comment has been hidden.
Please kindly mark your content as having spoiler.
replace the gray hollow circle with a "yellow" hollow circle
A. initially draw a yellow hallow? B. draw a gray hollow then draw a yellow one in the same position? (i.e. cover the gray hollow using a yellow one)
A. draw all lines first? B. draw all hollows first? C. draw the first hollow, the first line, the second hollow?
A. moveTo the first point, lineTo the second, lineTo the third..., and stroke only once? B. moveTo the first, lineTo the second, stroke. moveTo the second, lineTo the third, stroke...?
In case
seq=[1,2,3]
, the expected color of the top pixel of all actived hollows are #AFAF11, #D2D217, #D2D217 They should be the same right?I am on my bed, so I cant test the situation of different order of drawing. Do you mean they will be different?
for [123], I just using "yellow" as the color of circle
1.B 2and3.draw yellow circle if need, then draw a singe lline
IDK, but it is canvas, floating error can lead to
hellanything. (Which is why we can have Canvas Fingerprinting)Then why the color of three hollows in the result are not identical. (currently it is
1 != 2
and2 == 3
)o_O
O_o
Hello, can we get a definitive answer to this please?
This answer is really vague.
the answer was written in the description already ;-)
This comment has been hidden.
It seems that you are not drawing the image according to order strictly. Perhaps I can write a conpare function to calculate the similarity with my reference image. Please wait.
This comment has been hidden.