Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Jscript in Quartz Composer.

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 01-18-2009, 06:25 PM PM User | #1 nestor New to the CF scene   Join Date: Jan 2009 Posts: 2 Thanks: 0 Thanked 0 Times in 0 Posts Jscript in Quartz Composer. Hi all, I am transitioning some of my work with iterated function systems and attractor sets to quartz composer from Pd/GEM. I am very excited that apple chose to include the extensibility of a great scripting language like JS, since QC lacks objects such as arrays and persistent storage for strings and nums. I haven't touched JS since highschool. My eventual goal is to build a javascript object that iterates functions for X,Y, and Z values: x2 = (x1+1.12)*(y1+1.2)*1.24
 01-18-2009, 07:08 PM PM User | #2 jkd Senior Coder     Join Date: May 2002 Location: metro DC Posts: 3,163 Thanks: 1 Thanked 18 Times in 18 Posts An IFS is a list of (A,b,p), where, at each iteration, starting from x0, you choose from the list randomly (such that each list tuple is chosen with probability p) and update by setting x = Ax+b, yes? I would try something like this (and this would allow for non-linear transforms as well): Code: ```// Define your transforms here var list = new Array(); list.push( // Choose x = Ax+b 50% of the time, where: // A = [a,b,c;d,e,f;g,h,i] and b = [j;k;l] [0.5, function(x) { return [ a*x[0]+b*x[1]+c*x[2] + j, d*x[0]+e*x[1]+f*x[2] + k, g*x[0]+h*x[1]+i*x[2] + l ]; }]); list.push( // Choose x = [x_1;x_2;sin(x_3) / (x_1*x_2)] the other 50% of the time [0.5, function(x) { return [ x[0], x[1], Math.sin(x[2]) / x[0] / x[1] ]; }]); // construct the CDF of probabilities var cdf = new Array(list.length); cdf[0] = list[0][0] for (var i = 1; i < list.length; i++) { cdf[i] = cdf[i-1] + list[i][0]; } // now whenever you need an appropriately distributed transformation, call getTransform() // it returns a function. For example: // var t = getTransform(); x = t(x); function getTransform() { var r = Math.random(); for (var i = 0; i < cdf.length; i++) { if (r <= cdf[i]) return list[i][1]; } }``` Should be enough to get you started at least. __________________ jasonkarldavis.com
 01-19-2009, 04:45 PM PM User | #3 nestor New to the CF scene   Join Date: Jan 2009 Posts: 2 Thanks: 0 Thanked 0 Times in 0 Posts thanks jkd, Thanks a lot. That looks great, I'll have to pick it over with a fine-toothed comb! The problem that I've run into with QC is the persistence of vars(arrays included.) It seems that the JS is recompiled with every frame, so in order to have persistent variables over time, they must be inside of objects. I admit that I am new to OOP, yet I understand the concepts. Also, I think the IFS is a big first step for me, so I am going to try an attractor set using the iteration method. For instance: the clifford attractor: xn+1 = sin(a yn) + c cos(a xn)
yn+1 = sin(b xn) + d cos(b yn)
So I think the first step for me is to create a simple objects which iterates a function and stores it at an output each time it is rendered(each frame). For example, a counter, which I am having enough trouble with as it is.

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 06:16 AM.