Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Asking about the coordinate of points #18

Open
leviethung2103 opened this issue Mar 3, 2023 · 1 comment
Open

[Question] Asking about the coordinate of points #18

leviethung2103 opened this issue Mar 3, 2023 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@leviethung2103
Copy link

leviethung2103 commented Mar 3, 2023

Hello author,

strokes is the list of pair (x,y) coordinates. However, I does not understand why you multiply 255 and divide by width or height.

As far as I know, the width and height is equal to 400 ?

Is it just a normalization step to ensure the coordinates are consistent?

How did you define the magic number 255 ?

CleanShot 2023-03-03 at 12 48 34@2x

@obfusk obfusk self-assigned this Mar 4, 2023
@obfusk obfusk added the documentation Improvements or additions to documentation label Mar 4, 2023
@obfusk
Copy link
Owner

obfusk commented Mar 4, 2023

However, I does not understand why you multiply 255 and divide by width or height.

Because the coordinate system used by the library has north-west/top-left as (x=0,y=0) and south-east/bottom-right as (x=255,y=255).

Is it just a normalization step to ensure the coordinates are consistent?

So yes, unless you're already working in the same coordinate system, you need to map the coordinates used by your canvas (which in this case is indeed 400x400, not 255x255) onto the coordinate system used by the library.

In this case, that only requires making sure x and y are in the range 0-255 instead of 0-400, in other cases you may also need to account for the origin (x=0,y=0) being e.g. bottom-left (or in the middle) instead of top-left.

As it happens, the canvas used here can produce values outside the 0-400 range when you draw "over the edge" at sufficient velocity, so values can actually fall outside that range (#20); the JavaScript interface used by Jiten already handles this.

I've been meaning to document the API properly, but never got around to it; I did create an issue now: #19 😅

How did you define the magic number 255 ?

As the README says "the algorithms are based on the Kanji draw Android app", which also uses the range 0-255. A smaller range would probably have worked as well, but 2^8 seemed a reasonable choice so I used the same range.

@obfusk obfusk added question Further information is requested and removed question Further information is requested labels May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants