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

Rendering Path with start and end properties not rendering correctly in 0/90/180/270 degree angles, #2826

Open
ivanloy opened this issue Dec 20, 2024 · 0 comments

Comments

@ivanloy
Copy link

ivanloy commented Dec 20, 2024

Description
When rendering a Path in a canvas with start and end properties, if one of them causes the path to end in a 0/90/180/270 angle in the screen (Like 25%/50%/75% of a full circle, for example), it causes the end to render erratically and not straight. It only happens at certain dimensions, could not find the relation on which break there. Making the path bigger or smaller solves the issue, but at some points it breaks like this.

Image
Image

Version
1.7.6 is latest checked, has been broken since before 1.0. React Native CLI. React native 0.75.2
Happening on Android, on a Pixel Pro 7. Has been seen and fixed itself in the past on iPhone X and iPhone 12.

Steps to reproduce
Run the following code on android. Any path with enough thickness for it to be visible, with start and end properties, one of them making it cut in a straight angle, should work.

Snack, code example, screenshot, or link to a repository

const getPath = () => {
  const radius = 107;
  //Have suspicions that this not being an integer is an issue, seems to work with 195.4, but other hardcoded decimal values here kill it. Only in 
  //straight angles though, if I try this on any other path it works as intended. Shouldn't break with a float I imagine though? Since an svg path can 
  //have decimals without issues
  const centerX = 195.5;
  const centerY = 174;
  const matrix = Skia.Matrix();
  matrix.translate(centerX, centerY);
  matrix.rotate(ONE_QUARTER_CIRCLE_RADIANS);
  matrix.translate(-centerX, -centerY);

  const skPath = Skia.Path.Make().addCircle(centerX, centerY, radius);
  skPath.transform(matrix);
}

export const GaugeDoughnut = () => {
  const path = getPath();
  const trimmingValues = [{"end": 0.7333333333333334, "start": 0.5}];

  return (
    <Group>
      {trimmingValues.map((trimming, index) => 
         <GaugeDoughnutArc key={`gauge-arc-${index}`} path={path} trimming={trimming} color={"red"} />;
      )}
    </Group>
  );
};

export const GaugeDoughnutArc = ({path, trimming, color}: GaugeDoughnutArcProps) => {
  const strokeWidth = 42;
  return (
    <Path
      path={path}
      color={color}
      style="stroke"
      strokeWidth={strokeWidth}
      start={trimming.start}
      end={trimming.end}
    />
  );
};
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

No branches or pull requests

1 participant