nature-of-code / noc-book

The Nature of Code book (archived repo, see README for new repo / build system!)

Home Page:http://natureofcode.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chap 1 - Vector Subtraction - where to call translate()

dlehrich opened this issue · comments

Working through the Nature of Code w/ p5js. I'm using the p5 editor version 0.5.7

In the vector subtraction example (https://github.com/shiffman/The-Nature-of-Code-Examples-p5.js/blob/master/chp01_vectors/NOC_1_03_vector_subtraction/sketch.js)... if I run this code as-is, I see a line blip from the top left corner to center on frame 1, then no other lines. However, if I move the translate() call into setup(), the sketch behaves as expected.

Is this a possible issue with the p5 editor? Or has p5js syntax been updated to change the way translate() works?

Thanks!

This is this problem: processing/p5.js#1174. It has been fixed in newer version of p5. You can get the newer p5.js library file or just put push() at start of draw() and pop() at end as a temporary fix.