ProgrammingJavaScript

Random -copy-paste work around

caseyfarina's picture

What is the best way (or your way) to work around the fact that QC copies the same seed when a random controller is copied?

It is really unsustainable to drag in a new instance of "random controller" for large patches and macros.

Thanks, this forum is a great resource, First time poster long time reader.

Structure sort question

psonice's picture

I have a question on structure sorting, perhaps somebody can help.

I'm creating a bunch of structures with queues. Then, I feed all of the structures into a javascript patch, and combine them into a new 'structure of structures, using something like:

struct[0] = input0; struct[1] = input1; ... etc. and returning struct. It works fine, but the output structure is in some random order! I've tried using "struct['a']" and so on, it's no different, I see 0: 'e' structure.. then 1: 'k' structure etc.

I've tried using the structure sort patch, but I'll be damned if I can figure it out. Leaving it without a descriptor, the input is e,k,.. and the output is p,e,... The same thing happens with numbers.

Any ideas? Is this some kind of bug? It sure doesn't look 'expected' :/

JavaScript Text Messings

toneburst's picture

Just for a change, I thought I'd have a go with some JavaScript text effects in QC. This is the result. It's not very spectacular, but could form the basis of something more interesting, especially if combined with a custom font, or some nice animation of individual characters.

I've tried to make it as flexible and modular as possible. Each JS module outputs a complete string and a structure of individual characters, which could be passed into an Iterator for animation.

Hope it proves useful for someone out there.

Javascript

snerg's picture

Hi,

Does any one have some good resources on Javascript programming in QC?

I noticed some off the official examples don't use main functions and let you select how many inputs/outputs the javascript patch has.

However if I create a new javascript patch I can't get it to run without a main function and it never shows the options to specify the number of inputs/outputs, what am I doing wrong?

This is what I'm getting at:

http://iome.nl/javascript1.tiff http://iome.nl/javascript2.tiff

Snerg

Select from arrays

kyma's picture

I'm using iterator to create a short array of cubes. Now I want to select individual cubes from the array using the index and (for example) change its colour or shape properties. I have connected Iterator Variables/Iterations to the Structure index member and then I'm using a javascript if statement to test whether it is the same as the current iteration. My javascript is:

if ( inputs[0] == inputs[1]) {
   outputs[0]=6;
}else {
outputs[0] = 1;
};

But for some reason it is never true. Can anyone help with this simple problem?