The documentation clearly states there is a Vector.prototype.reflect() method, but does not exist on the object.
https://p5js.org/reference/#/p5.Vector
I did a console.log(p5.Vector.prototype) and it’s definitely not there.
When creating a new sketch, the p5 version seems to be 0.10.2:
1 Like
https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.10.2/p5.js
There is no reflect() method in this file. Is this an older version?
Repro: go to p5js.org, create a new sketch, and see that reflect() does not exist.
1 Like
“index.html”:
<script async src=https://Unpkg.com/p5></script>
<script defer src=sketch.js></script>
Unpkg.com/p5/
1 Like
Vector.reflect was added in 1.0.0.
Editor.p5js.org is using 0.10.2 by default, as you linked, so it doesn’t have that feature.
If you want the web editor upgraded to 1.0.0 by default, consider opening an issue (if you haven’t already):
If you just want a 1.0.0 sketch in the web editor, edit your two script links in the sketch index.html file from 0.10.2
to 1.0.0
. Done.
Upgrade to 1.0.0 is now being merged and resolved.