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

Cubic curves degenerate to lines #42

Closed
tuzhong007 opened this issue Mar 23, 2023 · 1 comment · Fixed by #43
Closed

Cubic curves degenerate to lines #42

tuzhong007 opened this issue Mar 23, 2023 · 1 comment · Fixed by #43

Comments

@tuzhong007
Copy link

tuzhong007 commented Mar 23, 2023

The following code draws a cubic Bezier curve from (0, 100) to (150, 100) whose control points are (50, 50) and (150, 100). In addition, the control points are connected by line strips.

skity::Paint paint;
  paint.setAntiAlias(true);
  paint.setStyle(skity::Paint::kStroke_Style);
  skity::Point cubicPts[] = {
      {0, 100, 0, 1}, {50, 50, 0, 1}, {100, 150, 0, 1}, {150, 100, 0, 1}};
  skity::Color color = 0xff88ff00;
  paint.setColor(0x7fffffff & color);
  paint.setStrokeWidth(1);
  for (unsigned j = 0; j < 3; ++j) {
    //     canvas->drawLine(cubicPts[j], cubicPts[j + 1], paint); //.
    canvas->drawLine(cubicPts[j].x, cubicPts[j].y, 
        cubicPts[j + 1].x,cubicPts[j + 1].y, paint);
  }
    skity::Path path;
    path.moveTo(cubicPts[0]);
    path.cubicTo(cubicPts[1], cubicPts[2], cubicPts[3]);
    paint.setStrokeWidth(3);
    paint.setColor(color);
    canvas->drawPath(path, paint);

But the result of cubic curve is a horizontal line segment:
image

@RuiwenTang
Copy link
Owner

Thanks for reporting this. I checked this code in my local project, and is fixed.
image
I will push this patch in this weekend.

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 a pull request may close this issue.

2 participants