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

Thumbnail position calculation #3516

Merged

Conversation

paulJordaan
Copy link
Contributor

Description

Fix Y position calculation for the getThumbnails funtion.
Fixes #3511

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

Checklist:

  • I have signed the Google CLA https://cla.developers.google.com
  • My code follows the style guidelines of this project
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have verified my change on multiple browsers on different platforms
  • I have run ./build/all.py and the build passes
  • I have run ./build/test.py and all tests pass

positionX = (thumbnailPosition % columns) / columns * fullImageWidth;
positionY = (thumbnailPosition % rows) / rows * fullImageHeight;
positionX = (thumbnailPosition % columns) * width;
positionY = Math.floor(thumbnailPosition / columns) * height;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be: Math.floor(thumbnailPosition / rows) * height;

(columns vs rows)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avelad I've checked the logic again and the use of columns is correct. Consider the following as per the unit test.
Grid of 2x3 100x150px:

[0][1]
[2][3]
[4][5]

Requesting the position of thumbnail 5 using your suggested edit would result in the following:

Math.floor(thumbnailPosition / rows) * height
Math.floor( 5 / 3) * 50
1 * 50
yPosition = 50

The correct position for thumbnail 5 should be:

x= 50
y= 100

@shaka-bot
Copy link
Collaborator

All tests passed!

@joeyparrish joeyparrish merged commit 097c9a1 into shaka-project:master Jul 9, 2021
joeyparrish pushed a commit that referenced this pull request Jul 13, 2021
Fix Y position calculation for the `getThumbnails` function of Player.

Fixes #3511
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

player.getThumbnails incorrectly calculates the Y position
4 participants