# Bezier Glitch in certain point combinations

**URL:** <https://discourse.processing.org/t/bezier-glitch-in-certain-point-combinations/32169>\
**Category:** p5.js\
**Created:** [September 9, 2021, 8:52pm UTC](https://discourse.processing.org/t/bezier-glitch-in-certain-point-combinations/32169 "2021-09-09T20:52:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreiantonescu](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andreiantonescu/32/14279_2.png) [@andreiantonescu](https://discourse.processing.org/u/andreiantonescu)\
**Post date:** [September 9, 2021, 8:52pm UTC](https://discourse.processing.org/t/bezier-glitch-in-certain-point-combinations/32169/1 "2021-09-09T20:52:46Z")

</div>

Hi,

I’ve reached some weird behaviour for bezier curves between browsers. There are some combinations of anchors and control points that produce a glitch like this:

 ![Screenshot 2021-09-09 at 23.34.45](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a8c33a54aa3b7d40287d0ca88eaa4ee2e79e47bb.png)  
(right is the correct curve)

If I slightly change the positions of the anchor and control points, this does not happen anymore. Additionally, this seems browser-related and only happens on certain browsers on my machine (Chrome).

Example: [Bezier Glitch - OpenProcessing](https://openprocessing.org/sketch/1258357)

Does anyone have any idea behind why this happens and how to solve it? Thanks!

---

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [September 9, 2021, 9:24pm UTC](https://discourse.processing.org/t/bezier-glitch-in-certain-point-combinations/32169/2 "2021-09-09T21:24:50Z")

</div>

Strange. I can reproduce the issue on my browser (Brave (Chromium) on MacOS), but I cannot reproduce it directly with canvas, so it does look like an issue with p5.js. I’d have to step through with a debugger to see what’s going on. Here’s the working raw canvas implementation:

```auto
<html>
<head>
<title>Bezier Curve Test</title>
</head>
<body>
<canvas id="disp" width="300" height="300"></canvas>
<script>
const disp = document.getElementById('disp');
const ctx = disp.getContext('2d');

ctx.fillStyle = 'dimgray';
ctx.fillRect(0, 0, disp.width, disp.height);

ctx.fillStype = undefined;
ctx.strokeStyle = 'limegreen';

ctx.translate(10, 100);

ctx.lineTo(108.87, 3.78);
ctx.bezierCurveTo(
    201.1, -128.61,
		34.21, 82.54,
		134.14, 126.01
);
ctx.stroke();

</script>
</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [September 10, 2021, 9:12am UTC](https://discourse.processing.org/t/bezier-glitch-in-certain-point-combinations/32169/3 "2021-09-10T09:12:07Z")

</div>

In the left example you have fill enabled so you get a solid triangle with vertices corresponding to the Bezier control points.

I suspect the different browsers apply fill differently, I suggest you use `noFill()`

---

<div class="post-metadata">

**Author:** ![andreiantonescu](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andreiantonescu/32/14279_2.png) [@andreiantonescu](https://discourse.processing.org/u/andreiantonescu)\
**Post date:** [September 10, 2021, 11:03am UTC](https://discourse.processing.org/t/bezier-glitch-in-certain-point-combinations/32169/4 "2021-09-10T11:03:54Z")

</div>

@quark I already have noFill() declared at the start of draw(). It doesn’t make any difference (for me) if I remove noFill() or add it before each bezier call.

@KumuPaul that’s interesting! I can confirm that using your code the issue does not reproduce anymore. What’s more intriguing is that I tried using the canvas drawing context provided in p5js and in that case it still happens, see here: [Bezier Glitch Canvas Context - OpenProcessing](https://openprocessing.org/sketch/1258755)

---

<div class="post-metadata">

**Author:** ![andreiantonescu](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andreiantonescu/32/14279_2.png) [@andreiantonescu](https://discourse.processing.org/u/andreiantonescu)\
**Post date:** [September 10, 2021, 3:54pm UTC](https://discourse.processing.org/t/bezier-glitch-in-certain-point-combinations/32169/5 "2021-09-10T15:54:01Z")

</div>

Another interesting thing: if I set Stroke cap to SQUARE, the curve still has issues, but displays differently:

 ![Screenshot 2021-09-10 at 18.53.11](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5bafc2298cb39cb99ceca949fad454ff0618a4b6.png)
