# Strange behaviour for bezier() in subpixel stroke weight

**URL:** <https://discourse.processing.org/t/strange-behaviour-for-bezier-in-subpixel-stroke-weight/31875>\
**Category:** p5.js\
**Created:** [August 24, 2021, 8:11am UTC](https://discourse.processing.org/t/strange-behaviour-for-bezier-in-subpixel-stroke-weight/31875 "2021-08-24T08:11:30Z")\
**Posts on this page:** 2\
**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:** [August 24, 2021, 8:11am UTC](https://discourse.processing.org/t/strange-behaviour-for-bezier-in-subpixel-stroke-weight/31875/1 "2021-08-24T08:11:30Z")

</div>

Hello there.

I’ve encountered some strange behaviour for bezier() when using subpixel (\<0.49) stroke weights. This seems to happen only on some curve configurations and only on **Chrome** :

> **[Debug - OpenProcessing](https://openprocessing.org/sketch/1244219)**

 ![Screenshot 2021-08-24 at 16.01.50](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d83b1e2c1d1055bb84022c3a969e0441b2f06817.png)

The curve on the top has a glitch when going from .51 to .49 stroke weight. What is strange is that if I slightly change the curve’s configuration, it doesn’t happen anymore (see curve on the bottom).

Note that on Safari this does not happen - I believe it is due to how the browsers handle subpixel stroke weights (in Safari the .51 line seems a lot thicker).

Does anyone have any direction as to how to solve this?

Thanks,  
Andrei

---

<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:** [August 24, 2021, 5:15pm UTC](https://discourse.processing.org/t/strange-behaviour-for-bezier-in-subpixel-stroke-weight/31875/2 "2021-08-24T17:15:38Z")

</div>

So, after more research, this seems to be an issue around how different browsers handle sub-pixel line weights (not related to p5js). The only solution I found was not to use sub-pixel line weights.

For reference, if anyone encounters problems with this I recommend:

- for lines that should be \< 1px, draw them at 1px but change their alpha. So if you would like to draw a line at 0.45px, draw it at 1px with 45% alpha
- draw all lines at \>1px and then scale down by the needed amount
