p5 lib static + instance dual implementation ?


This isn't technically a 'using p5' question, but I'm getting into writing my own client side js libraries and I wanted to see how p5 used both static and instance versions of functions such as p5.Vector.sub() ... so take a look here:


I'm guessing lines 282-284 are the static version, but why does the function reference the x, y, z that belong to 'this' before returning it ? Aren't those instance variables ? It also performs -= on them, so surely if you use the static version more than once, won't it be affected by all the previous times you used it ?

Many thanks for any pointers.

Thx, Loz


Sign In or Register to comment.