We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, Very new to this, so terminology may well be misused/missing, but hopefully you'll get the gist.
I've come across a Java based script called Tracery - http://www.crystalcodepalace.com/traceryTut.html This code allows users to create a statement which randomly changes key words - see link above for clarity.
My question is: How can I import Tracery script into Processing and use it? I've looked online without success so thought I'd ask the forum.
Your help would be appreciated.
Richard
Answers
from that page
not a "Java based script" but "javascript".
there are details of how to use it on the github page: https://github.com/galaxykate/tracery
Hi koogs,
Yes I looked on the github but I couldn't see anything referring to it working within Processing? Can you highlight the link?
This seems to me it is along the lines of rita.js:
As far as I know, and as koogs has pointed it out, the above library and rita.js are written in javascript which is not the same as java. You can get the code working in processing if you are in p5.js mode, which is javascript. However, when you say Processing in your posts the way you do, people think you are trying to use a javascript lib in java, which it is not going to work.
You can ask directly the owner of the above library and see if he/she knows if there is an equivalent library in java. Then you could use that in Processing.
Kf
(the Q is in the us library category, I took that to mean that the OP was using JavaScript processing)
The instructions aren't processing specific, it's just a link to the library and the call you have to make to generate the text from the grammar. Doesn't look too involved, if you are using p5.js.
Hi kfrajer & koogs,
Thanks to you both for your patience and assistance. OK, message received over Java and Javascript; as mentioned this is very new territory for me :) Thankyou for the tip/link over p5.js I'll venture that way and also it appears the owner has a twitter link too. Thanks!
minimal example. NB i don't use javascript ever so the scoping and stuff for this might all be wrong.
click mouse to regenerate.
in the html file i added BEFORE THE OTHER INCLUDES
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="tracery.min.js"></script>
tracery.min.js is from the tracery download, copied into the libraries folder of the sketch, the jquery is loaded from the google cdn.
main sketch
(i've been using cbdq and tracery for a year or so now. with a bit of thought you can get it to generate svg files and draw all sorts of things:
https://cheapbotsdonequick.com/
)
@koogs -- Interesting -- I'm working on a project with html+css blocks embedded in SVG files right now, and I hadn't thought about Tracery for something like SVG output.
...I'll post a link to the forum sometime soon.
(it's an odd little 'language' in that it has no calculations and no conditions other than giving it a bunch of alternatives and letting it choose randomly between them. source code for the above is here: https://cheapbotsdonequick.com/source/gamedpylori the rest of the examples on the site are more traditional story-generating things)
Interesting. That sounds a bit like ContextFree, only for text instead of geometric primitives.
https://www.contextfreeart.org/gallery2/