gabrielflorit / gabrielflorit/script-8.github.io

Inconsistent behavior with polyStroke()

Open
#314 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
CSS
Stars
640
Forks
34
PR merge metrics
No merged PRs in 30d

Description

I noticed that `polyStroke()` has a quirk, where given 2 or 5 arguments, it draws unclosed polygons, i.e.:

```js
polyStroke([
// empty array as last point
[0,0], [64, 0], [64, 64], []
], 5)
```

image

When given 3 arguments however, it doesn't draw anything. I'm guessing this behavior appears because [this](https://github.com/script-8/script-8.github.io/blob/a60a494976db12e65cc21517b9637b05a0d858a8/src/iframe/src/frameBufferCanvasAPI/polyStroke.js#L18):
```js
Math.min.apply(
Math,
[[0,0], [1,1], []].map(p => p[0])
)
```

...would return `NaN`

Since drawing unclosed polylines has plenty of use-cases, perhaps this behaviour should be parametrized, and unified across the different drawing implementations?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.