question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bezierCurveTo incorrect path when performing stroke

See original GitHub issue

Expected Behaviour

Draw an oval 1. out

Actual Behaviour

draws a “flower” 1. out

Steps To Reproduce

points = [
  246, 338, 246, 382,
  246, 414, 300, 414,
  366, 414, 366, 371,
  366, 338, 327, 338
];
ctx.strokeColor = '#000';
ctx.beginPath();
     ctx.moveTo(points[i].p[14], points[i].p[15]); //each bezierCurve strangely centers back to the start point moveTo! 
    ctx.bezierCurveTo(points[i].p[14], points[i].p[15],points[i].p[0], points[i].p[1], points[i].p[2], points[i].p[3]);
    ctx.bezierCurveTo(points[i].p[2], points[i].p[3],points[i].p[4], points[i].p[5], points[i].p[6], points[i].p[7]);
    ctx.bezierCurveTo(points[i].p[6], points[i].p[7],points[i].p[8], points[i].p[9], points[i].p[10], points[i].p[11]);
    ctx.bezierCurveTo(points[i].p[10], points[i].p[11],points[i].p[12], points[i].p[13], points[i].p[14], points[i].p[15]);
    ctx.stroke();
    // if one uses ctx.fill() instead this will be an oval though


out_fill

Platform

OS: windows 11 Node Version: 17.0.1 NPM Version: latest PureImage Version: latest

Any Additional Info

similar behavior for ctx.quadraticCurveTo but this mostly not strokes at all.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
joshmarinaccicommented, Dec 9, 2021

I think I figured it out. The flatten_path is supposed to update the ‘curr’ variable in every segment of the path, but it wasn’t doing so for the Bezier curves. Can you test if the change above fixes it for you? Up can just add the one line above in the diff.

0reactions
joshmarinaccicommented, Dec 12, 2021

Oops. I forgot to npm build before publishing. Fixed. Look for 0.3.8

Read more comments on GitHub >

github_iconTop Results From Across the Web

CanvasRenderingContext2D.bezierCurveTo() - Web APIs | MDN
The CanvasRenderingContext2D.bezierCurveTo() method of the Canvas 2D API adds a cubic Bézier curve to the current sub-path.
Read more >
Bezier path stroking performance issues - Stack Overflow
Running the time profiling tool in Instruments it tells me my app is spending 93.5% of the time doing the last line [path...
Read more >
Paths — SVG 2
A path is defined by including a 'path' element on which the d property specifies the path data. The path data contains the...
Read more >
Parametrized stroke outlining / expanding / offsetting #371
I've been eagerly interested in the functionality to expand strokes into paths, particularly for bezier curves (where I know the problem is ...
Read more >
Stroke width control points disappearing - Beyond the Basics
I add a power stroke path effect ... Does anyone know what I'm doing wrong? ... Draw a curve with Bèzier tool (no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found