-
Notifications
You must be signed in to change notification settings - Fork 470
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
[iOS] RoundedRect clipping bug #1480
Comments
Could it be due to pixel rounding? |
Thanks for the fast reply.
Making use of |
Should we close the issue or do you think there is something that could/should be done on our side? |
you draw a rect of width 96 on a canvas of 95.999 and it looks like one pixel has been clipped because to some rounding. Where the rounding happened exactly because there are a lot of operations done related to pixel density on both RN and Skia at different places. |
Yes, the canvas actually rendering a width slightly less than the requested 96 is indeed causing the clipping. |
Update: I just found a workaround. So for e.g. marginLeft: Math.round(availableSpace / 2). |
@dylancom could roundToNearestPixel the size of the flex container work too? I will close this issue since the same would happen with a regular view? But if there is something specific to Skia here, please let us know and we will reopen this issue. |
Let me try it, thanks for the suggestion. It's specific to using this library. There is no clipping when I use regular views to create rounded buttons or circles. (I'm using this library though to create inner shadows, which I can't with a regular view) It also happened when I had a heading with a bottom border using StyleSheet.hairlineWidth and placing multiple circles, created with Skia, below. The bottom of the circles would be clipped by approx 1px. (Unless I add a negative margin top of the size of the hairlineWidth to the circles, which fixes the clipping). |
@dylacom This sounds interesting, could you provide us with a small example where you display these three buttons as RN View (and maybe set a border of harlineWidth) and then below have the same with Skia view instead? We will definitely investigate it if they produce a different result. |
@wcandillon see the following examples (https://github.com/dylancom/react-native-skia-clipping/blob/main/App.tsx): |
Thank you for the nice reproducible example, I can confirm that something is off here. |
Description
I am using react-native-skia so I can create buttons that use filters such as an "inner shadow".
When using multiple Rounded Rects, and centering them horizontally, I have noticed that some are clipped on the right by approx 1 pixel. If I remove the horizontal centering, the clipping bug disappears.
Notice the 3rd "button" not being perfectly rounded on the right.
When placing a background color on the
<Canvas>
I have noticed that it's the RoundedRect sometimes taking 1 pixel less on the right, but the Canvas itself always has the correct width.Version
0.1.182
Steps to reproduce
<Canvas>
and a<RoundedRect>
.<View>
that has a "row" direction.Snack, code example, screenshot, or link to a repository
https://github.com/dylancom/react-native-skia-clipping
The text was updated successfully, but these errors were encountered: