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

Scale image from center in HeroImageFlowDelegate #17

Merged
merged 1 commit into from
Jul 17, 2023

Conversation

yunusemrebakir
Copy link
Collaborator

Description

This PR modifies the _HeroImageFlowDelegate class to scale the image from the center instead of the top left corner.

Problem

The hero image was scaling from the top left corner and this was causing the image to look not-centered.
To fix this, we now scale the image from the center.

In the updated code, we calculate the translationX and translationY values to shift the image by half of the difference between the container size and the scaled image size. Then, we create a Matrix4 object using Matrix4.identity() and apply both the scaling and translation using the scale and translate methods respectively. Finally, we pass the resulting transformMatrix to the transform property of flowPaintingContext.paintChild.
With this modification, the image should be scaled from the center instead of the top left.

Screenshots

Phone

Before After

Tablet

Before After

@yunusemrebakir yunusemrebakir requested a review from ulusoyca July 17, 2023 09:18
@ulusoyca ulusoyca merged commit 30301c5 into main Jul 17, 2023
@yunusemrebakir yunusemrebakir deleted the fix-hero-image-scaling-position branch July 17, 2023 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants