javascript

Initialize variables once in Javascript

implict's picture

How to initialize variable once in Javascript? I need to memorize and use old variables data. For example, in another programming environment, whenever executed some function, it can saves input arguments to array variable ; array.push(arg). So it makes possible to get some old data in array variable. But in qc, variables initialized newly at each frame. It is ok, not a way using Javascript. Does anybody help?

Structure merge

Swiftlikeninja's picture

I have a structure like the one in the attached picture, Im struggling with a means of combining all the indexes together. so for example the output structure would be ['61405075','6140232'], basically merging the structure together by index.

can anyone assist me with some javascript snippets to point me in the right direction?

Combine Like Keys into String

Swiftlikeninja's picture

I have been messing around with a javascript patch that will loop through a structure (about 1000 entries) and parse out the similar keys into single strings. the Code im using is as follows:

function (__structure structureOut) main ( __structure structureIn)
{
   if (!_testMode) {
 
        var Rebuild = new Object();
 
        for(i = 0; i <structureIn.length; i++) {
           Rebuild[structureIn[i][0]] +=structureIn[i][1];
          }
 
           var result = new Object();
           result.structureOut=Rebuild;
          return result;
   }
}

but the end results have an extra 'undefined' entry at the beginning of each new string. Can anyone explain why this is occurring? I've attached a sample compostion to better show.

Quartz Composer Physic | Collision

biro's picture

Hello everyone, I'm trying to simulate a physic system with collision detection in quartz, but with no results.

First thing first. I've downloaded the ParticleTool from the download section, with no results. Quartz is unable to find the tool in the library. (i've a mbp with os x 10.6.7 and the 0.3 version of particle tool) Despite this, i've decided to try with javascript (i'm feeling more comfortable with javascript or ActionScrip, and i found a lot of examples for them)

the question is: How can i do that with quartz? and if there's no way to make ParticleTools working on my mac, how can i do it with javascript?!

and why did apple made no user manual about quartz?! :(

Thank You so much!!!

Premature optimization question

randall's picture

Yes. This is premature optimization. I'll live.

So rather than build out a bunch of patches into a composition, I'm thinking about building a few master JS patches, and operating them like classes who send messages to each other.

The main reason is I'm building a server in Node.JS, and I figure sometimes I could move code into / out of Node for different reasons.

The premature optimization question is: Are JavaScript patches in QC a lot slower than the other patches? Are there any disadvantages to going JavaScript for logic?

I might just use JS anyway, but I'd love to be informed about the speed hit / any other downsides people are aware of.