Sorting Colors with sortMode errors

I’m playing with examples in the “Generative Design” book - this example builds an array of colors from an image and then sorts them.

I get an error message:

Uncaught ReferenceError: gd is not defined (sketch: line 69)
Line 69 = gd.sortColors(colors, sortMode);

does this capability no longer exist? or done differently now? I can’t find any information about it in the online reference.

1 Like

gd seems to be an object derived from a class.

Did you import the library for generative design (gd)?

import generativedesign.*;

Do other sketches run?

Can you please share the link?

Hello,

Which example?

http://www.generative-gestaltung.de/1/code

:)

1 Like

Hi Chrisr - thanks for the reply!

I’m pretty new to coding. So far all the other sketches I’ve tried worked fine. While I have sublime installed I’ve not figured out how to use well yet and so I’ve been sticking to the P5 web editor. Should I be somehow uploading the library to the web editor?

Not sure what link you would be refering to…

Hi glv,

Hmm - I followed your link and this it the particular code I’m trying to run

http://www.generative-gestaltung.de/1/P_1_2_2_01

I do notice that the version of the package I installed via the url provide in the book is 1.1.0 and I see more current versions on your link. I’ve been copying the sketch files I downloaded into the web editor to run them. Per Chrisir’s reply perhaps I need to also upload a library?

1 Like

Apologies for multiple replies - looks like the versions on this link are for Processing, but I downloaded and am working with P5.js

Sorry for any confusion - I’m really new at this!

I also just noticed the P5.js:

http://www.generative-gestaltung.de/2/

I have both books and have yet to open them… a recent purchase.

:)

1 Like

The books are really great inspirations!

here is the P5 example
http://www.generative-gestaltung.de/2/sketches/?01_P/P_1_2_2_01

It is stuck on “Loading …” in the preview pane of P5 Editor.

Were you able to resolve this error? If you are running Generative Design sketches in Processing’s default Java mode, then you need to install the Generative Design library through the PDE Contributions Manager.

It works with this:
http://www.generative-gestaltung.de/2/sketches/?01_P/P_1_2_2_01

It works if I install this:


I had to install option 2 as per README.md to launch same page (as above example) and run it locally. I already had Node.js so it was simple for me. The other examples did not require the server; just this one and I could run just opening index.html for examples.

:)

1 Like