From pnyboer at slambassador.com Thu May 1 13:46:11 2008 From: pnyboer at slambassador.com (pnyboer) Date: Thu May 1 13:46:15 2008 Subject: [javascript-dev] js with set function and using javascript to set value... Message-ID: <22368.481a1e01@www.cycling74.com> I'm using this javascript to set values of various max objects: function anything(){ post(" example",messagename,arguments[0]); var knob = this.patcher.getnamed(messagename); knob.set(arguments[0]); } if I try to "set" the value of a jsui this way, I get the error: • error: js: junk.js: Javascript TypeError: knob.set is not a function, line 4 • error: js: error calling function jsknob But the jsui does have a "set" function in it! This happens in Max 4x and Max 5. Here's a patch that illustrates this, call the above javascript "junk.js": #P window setfont "Sans Serif" 9.; #P window linecount 1; #P comment 101 217 75 196617 References: <22368.481a1e01@www.cycling74.com> Message-ID: <18DEE707-5A5B-4963-882A-459FB06F1AB3@musork.com> For JSUI or other objects which have methods hidden inside via the "anything" method. Use the message() synax o.message("set", whatever); -Joshua From pnyboer at slambassador.com Fri May 2 10:18:52 2008 From: pnyboer at slambassador.com (pnyboer) Date: Fri May 2 10:18:55 2008 Subject: [javascript-dev] Re: js with set function and using javascript to set value... In-Reply-To: <22368.481a1e01@www.cycling74.com> Message-ID: <2240e.481b3eec@www.cycling74.com> ah, right. thanks for the clue! P -- * * * * The Altamont 2 oz light rum 3/4 oz lime juice 1/2 oz orange cura?ao 1/4 oz orgeat splash of pernod handful of fresh mint leaves shake contents vigorously with ice. Strain well into a chilled cocktail glass. * * * * From pnyboer at slambassador.com Fri May 2 10:20:49 2008 From: pnyboer at slambassador.com (pnyboer) Date: Fri May 2 10:20:52 2008 Subject: [javascript-dev] @-style attributes in js... Message-ID: <2240f.481b3f61@www.cycling74.com> just wanted to confirm...it's still not possible to use @-style attributes in javascript in max 5? (or, has it been possible all along, and i just didn't know it?) Pboer -- * * * * The Altamont 2 oz light rum 3/4 oz lime juice 1/2 oz orange cura?ao 1/4 oz orgeat splash of pernod handful of fresh mint leaves shake contents vigorously with ice. Strain well into a chilled cocktail glass. * * * * From sxa at whiterabbitdesign.co.uk Sun May 4 04:59:43 2008 From: sxa at whiterabbitdesign.co.uk (sean ahern) Date: Sun May 4 04:59:46 2008 Subject: [javascript-dev] Re: @-style attributes in js... In-Reply-To: <2240f.481b3f61@www.cycling74.com> Message-ID: <22502.481d971e@www.cycling74.com> In 4.6, I just parse them using some prewritten code. Basically, I create the variable and default value, and add its name to an array of valid attribute names. Then I parse jsarguments for properly-formed pairs which match the format @ATTR1 VALUE (checking for the presence of ATTR1 in the atribute array). Finally I use an eval to set the value of a variable corresponding to the attribute name (ATTR=VALUE). My parser also handles position-dependent arguments. Apart from the code used to do the parsing etc (which isnt particularly optimised, so about 60 lines long), which could be included in a code template, that reduces my argument and attribute parsing to the following: args = new argHandler; // note - declare arguments in order; var ARG1 = 100; args.setUpArgument("ARG1"); var ARG2 = 0; args.setUpArgument("ARG2"); var ATTR1 = 100; args.setUpAttribute("ATTR1"); args.argumentParser(jsarguments); // required : reads and evals supplied arguments args.reportAttributes(); // posts all attributes as per a non-js patcher From nat-list at studioimaginaire.com Mon May 5 15:32:12 2008 From: nat-list at studioimaginaire.com (Nathanaël Lécaudé) Date: Mon May 5 15:32:16 2008 Subject: [javascript-dev] presentation mode property ? Message-ID: <225bd.481f7cdb@www.cycling74.com> Is there a way to detect whether the user is in Patching or Presentation mode from JavaScript ? Thanks. Nat From c74-mailinglists at e--j.com Mon May 5 17:26:14 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Mon May 5 17:26:20 2008 Subject: [javascript-dev] presentation mode property ? In-Reply-To: <225bd.481f7cdb@www.cycling74.com> References: <225bd.481f7cdb@www.cycling74.com> Message-ID: <78A9E430-0E79-4B45-8CD2-E1FA627AAACF@e--j.com> On 5 mai 08, at 23:32, Nathana?l L?caud? wrote: > Is there a way to detect whether the user is in Patching or > Presentation mode from JavaScript ? Nope. In fact this is a tricky thing because patching/presentation modes are views on the same thing (a patch), so you might be able to see multiple views of the same js/jsui object. ej From nat-list at studioimaginaire.com Mon May 5 17:31:50 2008 From: nat-list at studioimaginaire.com (Nathanaël Lécaudé) Date: Mon May 5 17:31:53 2008 Subject: [javascript-dev] Re: presentation mode property ? In-Reply-To: <78A9E430-0E79-4B45-8CD2-E1FA627AAACF@e--j.com> Message-ID: <225d4.481f98e3@www.cycling74.com> Wouldn't be possible to make max.frontpatcher report this ? Basically the active patcher would report what mode it is in ? It seems very import to me to have this feature. For example, in my ToolBox I have a function to distribute objects in space that a lot of users rely on. To make it work in presentation mode I need to know what mode the patch is in... Thanks, Nat From mobley8 at mac.com Sat May 10 16:48:57 2008 From: mobley8 at mac.com (goggle13) Date: Sat May 10 16:48:59 2008 Subject: [javascript-dev] inkjet, laser or thermal Printing from Max/Msp or Jitter Message-ID: <227fe.48262659@www.cycling74.com> Has anyone ever created a patch that would allow you to print a still from max or jitter before? I need to find some way of making this happen. If someone has anything to offer to this matter, please do so, I would greatly appreciate it. Thanks! From elmiller at berklee.net Sun May 11 12:19:54 2008 From: elmiller at berklee.net (eric miller) Date: Sun May 11 12:19:58 2008 Subject: [javascript-dev] checking status of an objects connections Message-ID: <2283b.482738ca@www.cycling74.com> Hi I apologize if this is a foolish question... I am new to js, and I am wondering if there is a way to check if an object is connected to anything. I know how to connect or disconnect objects, but essentially I am trying to ask if obj a is connected to obj b, if not then connect, if so then disconnect. I couldn't find it in the documentation. Thanks! From c74-mailinglists at e--j.com Sun May 11 12:58:07 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Sun May 11 12:58:16 2008 Subject: [javascript-dev] checking status of an objects connections In-Reply-To: <2283b.482738ca@www.cycling74.com> References: <2283b.482738ca@www.cycling74.com> Message-ID: <6878586F-6160-4B99-AB45-48E339EC6113@e--j.com> On 11 mai 08, at 20:19, eric miller wrote: > I apologize if this is a foolish question... > > I am new to js, and I am wondering if there is a way to check if an > object is connected to anything. I know how to connect or disconnect > objects, but essentially I am trying to ask if obj a is connected to > obj b, if not then connect, if so then disconnect. I couldn't find > it in the documentation. It's not possible to achieve that in JS. ej From elmiller at berklee.net Sun May 11 13:17:21 2008 From: elmiller at berklee.net (eric miller) Date: Sun May 11 13:17:24 2008 Subject: [javascript-dev] Re: checking status of an objects connections In-Reply-To: <6878586F-6160-4B99-AB45-48E339EC6113@e--j.com> Message-ID: <22840.48274641@www.cycling74.com> thanks. From apalomba at austin.rr.com Mon May 12 13:24:51 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Mon May 12 13:24:54 2008 Subject: [javascript-dev] Processing ported to javascript... Message-ID: <228a1.48289982@www.cycling74.com> Apparently someone went to the trouble of porting Processing to javascript... http://ejohn.org/blog/processingjs/ Is there a way to load this port into Max and do Processing graphics in a jsui object? From j at jasch.ch Mon May 12 15:18:26 2008 From: j at jasch.ch (=?ISO-8859-1?Q?jasch_=A0?=) Date: Mon May 12 15:19:11 2008 Subject: [javascript-dev] Processing ported to javascript... In-Reply-To: <228a1.48289982@www.cycling74.com> References: <228a1.48289982@www.cycling74.com> Message-ID: <18732D00-EA85-450F-A0EB-75F65D97B068@jasch.ch> how about using jweb? not sure how much of the javascript processing stuff Webkit actually supports, but a preliminary test shows promising results. try this: http://www.jasch.ch/dl/processing_js.zip cheers /*j > Apparently someone went to the trouble of porting > Processing to javascript... > http://ejohn.org/blog/processingjs/ > > Is there a way to load this port into Max and do Processing > graphics in a jsui object? From apalomba at austin.rr.com Mon May 12 15:41:40 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Mon May 12 15:41:44 2008 Subject: [javascript-dev] Re: Processing ported to javascript... In-Reply-To: <18732D00-EA85-450F-A0EB-75F65D97B068@jasch.ch> Message-ID: <228af.4828b993@www.cycling74.com> As far as I know jweb does not allow you to pass data from processing to your outside patch (or vice versa). Integrating processing into jsui would allow the processing source to have direct access to Max mouse events. Theoretically that is... It says that the port uses "Canvas Element" to do the drawing. Does jsui support this interface? From johnpoupinel at hotmail.com Tue May 13 13:32:26 2008 From: johnpoupinel at hotmail.com (Bertrand Fraysse) Date: Tue May 13 13:32:29 2008 Subject: [javascript-dev] Re: Processing ported to javascript... In-Reply-To: <228a1.48289982@www.cycling74.com> Message-ID: <2290c.4829ecc9@www.cycling74.com> Looking forward to see if it's possible to use it in jsui. It would soooo great. From apalomba at austin.rr.com Fri May 16 10:57:51 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Fri May 16 10:57:55 2008 Subject: [javascript-dev] Re: Processing ported to javascript... In-Reply-To: <2290c.4829ecc9@www.cycling74.com> Message-ID: <22aad.482dbd0f@www.cycling74.com> Can I please get some feedback from anybody at Cycling... From apalomba at austin.rr.com Fri May 16 11:03:42 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Fri May 16 11:03:49 2008 Subject: [javascript-dev] Strange "undefined" problem using screentoworld... Message-ID: <22ab1.482dbe6d@www.cycling74.com> I have the following code sample... wxyz = sketch.screentoworld(SizeW/2,SizeH/2); post("wxyz =", wxyz, " "); this.NodeList[0].x = wxyz.x; this.NodeList[0].y = wxyz.y; //this.NodeList[0].x = 0.0; //this.NodeList[0].y = 0.0 this.NodeList[0].z = 1.0; When I try to use screentoworld, and assign the value to x and y, I get an "undefined" result. The output looks like this... NodeGraph dump: 1 nodes. node 0 : 1 If I comment in the commented out lines I get this... NodeGraph dump: 1 nodes. node 0 : 0.0 0.0 1 It looks like using the values returned from screentoworld causes some problem. Can anyone see a reason why it would do this? Thanks, Anthony From danjel at gmail.com Fri May 16 22:34:59 2008 From: danjel at gmail.com (Danjel van Tijn) Date: Fri May 16 22:35:02 2008 Subject: [javascript-dev] reading from different inlets Message-ID: <22ad7.482e6072@www.cycling74.com> Ok I must be missing something painfully obvious in concept but I have been bashing my head on this for a while now. This should be so simple: I am making a js object to process a CC# and it's CC value (from a CTLIN object). I assume I would do this by defining a js object that has 2 inlets? or should it be just 1 inlet? How do I read the second inlet? This is what I am missing somehow. Here is an example of how I would expect to use the code: inlets = 1; outlets = 2; function msg_int(cc) { var val = inlet(1); //This does not work switch(cc) { case 1: outlets(0,val); break; case 2: outlets(0,val); break; } } help is appreciated! From c74-mailinglists at e--j.com Sat May 17 00:46:04 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Sat May 17 00:46:11 2008 Subject: [javascript-dev] reading from different inlets In-Reply-To: <22ad7.482e6072@www.cycling74.com> References: <22ad7.482e6072@www.cycling74.com> Message-ID: On 17 mai 08, at 06:34, Danjel van Tijn wrote: > > Ok I must be missing something painfully obvious in concept but I > have been bashing my head on this for a while now. > > This should be so simple: > > I am making a js object to process a CC# and it's CC value (from a > CTLIN object). I assume I would do this by defining a js object that > has 2 inlets? or should it be just 1 inlet? > > How do I read the second inlet? This is what I am missing somehow. In order to read the second inlet, you need a second inlet: inlets = 1; Then in your function, you just need to read the contents of the inlet property (the inlet index starts at 0): function msg_int(v) { if (inlet == 1) // right inlet else // left inlet } HTH, ej From mdk at relivethefuture.com Sat May 17 06:46:36 2008 From: mdk at relivethefuture.com (mdk) Date: Sat May 17 06:46:41 2008 Subject: [javascript-dev] Re: Processing ported to javascript... In-Reply-To: <228af.4828b993@www.cycling74.com> Message-ID: <22ae3.482ed3aa@www.cycling74.com> Quote: Anthony Palomba wrote on Mon, 12 May 2008 23:41 ---------------------------------------------------- > It says that the port uses "Canvas Element" to do the drawing. > Does jsui support this interface? ---------------------------------------------------- here's the spec for the 2d rendering context in the canvas element : http://www.whatwg.org/specs/web-apps/current-work/multipage/section-the-canvas.html#canvasrenderingcontext2d so if you can map that to jsui (or the subset of that interface which is used by the js processing implementation) then you are part of the way there. :) as to whether jweb supports the canvas element, i would think it does in osx as its part of webkit. whereas on the PC I believe the jweb component is IE, so you would have to use this : http://excanvas.sourceforge.net/ but of course the difficulty with jweb is how to get data in and out. :) From stormbind at gmail.com Sun May 18 09:42:17 2008 From: stormbind at gmail.com (Glen) Date: Sun May 18 09:42:21 2008 Subject: [javascript-dev] setting up inlets and outlets Message-ID: <22b38.48304e58@www.cycling74.com> Hi all, This is a most fundamental of problems and searching the forum for inlets or outlets gives a few unrelated replies. Max does not like the way I have declared the following because it stubbornly keeps only one inlet and one outlet. Please help. // some global statements inlets = 2; outlets = 2; function msg_ing(a) { // some local statements outlet(1, a); // js: bad outlet index 1 } Thank you. From c74-mailinglists at e--j.com Sun May 18 11:57:21 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Sun May 18 11:57:31 2008 Subject: [javascript-dev] setting up inlets and outlets In-Reply-To: <22b38.48304e58@www.cycling74.com> References: <22b38.48304e58@www.cycling74.com> Message-ID: On 18 mai 08, at 17:42, Glen wrote: > Hi all, > > This is a most fundamental of problems and searching the forum for > inlets or outlets gives a few unrelated replies. > > Max does not like the way I have declared the following because it > stubbornly keeps only one inlet and one outlet. Please help. > > // some global statements > inlets = 2; > outlets = 2; > > function msg_ing(a) { > // some local statements > outlet(1, a); // js: bad outlet index 1 > } That should work if you write "js yourjsfile.js" in a box, it should appear with 2 inlets and 2 outlets. How are you instantiating your js object? ej From stormbind at gmail.com Mon May 19 03:48:57 2008 From: stormbind at gmail.com (Glen) Date: Mon May 19 03:49:04 2008 Subject: [javascript-dev] Re: setting up inlets and outlets In-Reply-To: <22b38.48304e58@www.cycling74.com> Message-ID: <22b92.48314d08@www.cycling74.com> Yeah, I seem to have path problems. When I loaded MAX at the start of the day, it could not identify the script at all. When I make a parent patcher referencing my script, that script is missing. However, if I close and reload the parent patcher, my script appears OK. Could someone please explain because I have an open-book exam in a couple of hours and speeeeeeed is important :( From stormbind at gmail.com Mon May 19 03:59:00 2008 From: stormbind at gmail.com (Glen) Date: Mon May 19 04:02:13 2008 Subject: [javascript-dev] Re: setting up inlets and outlets In-Reply-To: <22b38.48304e58@www.cycling74.com> Message-ID: <22b93.48314f64@www.cycling74.com> Also, *ahem*, if someone could tell me very quickly how to separate values from each inlet I would be super-grateful. Sorry for not taking time to look this up. I'm swept off my feet with Jitter revision, lol.. From c74-mailinglists at e--j.com Mon May 19 04:02:09 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Mon May 19 04:02:53 2008 Subject: [javascript-dev] Re: setting up inlets and outlets In-Reply-To: <22b92.48314d08@www.cycling74.com> References: <22b92.48314d08@www.cycling74.com> Message-ID: <950FB0D9-B0A8-484D-85CF-ECAE1AF7AB39@e--j.com> On 19 mai 08, at 11:48, Glen wrote: > > Yeah, I seem to have path problems. When I loaded MAX at the start > of the day, it could not identify the script at all. > > When I make a parent patcher referencing my script, that script is > missing. However, if I close and reload the parent patcher, my > script appears OK. > > Could someone please explain because I have an open-book exam in a > couple of hours and speeeeeeed is important :( The simple (quick and dirty) solution is to save the script in the same folder as your main patch: MyFolder: ./mypatch.pat (maxpat if it's Max 5) ./myabstraction.pat ./myimage.jpeg ./myjsfile.js Then you can just name your [js myjsfile.js] and it will find it, because the folder containing the main patch is always added (temporarily) to the search path. ej From stormbind at gmail.com Mon May 19 06:04:02 2008 From: stormbind at gmail.com (Glen) Date: Mon May 19 06:04:07 2008 Subject: [javascript-dev] distinguishing between inlets Message-ID: <22b9b.48316cb1@www.cycling74.com> Hi, inlets = 2; outlets = 2; function msg_int(a){ // receives value from inlet 0 outlet(0, 100-a); // sends value to outlet 0 outlet(1, a); // sends value to outlet 1 } How can I read the value from inlet 1? With such wisdom, I'll be able to take over the world!! Currently helpless. Thanks very much, From stormbind at gmail.com Mon May 19 06:29:45 2008 From: stormbind at gmail.com (Glen) Date: Mon May 19 06:29:51 2008 Subject: [javascript-dev] Re: distinguishing between inlets In-Reply-To: <22b9b.48316cb1@www.cycling74.com> Message-ID: <22b9e.483172b9@www.cycling74.com> The reason the manual isn't helping me is because it states [b]inlet(no, get)[/b] yet inlet is not a function it also [i]implies[/i] using msg_int(a, b, c..) and this happens: function msg_int(a, b){ post(a); // will output a or b post(b); // nothing } From gusanomaxlist at googlemail.com Mon May 19 06:45:59 2008 From: gusanomaxlist at googlemail.com (gusano) Date: Mon May 19 06:46:06 2008 Subject: [javascript-dev] Re: distinguishing between inlets In-Reply-To: <22b9e.483172b9@www.cycling74.com> References: <22b9e.483172b9@www.cycling74.com> Message-ID: <48317687.5040006@gmail.com> I think Emmanuel already answered this few days ago... Ciao // ----------------------------------------------- inlets = 2; function msg_int(v) { if (inlet == 1) { post(); post(v, "in right inlet"); } else { post(); post(v, "in left inlet"); } } // ----------------------------------------------- From c74-mailinglists at e--j.com Mon May 19 06:47:36 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Mon May 19 06:47:45 2008 Subject: [javascript-dev] Re: distinguishing between inlets In-Reply-To: <22b9e.483172b9@www.cycling74.com> References: <22b9e.483172b9@www.cycling74.com> Message-ID: <9D396797-0C0E-4FC9-A88E-081253DC87BF@e--j.com> On 19 mai 08, at 14:29, Glen wrote: > > The reason the manual isn't helping me is because it states > [b]inlet(no, get)[/b] yet inlet is not a function > > it also [i]implies[/i] using msg_int(a, b, c..) and this happens: > > function msg_int(a, b){ > post(a); // will output a or b > post(b); // nothing > } if you send a list to your js object you need to use a list function function list(a, b) { post(a); // first list item post(b); // second list item } To know from which inlet a message arrived in your js, you need to look at the inlet property (a variable). So: inlets = 2; // define the number of outlets of your js object function msg_int(v) { if (inlet == 1) // second inlet post(v, " was received in the second inlet\n"); else post(v, "was received in the left inlet\n"); } HTH, ej From apalomba at austin.rr.com Mon May 19 08:24:26 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Mon May 19 08:24:33 2008 Subject: [javascript-dev] Re: Strange "undefined" problem using screentoworld... In-Reply-To: <22ab1.482dbe6d@www.cycling74.com> Message-ID: <22baf.48318d9a@www.cycling74.com> Anybody? From stormbind at gmail.com Mon May 19 10:30:49 2008 From: stormbind at gmail.com (Glen) Date: Mon May 19 10:30:54 2008 Subject: [javascript-dev] Re: distinguishing between inlets In-Reply-To: <22b9b.48316cb1@www.cycling74.com> Message-ID: <22bc6.4831ab39@www.cycling74.com> Thanks guys! :) Its too late for my exam, but I'll remember it for the future. From c74-mailinglists at e--j.com Mon May 19 10:34:07 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Mon May 19 10:34:15 2008 Subject: [javascript-dev] Re: Strange "undefined" problem using screentoworld... In-Reply-To: <22baf.48318d9a@www.cycling74.com> References: <22baf.48318d9a@www.cycling74.com> Message-ID: <545B30FE-014F-4884-9A1D-7FD9B00C8E81@e--j.com> On 19 mai 08, at 16:24, Anthony Palomba wrote: > Anybody? Could you post a clear example, that demonstrates the issue.screentoworld works fine here, so I doubt the problem is there. ej From apalomba at austin.rr.com Mon May 19 11:16:02 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Mon May 19 11:16:11 2008 Subject: [javascript-dev] Re: Re: Strange "undefined" problem using screentoworld... In-Reply-To: <545B30FE-014F-4884-9A1D-7FD9B00C8E81@e--j.com> Message-ID: <22bd1.4831b5d2@www.cycling74.com> Okay here is an example... test.pat... #P window setfont "Sans Serif" 9.; #P window linecount 1; #P message 320 91 39 9109513 random; #P message 240 91 55 9109513 not_correct; #P user jsui 240 137 64 64 1 0 0 test.js; #P message 182 91 37 9109513 correct; #P connect 3 0 1 0; #P connect 2 0 1 0; #P connect 0 0 1 0; #P window clipboard copycount 4; test.js... //////////////////////////////////////////////////////////////////////////////////////////// // Outlet/Inlet declarations // Set number if inlets (jsui method) inlets = 1; // Set number if outlets (jsui method) outlets = 1; //////////////////////////////////////////////////////////////////////////////////////////// // global code sketch.default3d(); var NodeList = new Array(); NodeList[0] = new Node(); //////////////////////////////////////////////////////////////////////////////////////////// // functions function correct() { post("NodeGraph dump: ", NodeList.length, "nodes. "); for(var i = 0; i < NodeList.length; i++) { post("node", i, ": ", NodeList[i].x, NodeList[i].y, NodeList[i].z, " "); } NodeList[0].x = 0.0; NodeList[0].y = 0.0 NodeList[0].z = 1.0; post("NodeGraph dump: ", NodeList.length, "nodes. "); for(var i = 0; i < NodeList.length; i++) { post("node", i, ": ", NodeList[i].x, NodeList[i].y, NodeList[i].z, " "); } } function not_correct() { post("NodeGraph dump: ", NodeList.length, "nodes. "); for(var i = 0; i < NodeList.length; i++) { post("node", i, ": ", NodeList[i].x, NodeList[i].y, NodeList[i].z, " "); } wxyz = sketch.screentoworld(100/2,100/2); post("wxyz =", wxyz, " "); NodeList[0].x = wxyz.x; NodeList[0].y = wxyz.y; //this.NodeList[0].x = 0.0; //this.NodeList[0].y = 0.0 NodeList[0].z = 1.0; post("NodeGraph dump: ", NodeList.length, "nodes. "); for(var i = 0; i < NodeList.length; i++) { post("node", i, ": ", NodeList[i].x, NodeList[i].y, NodeList[i].z, " "); } } function random() { NodeList[0].x = (Math.random()-0.5)*2; NodeList[0].y = (Math.random()-0.5)*2; NodeList[0].z = (Math.random()-0.5)*2; post("NodeGraph dump: ", NodeList.length, "nodes. "); for(var i = 0; i < NodeList.length; i++) { post("node", i, ": ", NodeList[i].x, NodeList[i].y, NodeList[i].z, " "); } } ///////////////////////////////////////////////////////////////////////////////////////////////// // Node Class // Node Constructor function Node(id) { post("Node Constructor... "); //this.x = (Math.random()-0.5)*2; //this.y = (Math.random()-0.5)*2; //this.z = (Math.random()-0.5)*2; this.x = (Math.random()-0.5)*2; this.y = (Math.random()-0.5)*2; this.z = (Math.random()-0.5)*2; this.r = 0.0; this.Data = 0.0; this.Text = ""; } // Node member Variables: Node.prototype.x = 0.0; Node.prototype.y = 0.0; Node.prototype.z = 0.0; Node.prototype.r = 0.0; Node.prototype.g = 0.0; Node.prototype.b = 0.0; Node.prototype.radius = 0.0; Node.prototype.Data = 0.0; Node.prototype.Text = ""; From c74-mailinglists at e--j.com Mon May 19 11:34:50 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Mon May 19 11:35:01 2008 Subject: [javascript-dev] Re: Re: Strange "undefined" problem using screentoworld... In-Reply-To: <22bd1.4831b5d2@www.cycling74.com> References: <22bd1.4831b5d2@www.cycling74.com> Message-ID: <0A0AAA51-6E88-436D-A3C5-D48B058137C6@e--j.com> On 19 mai 08, at 19:16, Anthony Palomba wrote: > Okay here is an example... > > test.pat... > > #P window setfont "Sans Serif" 9.; > #P window linecount 1; > #P message 320 91 39 9109513 random; > #P message 240 91 55 9109513 not_correct; > #P user jsui 240 137 64 64 1 0 0 test.js; > #P message 182 91 37 9109513 correct; > #P connect 3 0 1 0; > #P connect 2 0 1 0; > #P connect 0 0 1 0; > #P window clipboard copycount 4; sketch.screentoworld() returns an array, where the first item is x, y is the second, ? and z the third. So you should do something like that: wxyz = sketch.screentoworld(100/2,100/2); NodeList[0].x = wxyz[0]; NodeList[0].y = wxyz[1]; NodeList[0].z = wxyz[2]; HTH, ej From apalomba at austin.rr.com Mon May 19 12:56:24 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Mon May 19 12:56:29 2008 Subject: [javascript-dev] Re: Re: Re: Strange "undefined" problem using screentoworld... In-Reply-To: <0A0AAA51-6E88-436D-A3C5-D48B058137C6@e--j.com> Message-ID: <22be4.4831cd58@www.cycling74.com> Ahhh, yes. Thank you! From Stefan-Tiedje at addcom.de Mon May 19 15:02:40 2008 From: Stefan-Tiedje at addcom.de (Stefan Tiedje) Date: Mon May 19 15:02:48 2008 Subject: [javascript-dev] transparency in jsui Message-ID: <4831EAF0.9030903@addcom.de> I wanted to get a transparent back ground in the jsui_360dial.js. I simply replaced the line var vbrgb = [1.,1.,1.,1.]; with var vbrgb = [1.,1.,1.,0.]; It doesn't seem to work. Is it possible at all, or do I miss the too obvious?... I thought glclearcolor(vbrgb[0],vbrgb[1],vbrgb[2],vbrgb[3]); or glclearcolor(vbrgb); followed by glclear() should just execute it... The other question would be, if it is possible to define attributes in js which would appear in the jsui inspector. That would be nice for colours for example... Stefan -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|\-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com From c74-mailinglists at e--j.com Mon May 19 15:35:34 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Mon May 19 15:35:42 2008 Subject: [javascript-dev] transparency in jsui In-Reply-To: <4831EAF0.9030903@addcom.de> References: <4831EAF0.9030903@addcom.de> Message-ID: On 19 mai 08, at 23:02, Stefan Tiedje wrote: > I wanted to get a transparent back ground in the jsui_360dial.js. I > simply replaced the line Transparency of a jsui object is not currently available. This is something which will happen at some point in the future though. > The other question would be, if it is possible to define attributes > in js which would appear in the jsui inspector. That would be nice > for colours for example... If you declare an attribute, it automatically appears in the js/jsui inspector: var foo = 74; declareattribute(foo); HTH, ej From Stefan-Tiedje at addcom.de Mon May 19 23:31:21 2008 From: Stefan-Tiedje at addcom.de (Stefan Tiedje) Date: Mon May 19 23:31:30 2008 Subject: [javascript-dev] transparency in jsui In-Reply-To: References: <4831EAF0.9030903@addcom.de> Message-ID: <48326229.8060006@addcom.de> Emmanuel Jourdan schrieb: > Transparency of a jsui object is not currently available. This is > something which will happen at some point in the future though. Too bad, is there a way to find out the colour a jsui is sitting on? The I could do a fake transparency... > If you declare an attribute, it automatically appears in the js/jsui > inspector: > > var foo = 74; > declareattribute(foo); I tried this and simply added: declareattribute(vbrgb); declareattribute(vfrgb); declareattribute(vrgb2); and yes they show up, but instead of the attribute name I see the default values, not too helpful as description, and when changing them they don't seem to pass the values... And if it would work, it would be nice if the examples of all these jsui examples in the help file reflect this. Then it would not be necessary to define the colours with arguments... Stefan -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|\-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com From Stefan-Tiedje at addcom.de Tue May 20 00:42:56 2008 From: Stefan-Tiedje at addcom.de (Stefan Tiedje) Date: Tue May 20 00:43:07 2008 Subject: [javascript-dev] Javascript documentation. Message-ID: <483272F0.2060300@addcom.de> The see also section of the javascript tutorials do not point to the other tutorials, and I haven't found any link to a javascript reference for max 5 anywhere. I wanted to find out about the patcher method "newobject" for scripting, and unfortunately the example in the old JavascriptInMax pdf has an example which doesn't help too much... The tutorial 2 creates ctlins which are too big, but how to create them with a proper width? It points to the newobject method, but I can't find any reference how to use it in Max 5... But (not) learning the patcher methods by trial and error isn't too much fun... I usually come along well with examples I can modify... Stefan -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|\-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com From c74-mailinglists at e--j.com Tue May 20 01:20:51 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Tue May 20 01:20:58 2008 Subject: [javascript-dev] Javascript documentation. In-Reply-To: <483272F0.2060300@addcom.de> References: <483272F0.2060300@addcom.de> Message-ID: On 20 mai 08, at 08:42, Stefan Tiedje wrote: > I wanted to find out about the patcher method "newobject" for > scripting, and unfortunately the example in the old JavascriptInMax > pdf has an example which doesn't help too much... You can use the send message. Then the syntax will be the same as the one demonstrate in the "Making new objects" subpatcher of the thispatcher help file. For instance: this.patcher.message("script", "newobject", "comment", "@varname", i + "_unitlabel", "@presentation_rect", 280, y, 130, 20, "@patching_rect", 280, y, 130, 20, "@presentation", 1, "@text", ppList[i].unit, "@fixwidth", 1 ); ej From c74-mailinglists at e--j.com Tue May 20 01:33:15 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Tue May 20 01:33:56 2008 Subject: [javascript-dev] transparency in jsui In-Reply-To: <48326229.8060006@addcom.de> References: <4831EAF0.9030903@addcom.de> <48326229.8060006@addcom.de> Message-ID: <3DC67521-2E37-4F21-B954-5051823FCCC2@e--j.com> On 20 mai 08, at 07:31, Stefan Tiedje wrote: > Too bad, is there a way to find out the colour a jsui is sitting on? > The I could do a fake transparency... suckhah? If you need real transparency, you can also send commands to lcd. > I tried this and simply added: > > declareattribute(vbrgb); > declareattribute(vfrgb); > declareattribute(vrgb2); > > and yes they show up, but instead of the attribute name I see the > default values, not too helpful as description, and when changing > them they don't seem to pass the values... > > And if it would work, it would be nice if the examples of all these > jsui examples in the help file reflect this. Then it would not be > necessary to define the colours with arguments... Here's an example. It display toto and bgcolor as attribute name in the inspector. bgcolor is saved with the patcher. var toto = 74; var bgcolor = [ 1., 1., 0.6, 0.8 ]; declareattribute("toto"); declareattribute("bgcolor", null, null, 1); function bang() { post(toto, "\n"); post(bgcolor, "\n"); } ej From Stefan-Tiedje at addcom.de Tue May 20 03:04:57 2008 From: Stefan-Tiedje at addcom.de (Stefan Tiedje) Date: Tue May 20 03:05:03 2008 Subject: [javascript-dev] Javascript documentation. In-Reply-To: References: <483272F0.2060300@addcom.de> Message-ID: <48329439.7090708@addcom.de> Emmanuel Jourdan schrieb: > You can use the send message. Then the syntax will be the same as the > one demonstrate in the "Making new objects" subpatcher of the > thispatcher help file. For instance: I tried this for instance: this.patcher.message("script", "newobject", "newobj", "@varname", "ctlobj[" + k + "]", "@patching_rect", 250+k*30, 50, 280+k*30, 70, "@text", ctlin, k+1 ); And it complained: js: autosurface.js: Javascript ReferenceError: ctlin is not defined... ... The js reference claims: "Any message to a patcher that you can send in Max (via the thispatcher object) you can send in Javascript in js." How do I send the size message: "script size var1 100 15" like in the example to thispatcher? I tried this.patcher.size(controlin[k], 27, 15); but it didn't work. Maybe because the the object doesn't have a scripting name yet... I go through this, because I want to see if scripting within javascript is easier than with thispatcher, but it seems much more complicated... ;-) Stefan -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|\-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com From c74-mailinglists at e--j.com Tue May 20 06:34:44 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Tue May 20 06:58:41 2008 Subject: [javascript-dev] Javascript documentation. In-Reply-To: <48329439.7090708@addcom.de> References: <483272F0.2060300@addcom.de> <48329439.7090708@addcom.de> Message-ID: On 20 mai 08, at 11:04, Stefan Tiedje wrote: > Emmanuel Jourdan schrieb: >> You can use the send message. Then the syntax will be the same as >> the one demonstrate in the "Making new objects" subpatcher of the >> thispatcher help file. For instance: > > I tried this for instance: > > this.patcher.message("script", "newobject", "newobj", > "@varname", "ctlobj[" + k + "]", > "@patching_rect", 250+k*30, 50, 280+k*30, 70, > "@text", ctlin, k+1 > ); > > And it complained: > > js: autosurface.js: Javascript ReferenceError: ctlin is not defined... it should proabably be: "@text", "ctlin " + k+1 > The js reference claims: "Any message to a patcher that you can send > in Max (via the thispatcher object) you can send in Javascript in js." > > How do I send the size message: "script size var1 100 15" like in > the example to thispatcher? > > I tried > > this.patcher.size(controlin[k], 27, 15); > > but it didn't work. Maybe because the the object doesn't have a > scripting name yet... Then you need to name it: controlin[k].varname = "ctrlin_" + k; this.patcher.message("script", "size", "ctrlin_" + k, 100, 15); You should also be able to use the rect property of a MaxObject. ej From Stefan-Tiedje at addcom.de Tue May 20 07:42:16 2008 From: Stefan-Tiedje at addcom.de (Stefan Tiedje) Date: Tue May 20 07:42:23 2008 Subject: [javascript-dev] Javascript documentation. In-Reply-To: References: <483272F0.2060300@addcom.de> <48329439.7090708@addcom.de> Message-ID: <4832D538.2080605@addcom.de> Emmanuel Jourdan schrieb: > it should proabably be: > > "@text", "ctlin " + k+1 Thanks, that did the trick (after I put (k+1) in brackets). Does that mean that these attributes have a fixed number of arguments? and @text will only take one single argument? Or is there an alternative notation also possible... I never know when I have to combine things with "+" or when I have to separate them with a comma. In Max I don't have to care about this but js is picky... ;-) Stefan -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|\-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com From c74-mailinglists at e--j.com Tue May 20 08:20:51 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Tue May 20 08:20:59 2008 Subject: [javascript-dev] Javascript documentation. In-Reply-To: <4832D538.2080605@addcom.de> References: <483272F0.2060300@addcom.de> <48329439.7090708@addcom.de> <4832D538.2080605@addcom.de> Message-ID: On 20 mai 08, at 15:42, Stefan Tiedje wrote: > Thanks, that did the trick (after I put (k+1) in brackets). Does > that mean that these attributes have a fixed number of arguments? > and @text will only take one single argument? > Or is there an alternative notation also possible... It depends on the attribute. For instance bordercolor would take 4 floats, here text takes only one string. You can find that easily by "looking at the object as text" (copy of the object, paste in a text file). ej From johnpoupinel at hotmail.com Tue May 20 19:15:43 2008 From: johnpoupinel at hotmail.com (Bertrand Fraysse) Date: Tue May 20 19:15:46 2008 Subject: [javascript-dev] ;max Message-ID: <22c8f.483377be@www.cycling74.com> Is it possible to send message to max like, for example ; max showcursor ; max hidecursor from within jsui ? An other thing. Does anyone have an idea on how to create a sort of [line] within jsui ? I'm making a 2D interface like pictslider but with random possibilities inside the interface, i'd like to an interpolation between new random positions... From c74-mailinglists at e--j.com Tue May 20 19:31:24 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Tue May 20 19:31:31 2008 Subject: [javascript-dev] ;max In-Reply-To: <22c8f.483377be@www.cycling74.com> References: <22c8f.483377be@www.cycling74.com> Message-ID: <2926E15F-170B-4FE2-B969-9F09DE0B2C80@e--j.com> On 21 mai 08, at 03:15, Bertrand Fraysse wrote: > Is it possible to send message to max like, for example > > ; > max showcursor > > ; > max hidecursor > > from within jsui ? Yes: max.showcursor(); or max.hidecursor(); > An other thing. Does anyone have an idea on how to create a sort of > [line] within jsui ? > I'm making a 2D interface like pictslider but with random > possibilities inside the interface, i'd like to an interpolation > between new random positions... You might want to have a look to the Task object, calculate an increment depending on your Task speed/interpolation time, increment and that's it ;-) ej From junk at odbol.com Thu May 22 01:45:48 2008 From: junk at odbol.com (Tyler) Date: Thu May 22 01:45:53 2008 Subject: [javascript-dev] Re: Re: slabs and planes in js In-Reply-To: <3D649F8B-47F3-4AC0-96B9-63D4ED61B690@musork.com> Message-ID: <22d22.483524ac@www.cycling74.com> Ahhh, thank you so much for this code.. it's exactly what I needed. However, moving a bit further ahead I am stuck: Right now I'm compositing an array of these effect chains with multiple videoplanes stacked on one another. I change the opacity of the videoplane to blend the clip with the others, however this is not quite the effect I want. Before I was using a jit.gl.slab Max object with "43j-fourwaymix.jxs" from the tutorial. I'm trying to get it to work in Javascript using the mixer and just one videoplane, but I can't figure out how to input FOUR textures into a slab object - it only has the one .texture property. I tried something like this: //this code isn't quite complete. it's riffing off of your example just to give the basic idea... var GL_CONTEXT = "foo"; var outplane = null; outplane = new JitterObject("jit.gl.videoplane",GL_CONTEXT); outplane.automatic = 0; outplane.transform_reset = 2; var mixerObj = null; mixerObj = new JitterObject("jit.gl.slab", GL_CONTEXT); mixerObj.file = "43j-fourwaymix.jxs"; mixerObj.param("a", 1.0); //set first clip to be visible var outslab = null; outslab = new JitterObject("jit.gl.slab",GL_CONTEXT); outslab.file = "co.normal.jxs"; outslab.param("amount",0.5); function jit_matrix(m) { outslab.activeinput = inlet; outslab.jit_matrix(m); outslab.draw(); //use a slab's texture as the first input to the mixer. /******this is the part I can't get to work!******/ mixerObj.param("tex0", outslab.capture); //output mixer to screen mixerObj.draw(); outplane.texture = mixerObj.capture; outplane.draw(); } From matt at postsomnia.com Thu May 22 14:36:55 2008 From: matt at postsomnia.com (Matt Lyon) Date: Thu May 22 14:37:02 2008 Subject: [javascript-dev] Re: Processing ported to javascript... In-Reply-To: <228a1.48289982@www.cycling74.com> Message-ID: <22d7a.4835d967@www.cycling74.com> personally i think you'd have an easier time rewriting processing.js for max and jsui than you would trying to intercept calls. That said, canvas seems to be here to stay and it would be awesome to see max support it as an alternative drawing api. From matt at postsomnia.com Thu May 22 14:40:23 2008 From: matt at postsomnia.com (Matt Lyon) Date: Thu May 22 14:40:29 2008 Subject: [javascript-dev] Re: Re: distinguishing between inlets In-Reply-To: <48317687.5040006@gmail.com> Message-ID: <22d7c.4835da37@www.cycling74.com> personally i'm fond of case statements, there's less temptation to mix in other logic with an "if" that picks your inlet: function list() { switch(inlet) { case 0: // do stuff; break; case 1: // do stuff; break; } } From matt at postsomnia.com Thu May 22 14:59:45 2008 From: matt at postsomnia.com (Matt Lyon) Date: Thu May 22 14:59:51 2008 Subject: [javascript-dev] reloading jsextensions Message-ID: <22d80.4835dec1@www.cycling74.com> is there a way to force max to reload the jsextensions folder, or even a specific file within? For specific files, setting autowatch = 1 in the file doesn't work, and relaunching max for changes to my personal js library is gonna become a huge pain, and I couldn't find anything about this from either the JS docs or a forum search. From matt at postsomnia.com Thu May 22 15:47:43 2008 From: matt at postsomnia.com (Matt Lyon) Date: Thu May 22 15:47:46 2008 Subject: [javascript-dev] Re: Javascript Reference with MAX5 In-Reply-To: Message-ID: <22d88.4835e9ff@www.cycling74.com> Quote: jkc wrote on Wed, 30 April 2008 10:18 ---------------------------------------------------- > The biggest fundamental change is that the JS engine now uses JS 1.6. Just FYI, if no one else has mentioned it yet, is that the Max5 docs, Javascript Tutorial Chapter 1, lists Max as still having a 1.5 interpreter. I figure maybe it's old and out of date, but this thread is the first I've heard that Max5 uses 1.6 From personalcomputermusic at gmail.com Fri May 23 10:33:57 2008 From: personalcomputermusic at gmail.com (f.e) Date: Fri May 23 10:34:18 2008 Subject: [javascript-dev] (pas de sujet) Message-ID: <4836F1F5.2030504@gmail.com> Hello, Is there anyway to have a sprite behavior in JSui ? Or do i have to redraw all my things when i just want to move one without leaving traces behind ? Thanks in advance f.e -- f.e chanfrault | aka | personal computer music >>>>>>> http://www.personal-computer-music.com >>>>>>> | film soundtracks, sound art, music | From personalcomputermusic at gmail.com Sat May 24 04:49:28 2008 From: personalcomputermusic at gmail.com (f.e) Date: Sat May 24 04:49:40 2008 Subject: [javascript-dev] JSui performance issues Message-ID: <4837F2B8.10500@gmail.com> Hello, I'm re-building a graphic interface for the 4th time and it seems every approach is problematic. To make it brief, you create/drag graphic objects made of one centered circle and one circle for the adjustable radius. Nothing fancy. - Java UI : tremondously cpu hungry. Event handling is a nightmare - Java based external sending messages to an LCD : less hungry but still unacceptable for realtime. Event handling still a nightmare - C external sending messages to an LCD : very very good performances BUT i am limited to the LCD features (no alpha channel). Event handling still a nightmare - JSui : Very handy event handling. Lots of drawing features. Antialiasing. Alpha channel. Unfortunately, tremondously cpu hungry. I know my code is dirty at this point, but i've watched the same cpu spikes using technoui so i suspect it's JSui's law. Is there anyway to have a sprite behavior in JSui (like in LCD) ? Or do i have to redraw all my things when i just want to move one without leaving traces behind (erase / redraw everything when you just change one thing) ? This second solution seems to lead to HUUUUGE CPU usage (sometimes 100% of one core) when you got several things to draw. At the time i'm writing, i have only 4 circles objects on my scene, and trying to change ones color continuously with a color swatch and a very simple frgb function (like you have in any jsui examples) makes my mouse stutter and my cpu goes to the clouds... Max 4.6.3 / XP SP2 / DualCore 2.16Ghz / NVIDIA GeForce Go 7800 GTX Thanks in advance f.e -- f.e chanfrault | aka | personal computer music >>>>>>> http://www.personal-computer-music.com >>>>>>> | film soundtracks, sound art, music | From jeremy at bootsquad.com Sat May 24 05:06:32 2008 From: jeremy at bootsquad.com (Jeremy Bernstein) Date: Sat May 24 05:06:37 2008 Subject: [javascript-dev] Re: JSui performance issues In-Reply-To: <4837F2B8.10500@gmail.com> Message-ID: <22e20.4837f6b6@www.cycling74.com> You might consider building your UI in OpenGL with jit.gl.sketch and/or jit.gl.gridshape. Then you get the GL benefits you're seeing in JS, but with hardware, rather than software rendering. jb From personalcomputermusic at gmail.com Sat May 24 05:36:55 2008 From: personalcomputermusic at gmail.com (f.e) Date: Sat May 24 05:37:06 2008 Subject: [javascript-dev] Re: JSui performance issues In-Reply-To: <22e20.4837f6b6@www.cycling74.com> References: <22e20.4837f6b6@www.cycling74.com> Message-ID: <4837FDD7.2090009@gmail.com> Ok. Good idea. I'll try that now. Thanks f.e f.e chanfrault | aka | personal computer music >>>>>>> http://www.personal-computer-music.com >>>>>>> | film soundtracks, sound art, music | Jeremy Bernstein a ?crit : > You might consider building your UI in OpenGL with jit.gl.sketch and/or jit.gl.gridshape. Then you get the GL benefits you're seeing in JS, but with hardware, rather than software rendering. > > jb > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev > From personalcomputermusic at gmail.com Sun May 25 04:40:56 2008 From: personalcomputermusic at gmail.com (f.e) Date: Sun May 25 04:41:04 2008 Subject: [javascript-dev] Re: JSui performance issues In-Reply-To: <22e20.4837f6b6@www.cycling74.com> References: <22e20.4837f6b6@www.cycling74.com> Message-ID: <48394238.1030009@gmail.com> Jeremy, is there a screentoworld (as we have in JSui) mechanism in jitter ? It seems i have to use x,y in pixels (in moveto, f.e) but things like circle's radius are in relative float. Do i have to do a scale in relation with my pwindow width/height ? Why my cicrles are awfully drawn in jit.gl.sketch ? Is there a way to have proper circles instead of a dozen segments faking a circle ? I guess i'll have to move this to the jitter section... Cheers f.e f.e chanfrault | aka | personal computer music >>>>>>> http://www.personal-computer-music.com >>>>>>> | film soundtracks, sound art, music | Jeremy Bernstein a ?crit : > You might consider building your UI in OpenGL with jit.gl.sketch and/or jit.gl.gridshape. Then you get the GL benefits you're seeing in JS, but with hardware, rather than software rendering. > > jb > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev > From aemersont at gmail.com Mon May 26 03:02:45 2008 From: aemersont at gmail.com (emerson) Date: Mon May 26 03:02:50 2008 Subject: [javascript-dev] Handling coll objects from inside js objects Message-ID: <22e92.483a7cb2@www.cycling74.com> Hello, I had posted this question under "MaxMSP" section, so far got no answers, perhaps I may try to duplicate it in this section: I am planning to implement a max prg which generates variational transformations on performer inputs (MIDI). For the manipulations and analyses to be made on the input sequence, I want to use javascript objects. Could anyone give me ideas or inform me about a method for how I can reference/handle the data structure in "coll"s using js code, within js objects at various parts of patches? Thanks again. From j at jasch.ch Mon May 26 03:49:11 2008 From: j at jasch.ch (=?ISO-8859-1?Q?jasch_=A0?=) Date: Mon May 26 03:49:42 2008 Subject: [javascript-dev] Handling coll objects from inside js objects In-Reply-To: <22e92.483a7cb2@www.cycling74.com> References: <22e92.483a7cb2@www.cycling74.com> Message-ID: AFAIK this is not possible. You could use patcher scripting methods to set and retrieve data remotely, but that's not the same as accessing the data structure directly. And since you're in javascript already, why not use the much more powerful data structures possible in this language? /*j From pdelges at radiantslab.com Mon May 26 03:51:59 2008 From: pdelges at radiantslab.com (Patrick Delges) Date: Mon May 26 03:52:04 2008 Subject: [javascript-dev] Handling coll objects from inside js objects In-Reply-To: <22e92.483a7cb2@www.cycling74.com> References: <22e92.483a7cb2@www.cycling74.com> Message-ID: <653EC95A-529C-46C2-BA13-DC1CF0655FEB@radiantslab.com> On 26 mai 08, at 11:02, emerson wrote: > be made on the input sequence, I want to use javascript objects. > Could anyone give me ideas or inform me about a method for how I can > reference/handle the data structure in "coll"s using js code, within > js objects at various parts of patches? See the Maxobj section in JavascriptingMax.pdf. An easy way would be to be to give your [coll ] instance a name (let say "mySuperColl_hider"), define in your js file a loadbang function like this: var myColl; function loadbang () { myColl = this.patcher.getnamed("mySuperColl_hider"); } and send messages to the coll like this: function foobar() { ... myColl.message (...); ... } If you need to get values, you may have a look at this thread: http://www.cycling74.com/forums/index.php?t=msg&goto=112604&rid=0&S=fa8a096b2d60ea595614c0c356155f31&srch=straightforward#msg_112604 I know Jeremy B. compiled a [js] version with a get function, but I dont know wether it has made its way to a public release... In Max5, things may have changes, but I couldn't find any serious documentation yet. p _____________________________ Patrick Delges Centre de Recherches et de Formation Musicales de Wallonie asbl http://www.crfmw.be/max From aemersont at gmail.com Mon May 26 06:07:21 2008 From: aemersont at gmail.com (emerson) Date: Mon May 26 06:07:25 2008 Subject: [javascript-dev] Re: Handling coll objects from inside js objects In-Reply-To: <653EC95A-529C-46C2-BA13-DC1CF0655FEB@radiantslab.com> Message-ID: <22e9a.483aa7f9@www.cycling74.com> Thanks very much for the replies. Considering your advices, it seems easier not to get involved in 'coll's but staying more in js arrays from the start. Again, thanks a lot for the advices. From acro.mosh at gmail.com Mon May 26 16:29:46 2008 From: acro.mosh at gmail.com (adam synnott) Date: Mon May 26 16:29:50 2008 Subject: [javascript-dev] java, jit.gl.gridshape and textures Message-ID: <22ee3.483b39d9@www.cycling74.com> hi, I'm trying quite unsuccesfully to apply a texture to each of the little planes in this script. the texture would be a still picture file. here's the script so far. var planes = 30; //number of particles //yo // inlets and outlets inlets = 2; outlets = 2; //blob 1 var person00x var person00y //blob 2 var person01x var person01y //blob 3 var person02x var person02y //blob 4 var person03x var person03y //blob 5 var person04x var person04y //jit.window creation var mywindow = new JitterObject("jit.window","wallpaper"); mywindow.depthbuffer = 0; mywindow.idlemouse = 0; //jit.gl.render creation var myrender = new JitterObject("jit.gl.render","wallpaper"); //use a 2d projection myrender.ortho = 2; myrender.erase_color = [0,0,0,1]; // create an array of [jit.gl.gridshape] objects randomly arrayed across the window var myplane = new Array(planes); //for statment to create the planes for(var i=0;i0) person00x = arguments[0]; if (arguments.length>1) person00y = arguments[1]; //blob2 if (arguments.length>2) person01x = arguments[2]; if (arguments.length>3) person01y = arguments[3]; //blob3 if (arguments.length>4) person02x = arguments[4]; if (arguments.length>5) person02y = arguments[5]; //blob4 if (arguments.length>6) person03x = arguments[6]; if (arguments.length>7) person03y = arguments[7]; //blob5 if (arguments.length>8) person04x = arguments[8]; if (arguments.length>9) person04y = arguments[9]; } // drive the renderer function bang() { //1 // collision detection block. we need to iterate through // the little spheres and check their distance from the control // object. if we're touching we move the little sphere away // along the correct angle of contact. for(var i = 0;icartesian to figure out x and y displacement var movex = (0.15-r)*Math.cos(theta); var movey = (0.15-r)*Math.sin(theta); // offset the little sphere to the new position, // which should be just beyond touching at the // angle of contact we had before. the result // should look like we've "pushed" it along... myplane[i].position = [myplane[i].position[0]-movex, myplane[i].position[1]-movey]; } } //2 for(var i = 0;i I am making a file browser, and jsfolderiter.js has shown me everything I need except the ability to go "up" a folder. Is there a simple property such as foldername.backpath to do this? For example, if I am in C:\Stuff\Junk\ I would like to get C:\Stuff\ I looked into string manipulation as a workaround, but this brings in problems with being cross-platform because of the differences between Windows and OSX paths. I hope this is not a silly question, I could not find a reference with the properties of Folder(). From j at jasch.ch Tue May 27 02:22:56 2008 From: j at jasch.ch (=?ISO-8859-1?Q?jasch_=A0?=) Date: Tue May 27 02:23:43 2008 Subject: [javascript-dev] java, jit.gl.gridshape and textures In-Reply-To: <22ee3.483b39d9@www.cycling74.com> References: <22ee3.483b39d9@www.cycling74.com> Message-ID: <7E325F54-48C2-4C8C-8FD9-AA4E50F84E4E@jasch.ch> adam, lots of things: but mainly, instanciate a texture, load a file into it, apply it to your planes. then: in javascript, you don't have to hardcode copies of the same structure. just use arrays for everything, like you already do for the planes. in the patch: inputting the control-points separately saves calculation cycles. using pak is poor style, every mouse action will result in TWO inputs since both values form a pictslider trigger the pak. when coming from cv.jit motion tracking, you will get blob-coordinates continously but the coordinates are always transmitted in groups of 2. if the number of blobs should vary, i'd instanciate plenty of blobs (> 20) and deactivate the unused ones. for tutorials: check out if you haven't already /examples/jitter- examples/javascript/render/ and some of the jitter-recipes by andrew benson hth /*j /////////////////// // save as adam.js /////////////////// autowatch = 1; // turn on during coding , off when finished to save CPU // inlets and outlets inlets = 2; outlets = 2; //number of particles // create an array of [jit.gl.gridshape] objects randomly arrayed across the window var planes = 30; var myplane = new Array(planes); //number of blobs var num_blobs = 10; var person = new Array(num_blobs); //jit.window creation var mywindow = new JitterObject("jit.window","wallpaper"); mywindow.depthbuffer = 0; mywindow.idlemouse = 0; //jit.gl.render creation var myrender = new JitterObject("jit.gl.render","wallpaper"); //use a 2d projection myrender.ortho = 2; myrender.erase_color = [0,0,0,1]; var mytexture = new JitterObject("jit.gl.texture", "wallpaper"); mytexture.name = "tex"; init(); function init() { var i; read("fuzz_circle.jpg"); //for statment to create the planes for(i = 0; i < planes; i++){ myplane[i] = new JitterObject("jit.gl.gridshape","wallpaper"); myplane[i].shape = "plane"; myplane[i].lighting_enable = 1; myplane[i].smooth_shading = 1; myplane[i].scale = [0.05,0.05,0.05]; myplane[i].color = [1.0, 1.0, 1.0, 1.0]; myplane[i].position = [Math.random()*2.-1,Math.random()*2.-1]; myplane[i].blend_enable = 1; myplane[i].texture = "tex"; } //for statment to create the blobs for(i = 0; i < num_blobs; i++) { person[i] = new JitterObject("jit.gl.gridshape","wallpaper"); person[i].shape = "sphere"; person[i].lighting_enable = 0; person[i].smooth_shading = 0; person[i].scale = [0.05,0.05,0.05]; person[i].color = [1.0 - (i * 0.1), 0.0, 0.0, 0.3]; person[i].position = [Math.random()*2.-1,Math.random()*2.-1]; person[i].blend_enable = 1; person[i].enable = 0; } for(i = 0; i < 5; i++) { // turn on a few blobs enable(i, 1); } } function list(idx, xx, yy) { person[idx].position = [xx, yy, 0.0]; } // drive the renderer function bang() { //1 // collision detection block. we need to iterate through // the little spheres and check their distance from the control // object. if we're touching we move the little sphere away // along the correct angle of contact. var i, j, distx, disty, r, theta, movex, movey; for(j = 0; j < num_blobs; j++) { //blobs loop for(i = 0; icartesian to figure out x and y displacement movex = (0.15 - r) * Math.cos(theta); movey = (0.15 - r) * Math.sin(theta); // offset the little sphere to the new position, // which should be just beyond touching at the // angle of contact we had before. the result // should look like we've "pushed" it along... myplane[i].position = [myplane[i].position[0] - movex, myplane[i].position[1] - movey]; } } } // rendering block... myrender.erase(); // erase the drawing context myrender.drawclients(); // draw the client objects myrender.swap(); // swap in the new drawing } bang.immediate = 1; function fullscreen(v) // function to send the [jit.window] into fullscreen mode { mywindow.fullscreen = v; } function jit_matrix(inname) { mytexture.jit_matrix(inname); } function read(filename) { mytexture.file = filename; } function enable(id, status) { person[id].enable = status; } ////////////// // the patch ////////////// #P window setfont "Sans Serif" 9.; #P window linecount 1; #P message 338 277 57 196617 read \, bang; #P newex 339 295 63 196617 jit.qt.movie; #P number 271 277 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P message 272 295 62 196617 enable \$1 1; #P message 192 283 74 196617 read chilis.jpg; #P message 91 283 101 196617 read fuzz_circle.jpg; #P newex 559 217 54 196617 prepend 4; #P newex 456 217 54 196617 prepend 3; #P newex 353 217 54 196617 prepend 2; #P newex 250 217 54 196617 prepend 1; #P newex 147 217 54 196617 prepend 0; #P newex 147 189 54 196617 pack 0. 0.; #P user pictslider 147 33 100 100 4 4 4 4 SliderDefaultKnob.pct 1 SliderDefaultBkgnd.pct 1 2163 0 15728640 320 1. 1.; #P newex 156 168 92 196617 scale 0 240 -1. 1.; #P newex 147 148 92 196617 scale 0 240 -1. 1.; #P newex 250 189 54 196617 pack 0. 0.; #P user pictslider 250 33 100 100 4 4 4 4 SliderDefaultKnob.pct 1 SliderDefaultBkgnd.pct 1 2163 0 15728640 320 1. 1.; #P newex 259 168 92 196617 scale 0 240 -1. 1.; #P newex 250 148 92 196617 scale 0 240 -1. 1.; #P newex 353 189 54 196617 pack 0. 0.; #P user pictslider 353 33 100 100 4 4 4 4 SliderDefaultKnob.pct 1 SliderDefaultBkgnd.pct 1 2163 0 15728640 320 1. 1.; #P newex 362 168 92 196617 scale 0 240 -1. 1.; #P newex 353 148 92 196617 scale 0 240 -1. 1.; #P newex 456 189 54 196617 pack 0. 0.; #P user pictslider 456 33 100 100 4 4 4 4 SliderDefaultKnob.pct 1 SliderDefaultBkgnd.pct 1 2163 0 15728640 320 1. 1.; #P newex 465 168 92 196617 scale 0 240 -1. 1.; #P newex 456 148 92 196617 scale 0 240 -1. 1.; #P newex 559 189 54 196617 pack 0. 0.; #P newex 38 137 52 196617 sel 102; #P newex 38 109 40 196617 key; #P window setfont "Fixedwidth Serif" 10.; #P message 38 220 83 1441802 fullscreen \$1; #P toggle 38 194 15 0; #P user pictslider 559 33 100 100 4 4 4 4 SliderDefaultKnob.pct 1 SliderDefaultBkgnd.pct 1 2163 0 15728640 320 1. 1.; #P window setfont "Sans Serif" 9.; #P newex 568 168 92 196617 scale 0 240 -1. 1.; #P newex 559 148 92 196617 scale 0 240 -1. 1.; #P toggle 74 168 15 0; #P newex 74 191 64 196617 qmetro 20; #P newex 74 324 57 196617 js adam.js; #P connect 8 0 9 0; #P connect 9 0 6 0; #P connect 6 0 7 0; #P connect 2 0 1 0; #P fasten 7 0 0 0 43 241 79 241; #P connect 1 0 0 0; #P fasten 27 0 0 0 152 268 79 268; #P fasten 28 0 0 0 255 268 79 268; #P fasten 29 0 0 0 358 268 79 268; #P fasten 30 0 0 0 461 268 79 268; #P fasten 31 0 0 0 564 268 79 268; #P fasten 32 0 0 0 96 304 79 304; #P fasten 33 0 0 0 197 304 79 304; #P fasten 34 0 0 0 277 317 79 317; #P fasten 36 0 0 0 344 316 79 316; #P connect 25 0 23 0; #P connect 23 0 26 0; #P connect 26 0 27 0; #P connect 25 1 24 0; #P connect 24 0 26 1; #P connect 21 0 19 0; #P connect 19 0 22 0; #P connect 22 0 28 0; #P connect 21 1 20 0; #P connect 35 0 34 0; #P connect 20 0 22 1; #P connect 37 0 36 0; #P connect 17 0 15 0; #P connect 15 0 18 0; #P connect 18 0 29 0; #P connect 17 1 16 0; #P connect 16 0 18 1; #P connect 13 0 11 0; #P connect 11 0 14 0; #P connect 14 0 30 0; #P connect 13 1 12 0; #P connect 12 0 14 1; #P connect 5 0 3 0; #P connect 3 0 10 0; #P connect 10 0 31 0; #P connect 5 1 4 0; #P connect 4 0 10 1; #P window clipboard copycount 38; From acro.mosh at gmail.com Tue May 27 05:55:36 2008 From: acro.mosh at gmail.com (adam synnott) Date: Tue May 27 05:55:40 2008 Subject: [javascript-dev] Re: java, jit.gl.gridshape and textures In-Reply-To: <7E325F54-48C2-4C8C-8FD9-AA4E50F84E4E@jasch.ch> Message-ID: <22f2e.483bf6b7@www.cycling74.com> Hi, Thnanks for all of the helpful advice. I had no idea about the pak object. I'll get into the code and let you know how it goes. Again, Thanks for the advice. adamx From acro.mosh at gmail.com Thu May 29 07:03:35 2008 From: acro.mosh at gmail.com (adam synnott) Date: Thu May 29 07:03:40 2008 Subject: [javascript-dev] Re: java, jit.gl.gridshape and textures In-Reply-To: <22f2e.483bf6b7@www.cycling74.com> Message-ID: <2305f.483ea9a6@www.cycling74.com> Hi, I took all your advice and rewrote the script... a new problem occured when i started to experimetn with textures. My texture has black in the corners which i'd like to get rid of. In jitter i'd usually get rid of it with a jit.op @op max object. I attempted to do this in js. any suggestions? js autowatch = 1 // turn off when not coding //blobs var persons = 5; var myperson = new Array(persons); //particles var planes = 100; myplane = new Array(planes); var op = planes; myop = new Array(op); //render var myrender = new JitterObject("jit.gl.render","test"); myrender.ortho = 2; myrender.erase_color = [0,0,0,1]; //jit window var mywindow = new JitterObject("jit.window","test"); mywindow.depthbuffer = 0; mywindow.idlemouse = 0; mywindow.mode = "texture" mywindow.interp = 1; var mytexture = new JitterObject("jit.gl.texture","test"); mytexture.name = "flower"; var mywallpaper = new JitterObject("jit.gl.texture","test"); mywallpaper.name = "wallpaper"; for(i=0;icartesian to figure out x and y displacement var movex = (0.15-r)*Math.cos(theta); var movey = (0.15-r)*Math.sin(theta); // offset the little sphere to the new position, // which should be just beyond touching at the // angle of contact we had before. the result // should look like we've "pushed" it along... myplane[i].position = [myplane[i].position[0]-movex, myplane[i].position[1]-movey]; } } } //outlet //outlet(0,"jit_matrix",test.name); //rendering block myrender.erase(); // erase the drawing context myrender.drawclients(); // draw the client objects myrender.swap(); //swap in the new drawing } function fullscreen(v) { mywindow.fullscreen = v; } function jit_matrix(inname) { mytexture.jit_matrix(inname); mywallpaper.jit_matrix(inname); patch is max v2; #N vpatcher 452 182 1052 582; #P window setfont "Sans Serif" 9.; #P window linecount 1; #P newex 144 165 19 9109513 t b; #P newex 144 143 40 9109513 key; #P toggle 144 191 15 0; #P message 159 247 62 9109513 fullscreen \$1; #P message 31 208 52 9109513 read \, bang; #P newex 31 230 55 9109513 jit.qt.movie; #P newex 194 206 49 9109513 prepend 0; #P newex 284 161 81 9109513 scale 0 127 -1. 1.; #P newex 194 161 81 9109513 scale 0 127 -1. 1.; #P user pictslider 194 59 100 100 4 4 4 4 SliderDefaultKnob.pct 1 SliderDefaultBkgnd.pct 1 2163 0 8323072 127 1. 1.; #P newex 194 184 50 9109513 pack 0. 0.; #P toggle 98 212 15 0; #P newex 98 232 45 9109513 metro 20; #P newex 98 263 56 9109513 js person.js; #P connect 9 0 8 0; #P connect 2 0 1 0; #P connect 10 0 0 0; #P connect 7 0 0 0; #P connect 1 0 0 0; #P fasten 8 0 0 0 36 256 103 256; #P connect 12 0 13 0; #P connect 13 0 11 0; #P connect 11 0 10 0; #P connect 4 0 5 0; #P connect 5 0 3 0; #P connect 3 0 7 0; #P fasten 6 0 3 1 289 182 239 182; #P connect 4 1 6 0; #P pop; am i even close to being on the right track? best adam From sxa at whiterabbitdesign.co.uk Fri May 30 04:38:05 2008 From: sxa at whiterabbitdesign.co.uk (sean ahern) Date: Fri May 30 04:38:10 2008 Subject: [javascript-dev] Re: Navigating Folders... going "up" In-Reply-To: <22efb.483b765f@www.cycling74.com> Message-ID: <230c2.483fd90c@www.cycling74.com> Looking at the code for jsfolderiter.js, it looks as though it always uses'/' as its own path separator. Do you really need to worry about cross-platform path handling? Unless Im missing something, shouldnt the following suffice?? var folderString = new String(fodlerName); lastSep = folderString.lastIndexOf('/',folderString.length-2); folderString = folderString.slice(0,lastSep); Alternately, would your application suffice with just C:\Stuff\Junk\.. ? From afaulsti at hotmail.com Fri May 30 09:51:48 2008 From: afaulsti at hotmail.com (Aaron Faulstich) Date: Fri May 30 09:51:53 2008 Subject: [javascript-dev] Re: Re: JSui performance issues In-Reply-To: <48394238.1030009@gmail.com> Message-ID: <230d7.48402294@www.cycling74.com> Increase the shapeslice attribute in the jit.gl.sketch to get better looking circles. I redid a couple of my old JSUI interfaces in Jitter a couple months ago, and both saw a large decrease in CPU use even without hardware rendering. It really seems like the best way to go. From personalcomputermusic at gmail.com Fri May 30 10:15:16 2008 From: personalcomputermusic at gmail.com (f.e) Date: Fri May 30 10:15:26 2008 Subject: [javascript-dev] Re: Re: JSui performance issues In-Reply-To: <230d7.48402294@www.cycling74.com> References: <230d7.48402294@www.cycling74.com> Message-ID: <48402814.8090701@gmail.com> Thanks a lot for this info ! Best f.e f.e chanfrault | aka | personal computer music >>>>>>> http://www.personal-computer-music.com >>>>>>> | film soundtracks, sound art, music | Aaron Faulstich a ?crit : > Increase the shapeslice attribute in the jit.gl.sketch to get better looking circles. > > I redid a couple of my old JSUI interfaces in Jitter a couple months ago, and both saw a large decrease in CPU use even without hardware rendering. It really seems like the best way to go. > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev > From afaulsti at hotmail.com Fri May 30 10:22:37 2008 From: afaulsti at hotmail.com (Aaron Faulstich) Date: Fri May 30 10:22:44 2008 Subject: [javascript-dev] Re: Navigating Folders... going "up" In-Reply-To: <230c2.483fd90c@www.cycling74.com> Message-ID: <230e0.484029cc@www.cycling74.com> I was doing something similar to your code, but less efficient. The .lastIndexOf really speeds things up. My final code (for Windows) is: function back_folder() { //protect from going "up" at a drive if(prev_folder.charAt(prev_folder.length-2)!=":") { last_sep = prev_folder.lastIndexOf("/", prev_folder.length-2); var jump_to = prev_folder.slice(0, last_sep) + "/"; jump_folder(jump_to); } } Where jump_folder is my folder loading function, and prev_folder is the last folder that's been loaded. It's working fine on Windows and is faster than what I had before. Thank you! From apalomba at austin.rr.com Sat May 31 12:47:02 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Sat May 31 12:47:07 2008 Subject: [javascript-dev] Re: get values of number boxes (and other objects) In-Reply-To: <147d2.4542840c@www.cycling74.com> Message-ID: <23140.48419d25@www.cycling74.com> So is there a better way to do this now? I want to query the value of an object from js...