From lfanele at gmail.com Sun Dec 2 14:21:13 2007 From: lfanele at gmail.com (Stephen Lumenta) Date: Sun Dec 2 14:21:18 2007 Subject: [javascript-dev] Inheritance... Message-ID: <1df56.475321c8@www.cycling74.com> Hi, I think I'm going cracy. I wanted to write my own objects, but for some reason I can't get inheritance to work in js. I've read about javascript-inheritance on the web before and boiled it down to a simple example, but when you run the code i always get an x undefined... Is there something obvious i am missing? Thanks a lot, Stephen //inheritance revisited autowatch = 1; var sub = new Subclass(); bang(); function bang() { post("inherited x: "+sub.x+" "); // this should print 244 right? } // my SuperClass function Superclass() { this.x = 244; } // SubClass inherits from SuperClass ? function Subclass(){ } Subclass.prototype = new Superclass(); From donaghy_liam at hotmail.com Mon Dec 3 09:39:36 2007 From: donaghy_liam at hotmail.com (Liam Donaghy) Date: Mon Dec 3 09:39:42 2007 Subject: [javascript-dev] array of newobject of type "Number Box" Message-ID: <1df7c.47543148@www.cycling74.com> Hi, I am trying to dynamically create an array of objects and this works fine for toggle, e.g a = patcher.newobject("toggle",122,90,15,0); but how do you create a newobject for "Number Box" as it fails e.g a = patcher.newobject("Number Box",122,90,15,0); is the space in the string a problem, any help much appreciated. From vboehm at gmx.ch Mon Dec 3 10:30:42 2007 From: vboehm at gmx.ch (=?ISO-8859-1?Q?volker_b=F6hm?=) Date: Mon Dec 3 10:29:57 2007 Subject: [javascript-dev] array of newobject of type "Number Box" In-Reply-To: <1df7c.47543148@www.cycling74.com> References: <1df7c.47543148@www.cycling74.com> Message-ID: On 03 Dec 2007, at 17:39, Liam Donaghy wrote: > > Hi, > > I am trying to dynamically create an array of objects and this > works fine for toggle, e.g > > a = patcher.newobject("toggle",122,90,15,0); > > but how do you create a newobject for "Number Box" as it fails e.g > > a = patcher.newobject("Number Box",122,90,15,0); try "number" instead. and you will need some more arguments. to find out about the format you can open a max patch as text and inspect the argument list of the objects. vb From donaghy_liam at hotmail.com Mon Dec 3 13:18:02 2007 From: donaghy_liam at hotmail.com (Liam Donaghy) Date: Mon Dec 3 13:18:04 2007 Subject: [javascript-dev] Re: array of newobject of type "Number Box" In-Reply-To: <1df7c.47543148@www.cycling74.com> Message-ID: <1df93.4754647a@www.cycling74.com> Hi Vb, Thanks a lot, I have opened the patch as text and used the full list of parameters. Opened as text : #P number 116 22 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; to javascript : var object_array = new Array(128); object_array[k] = this.patcher.newobject("number" ,116, 22, 35, 9, 0, 0, 0, 3, 0, 0, 0, 221, 221, 221, 222, 222, 222, 0, 0, 0); Parameters 2 + 3 (116 + 22) control the object positioning From doktorp at mac.com Wed Dec 5 01:05:24 2007 From: doktorp at mac.com (vade) Date: Wed Dec 5 01:05:26 2007 Subject: [javascript-dev] Callback for bpatcher resize event? Message-ID: <1e04e.47565bc3@www.cycling74.com> Hello Ive got some nifty GUI code that checks the parent bpatcher size on a function call and reflows my gui to my wishes (YAY! Confetti!!@#) Now, id love to know if there is some callback my javascript can hook into to see if its parent patcher is being resized or moved, so I can fire off my resize event (for dynamic resizing) Im not using JSUI, im using standard max objects within a bpatcher. Thanks, *super* curious. I should have moved this crufty olde code to JS a while ago - makes things HANDY! WOOO! From cycling74forum at opuslocus.net Wed Dec 5 21:28:36 2007 From: cycling74forum at opuslocus.net (John Pitcairn) Date: Wed Dec 5 21:28:39 2007 Subject: [javascript-dev] Re: Callback for bpatcher resize event? In-Reply-To: <1e04e.47565bc3@www.cycling74.com> Message-ID: <1e0a2.47577a74@www.cycling74.com> Don't think so. Use the [mousestate] object to send every mouse-up to your js, (efficiently) check the patcher size, rearrange if it's changed? From doktorp at mac.com Wed Dec 5 21:42:40 2007 From: doktorp at mac.com (vade) Date: Wed Dec 5 21:42:43 2007 Subject: [javascript-dev] Re: Callback for bpatcher resize event? In-Reply-To: <1e0a2.47577a74@www.cycling74.com> Message-ID: <1e0a3.47577dc0@www.cycling74.com> Hm, I really dont want to have to poll, that would be very bad with many gui objects. Oh well, ill see what I can manage. From doktorp at mac.com Wed Dec 5 22:24:01 2007 From: doktorp at mac.com (vade) Date: Wed Dec 5 22:24:02 2007 Subject: [javascript-dev] Re: Callback for bpatcher resize event? In-Reply-To: <1e04e.47565bc3@www.cycling74.com> Message-ID: <1e0a4.47578771@www.cycling74.com> So, I have a resize function which reflows my gui - I was able to use a task within the loadbang function with a delay to get my initial resize working. No idea how on earth to do others, but I think its ok, since resizing will be an editing task, and users can just click the damn resize message box if they need to reflow. Once they set it, this function will do it for them when the patch is saved. function loadbang() { var loadtask = new Task(resize, this); loadtask.schedule(100); } function resize() { prev = 0; owner = this.patcher; while (owner) { prev = owner; owner = owner.patcher.parentpatcher; } if (prev) top = prev.box; // width of our parent bpatcher width = top.rect[2] - top.rect[0]; do your reflow here if you want // refresh our parent patchers on down (?). prev.parentpatcher.refresh(); prev.refresh(); this.patcher.refresh(); } From cycling74forum at opuslocus.net Wed Dec 5 22:24:26 2007 From: cycling74forum at opuslocus.net (John Pitcairn) Date: Wed Dec 5 22:24:27 2007 Subject: [javascript-dev] Re: Callback for bpatcher resize event? In-Reply-To: <1e0a3.47577dc0@www.cycling74.com> Message-ID: <1e0a5.4757878a@www.cycling74.com> It doesn't require polling, unless you want a "live" resize on drag. You can make the window-size check quite efficient, and you only do that on mouseup anyway - which really won't be very frequent, compared to polling every 100ms or so. So you still don't run any of your GUI-resize code unless the patcher size has changed. From doktorp at mac.com Wed Dec 5 22:53:25 2007 From: doktorp at mac.com (vade) Date: Wed Dec 5 22:53:26 2007 Subject: [javascript-dev] Re: Callback for bpatcher resize event? In-Reply-To: <1e0a5.4757878a@www.cycling74.com> Message-ID: <1e0a6.47578e55@www.cycling74.com> hrm? task.schedule() only runs once according to the docs, and yeah, the whole point was to get a live resize so when people are editing the patches the guis update :) The mouse up/patch unlocked thing is a bit too hackish for me, unless I am misunderstanding. From cycling74forum at opuslocus.net Wed Dec 5 23:30:46 2007 From: cycling74forum at opuslocus.net (John Pitcairn) Date: Wed Dec 5 23:30:47 2007 Subject: [javascript-dev] Re: Callback for bpatcher resize event? In-Reply-To: <1e0a6.47578e55@www.cycling74.com> Message-ID: <1e0a9.47579716@www.cycling74.com> > The mouse up/patch unlocked thing is a bit too hackish for me, > unless I am misunderstanding. Maybe I'm misunderstanding? The user can't resize anything without clicking/dragging on it with the mouse, right? When the mouse is released, the resize (if there was one) is done. You feed the mouseup from mousestate to your js, which checks the patcher to see if the width/height is different. If it is, you rearrange your GUI. If it isn't, you do nothing. No polling via js task or otherwise is required, it's a mouse-driven event. From doktorp at mac.com Wed Dec 5 23:38:33 2007 From: doktorp at mac.com (vade) Date: Wed Dec 5 23:38:34 2007 Subject: [javascript-dev] Re: Callback for bpatcher resize event? In-Reply-To: <1e0a9.47579716@www.cycling74.com> Message-ID: <1e0aa.475798e9@www.cycling74.com> Well, mouse state polls, maybe not in JS, but in max code. btw, my code is not polling at all, that task has a schedule, while runs once, delayed by 100ms because there is some delay required for the subpatch within my bpatcher to realize it is in a parent and traverse the hierarchy up. Otherwise with no delay it throws an error. Logic wise I think we are in agreement, however, this isnt for a window, but for a bpatcher, where I plan on have MANY MANY of them, so I suppose I could be polling in one location, send the event globally, to fire it off, I may give it a shot, but my above solution works for what I need to do. These ui objects are the heart of my performance environment, so I want to keep them as lean as possible. Thanks, I may give something like that a shot at some point. From doktorp at mac.com Wed Dec 5 23:39:16 2007 From: doktorp at mac.com (vade) Date: Wed Dec 5 23:39:17 2007 Subject: [javascript-dev] Re: Callback for bpatcher resize event? In-Reply-To: <1e04e.47565bc3@www.cycling74.com> Message-ID: <1e0ab.47579913@www.cycling74.com> erm sorry, which runs once, only once, on load. That task never runs again. (to be clear). From doktorp at mac.com Fri Dec 7 09:59:00 2007 From: doktorp at mac.com (vade) Date: Fri Dec 7 09:59:04 2007 Subject: [javascript-dev] javascript + Pattr question - storing multiple values of mixed types (string/float) Message-ID: <1e15c.47597bd2@www.cycling74.com> Hello So i am in the process of pattrfying one of my javascripts. I have implemented setvalueof and getvalueof, and within my patch my pattrstorage instance properly sees multiple variables. My data within the client window is such: "float 0 1 0 Var1 10 0" (gui mode, minval, maxval, currentvalue, currenttitle, listsize, listtype for those interested). Now, those variables are global to my JS, and I am attempting to store them within an array - which seems to work at least for SETTING, however recalling does some weird things: (I am setting an array called currentPattr to hold my 'multiple' values - I call pattrUpdate rather than notifyclients within my code to update this currentPattr array, which then calls notifyclients itself) [code] // pattr compatibility function pattrUpdate() { // set our array to current global state - have to use an array for pattr since we can only get/set one variable. currentPattr[0] = mode; currentPattr[1] = minval; currentPattr[2] = maxval; currentPattr[3] = currentval; currentPattr[4] = currenttitle; currentPattr[5] = listsize; currentPattr[6] = listmode; // currentPattr[7] = menuitems; // post(currentPattr); // do our actual pattr updates notifyclients(); } function getvalueof() { post("storing pattr state"); post(); return currentPattr; // our aggregate array of pattr variables pattrUpdate(); } function setvalueof(v) { post("recalling pattr state"); post(); currentPattr = v; // set our values mode = currentPattr[0]; minval = currentPattr[1]; maxval = currentPattr[2]; currentval = currentPattr[3]; currenttitle = currentPattr[4]; listsize = currentPattr[5]; listmode = currentPattr[6]; // menuitems = currentPattr[7]; pattrUpdate(); resize(); debug(); } // debug function debug() { post("mode = " + mode); post(); post("min = " + minval); post(" max = " + maxval); post(); } [/code] as far as I can tell, setting works (as far as I understand, using getvalueof results in proper values in my pattrstorage window (otherwise, why would I see the full values I see?)), using my setvalueof to restore client state results in debug printing for example recalling pattr state mode = f min = l max = o storing pattr state digging further I've iterated over my recalled currentPattr from getvalueof() and note it does not contain all the data I had expected So, how do I properly pack in the values of mixed string/floats to pattr and recall them? Do I need to use multidimensional arrays or something? Forgive me if this is obvious, I feel like I am overlooking something staring me in the face. Thanks again! From mattijs at smadsteck.nl Fri Dec 7 10:24:50 2007 From: mattijs at smadsteck.nl (Mattijs Kneppers) Date: Fri Dec 7 10:24:51 2007 Subject: [javascript-dev] Re: javascript + Pattr question - storing multiple values of mixed types (string/float) In-Reply-To: <1e15c.47597bd2@www.cycling74.com> Message-ID: <1e15f.475981e2@www.cycling74.com> Better even would be if we could define multiple attributes inside javascript and access them separately with pattr.. Mattijs -- SmadSteck - http://www.smadsteck.nl Hard- and software for interactive audiovisual sampling From doktorp at mac.com Fri Dec 7 10:31:28 2007 From: doktorp at mac.com (vade) Date: Fri Dec 7 10:31:30 2007 Subject: [javascript-dev] Re: javascript + Pattr question - storing multiple values of mixed types (string/float) In-Reply-To: <1e15f.475981e2@www.cycling74.com> Message-ID: <1e161.47598370@www.cycling74.com> Yeah, totally, I was initially quite confused by the functions, as I did not see how to do exactly that, and then noticed the mention of arrays, and deduced one had to manage this oneself. From c74-mailinglists at e--j.com Fri Dec 7 10:59:57 2007 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Fri Dec 7 11:00:52 2007 Subject: [javascript-dev] Re: javascript + Pattr question - storing multiple values of mixed types (string/float) In-Reply-To: <1e161.47598370@www.cycling74.com> References: <1e161.47598370@www.cycling74.com> Message-ID: On 7 d?c. 07, at 18:31, vade wrote: > Yeah, totally, I was initially quite confused by the functions, as I > did not see how to do exactly that, and then noticed the mention of > arrays, and deduced one had to manage this oneself. Your code have some issue. You should call notifyclients() when your pattr state change. It doesn't make sense to recall it (trough your pattrUpdate() function) inside getvalueof(). I didn't test it: var currentPattr = new Array(); var mode... function pattrUpdate() { // set our array to current global state - have to use an array for pattr since we can only get/set one variable. currentPattr[0] = mode; currentPattr[1] = minval; currentPattr[2] = maxval; currentPattr[3] = currentval; currentPattr[4] = currenttitle; currentPattr[5] = listsize; currentPattr[6] = listmode; } pattrUpdate.private = 1; function getvalueof() { post("storing pattr state"); post(); pattrUpdate(); // update the states return currentPattr; // our aggregate array of pattr variables } function setvalueof(v) { post("recalling pattr state"); post(); // set our values mode = v[0]; minval = v[1]; maxval = v[2]; currentval = v[3]; currenttitle = v[4]; listsize = v[5]; listmode = v[6]; // menuitems = v[7]; resize(); debug(); } // debug function debug() { post("mode = " + mode); post(); post("min = " + minval); post(" max = " + maxval); post(); } // just to test: function setmode(s) { mode = s; // store your new mode notifyclients(); // update the pattr values } Best, ej From doktorp at mac.com Fri Dec 7 13:54:57 2007 From: doktorp at mac.com (vade) Date: Fri Dec 7 13:54:59 2007 Subject: [javascript-dev] Re: Re: javascript + Pattr question - storing multiple values of mixed types (string/float) In-Reply-To: Message-ID: <1e17b.4759b320@www.cycling74.com> Hi Emmanuel - thanks for taking the time to look at that however, there seems to be an issue with your code (the same issue as mine) Here is a modified version of your code: var currentPattr = new Array(); var mode = "float" var minval = 0.0; var maxval = 10.0; var currentval = 0.0; var currenttitle = "SOMETITLE"; var listsize = "10"; var listmode = "int"; function pattrUpdate() { // set our array to current global state - have to use an array for currentPattr[0] = mode; currentPattr[1] = minval; currentPattr[2] = maxval; currentPattr[3] = currentval; currentPattr[4] = currenttitle; currentPattr[5] = listsize; currentPattr[6] = listmode; } pattrUpdate.local = 1; function getvalueof() { post("storing pattr state"); post(); pattrUpdate(); // update the states return currentPattr; // our aggregate array of pattr variables } function setvalueof(v) { post("recalling pattr state"); post(); // set our values mode = v[0]; minval = v[1]; maxval = v[2]; currentval = v[3]; currenttitle = v[4]; listsize = v[5]; listmode = v[6]; // menuitems = v[7]; //resize(); debug(); } // debug function debug() { post("mode = " + mode); post(); post("min = " + minval); post(" max = " + maxval); post(); } // just to test: function setmode(s) { mode = s; // store your new mode notifyclients(); // update the pattr values } running that code code: step one: send message "setmode list" to our js send message "store 1" to our pattrstorage note that the clientwindow for pattrstorage properly shows "list" in the data window along side our other data we specified as default in the code send message "setmode int" to our js send message "store 2" to store this second set of data. Both client and storage window reflect these settings. Now recall setting 1. Note that debug now outputs : recalling pattr state mode = l min = i max = s storing pattr state From doktorp at mac.com Fri Dec 7 13:56:58 2007 From: doktorp at mac.com (vade) Date: Fri Dec 7 13:56:59 2007 Subject: [javascript-dev] Re: Re: javascript + Pattr question - storing multiple values of mixed types (string/float) In-Reply-To: <1e17b.4759b320@www.cycling74.com> Message-ID: <1e17c.4759b399@www.cycling74.com> I hate this web forum so much. It cut off my message : here is the rest which clearly shows us overwriting our array indices with new values (v[0] does not contain "list" it contains "l") This seems obvious now, but what/where/why is the clientwindow/storagewindow getting its display from? Are we expanding the array somehow? So I suppose we have to use multidimensional arrays, but I cannot seem to get that to work either Thanks again for your help. BTW - I tried this with notifyclients in various places and did not see a difference. Why does notifyclients care what function its in, as long as it is being called when values are changing and pattr needs to be informed? Thanks you sir! From c74-mailinglists at e--j.com Fri Dec 7 14:49:40 2007 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Fri Dec 7 14:50:31 2007 Subject: [javascript-dev] Re: Re: javascript + Pattr question - storing multiple values of mixed types (string/float) In-Reply-To: <1e17c.4759b399@www.cycling74.com> References: <1e17c.4759b399@www.cycling74.com> Message-ID: <177E2752-C213-47EE-8E6D-7A942784CE90@e--j.com> On 7 d?c. 07, at 21:56, vade wrote: > which clearly shows us overwriting our array indices with new > values (v[0] does not contain "list" it contains "l") This seems > obvious now, but what/where/why is the clientwindow/storagewindow > getting its display from? Are we expanding the array somehow? > > So I suppose we have to use multidimensional arrays, but I cannot > seem to get that to work either Silly me;-) setvalueof() receive an "array" (it's not exactly an array but) as argument so you just need to go over the each item: function setvalueof() { var index = 0; post("recalling pattr state"); post(); // set our values mode = arguments[index++]; minval = arguments[index++]; maxval = arguments[index++]; currentval = arguments[index++]; currenttitle = arguments[index++]; listsize = arguments[index++]; listmode = arguments[index++]; // menuitems = arguments[index++]; //resize(); debug(); } > BTW - I tried this with notifyclients in various places and did not > see a difference. Why does notifyclients care what function its in, > as long as it is being called when values are changing and pattr > needs to be informed? notifyclients() is the method that you need to call when you want the pattr information to be updated (thankfully, it doesn't do that automatically each time it receive something). So when you send a message that change one of the item of your pattr state you need to call notifyclients(). Does that makes sense? Cheers, ej From doktorp at mac.com Fri Dec 7 15:01:47 2007 From: doktorp at mac.com (vade) Date: Fri Dec 7 15:01:49 2007 Subject: [javascript-dev] Re: Re: Re: javascript + Pattr question - storing multiple values of mixed types (string/float) In-Reply-To: <177E2752-C213-47EE-8E6D-7A942784CE90@e--j.com> Message-ID: <1e186.4759c2cb@www.cycling74.com> yeah, I called updatePattr() rather than notifyclients to synchronize my arrays first, then notify. Yes that makes sense I just re-read the manual and am implementing arguments - which totally looks like its going to work. Im glad we both found the right method! Thanks Emmanuel for the help! From c74-mailinglists at e--j.com Fri Dec 7 15:19:20 2007 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Fri Dec 7 15:20:09 2007 Subject: [javascript-dev] Re: Re: Re: javascript + Pattr question - storing multiple values of mixed types (string/float) In-Reply-To: <1e186.4759c2cb@www.cycling74.com> References: <1e186.4759c2cb@www.cycling74.com> Message-ID: <3A951363-DE0B-402A-9AC7-4FC6A8879761@e--j.com> On 7 d?c. 07, at 23:01, vade wrote: > yeah, I called updatePattr() rather than notifyclients to > synchronize my arrays first, then notify. Yes that makes sense > > I just re-read the manual and am implementing arguments - which > totally looks like its going to work. Im glad we both found the > right method! You're welcome. I should have looked at ej.function before replying the first time ;-) ej From doktorp at mac.com Fri Dec 7 15:50:27 2007 From: doktorp at mac.com (vade) Date: Fri Dec 7 15:50:29 2007 Subject: [javascript-dev] Re: Re: Re: Re: javascript + Pattr question - storing multiple values of mixed types (string/float) In-Reply-To: <3A951363-DE0B-402A-9AC7-4FC6A8879761@e--j.com> Message-ID: <1e18a.4759ce33@www.cycling74.com> so just a heads up - it works 100% SOme psuedocode below that illustrates if you want to handle multiple pattr entries in pattr: // the variables I want to store var somefloat = 3.14159; var somestuff = "some stuff or whatever"; var someint = 10; //make an array of items you want to store var mypattritems = new Array() function updatePattr() { mypattritems[0] = somefloat; mypattritems[1] = somestuff; mypattritems[2] = someint; notifyclients(); // for pattr to notice! } // for pattrstorage to store it function getvalueof() { return mypattritems; // this sends the array to pattrland } // for pattrstorage to return it to JS function setvalueof() { // note we use ARGUMENTs here, not like in the manual pi = arguments[0]; stuff = arguments[1]; someint = arguments[2]; } // getter setter methods for our individual variables msg_int(v) { someint = v; updatePattr(); // updates our array with the new values and tells pattr } function msg_float(v) { somefloat = v; updatePattr(); } etc. etc. Thanks again -ej! From klaus at klingt.org Thu Dec 20 07:27:26 2007 From: klaus at klingt.org (klaus filip) Date: Thu Dec 20 07:27:35 2007 Subject: [javascript-dev] jsui mysketch Message-ID: hi i am trying to build a multi-2D slider as jsui and hanging at the very basics. since i don't want to redraw all sliders i want to use multiple sketches (like sprites). below is my basic misunderstanding, the function dsketch works, but the function dsketch2 is doing nothing... if somebody already did a jsui for multiple 2D-sliders and wants to share this, i would not mind as well ;-) thanks klaus autowatch = 1; inlets = 2; outlets = 1; sketch.default2d(); var vbrgb = [0.3,0.3,0.6,0.5]; var vfrgb = [0.8,0.8,0.3,0.5]; var width = box.rect[2] - box.rect[0]; var height = box.rect[3] - box.rect[1]; var sketch2 = new Sketch(width,height); sketch2.default2d(); function dsketch() { with (sketch) { glclearcolor(vbrgb); glclear(); refresh(); } } function dsketch2() { with (sketch2) { glclearcolor(vbrgb); glclear(); refresh(); } } From samuel.freeman at gmail.com Thu Dec 20 08:12:01 2007 From: samuel.freeman at gmail.com (Samuel Freeman) Date: Thu Dec 20 08:12:03 2007 Subject: [javascript-dev] jsui mysketch In-Reply-To: References: Message-ID: <2591ffce0712200712s45ac7c68o313ac409b1843f0e@mail.gmail.com> Perhaps someone else will be of more help, but I started with js in max at a very similar position, and very soon just gave up on newSketch() / sprite-ish approach an just redraw the whole sketch, that's the way all the examples I've seen work do it. Try having separate functions for the various sliders which will each be called by a master drawing function. On the other hand, I too would still be interested to find out how to get the newSketch thing going... Sam On 20/12/2007, klaus filip wrote: > hi > i am trying to build a multi-2D slider as jsui and hanging at the > very basics. > since i don't want to redraw all sliders i want to use multiple > sketches (like sprites). > below is my basic misunderstanding, the function dsketch works, > but the function dsketch2 is doing nothing... > > if somebody already did a jsui for multiple 2D-sliders and wants to > share this, i would not mind as well ;-) > > thanks > klaus > > autowatch = 1; > inlets = 2; > outlets = 1; > sketch.default2d(); > var vbrgb = [0.3,0.3,0.6,0.5]; > var vfrgb = [0.8,0.8,0.3,0.5]; > var width = box.rect[2] - box.rect[0]; > var height = box.rect[3] - box.rect[1]; > > var sketch2 = new Sketch(width,height); > sketch2.default2d(); > > > > function dsketch() > { > with (sketch) > { > glclearcolor(vbrgb); > glclear(); > refresh(); > } > } > > function dsketch2() > { > with (sketch2) > { > glclearcolor(vbrgb); > glclear(); > refresh(); > } > } > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev > From samuel.freeman at gmail.com Thu Dec 20 08:14:44 2007 From: samuel.freeman at gmail.com (Samuel Freeman) Date: Thu Dec 20 08:14:46 2007 Subject: [javascript-dev] jsui mysketch In-Reply-To: <2591ffce0712200712s45ac7c68o313ac409b1843f0e@mail.gmail.com> References: <2591ffce0712200712s45ac7c68o313ac409b1843f0e@mail.gmail.com> Message-ID: <2591ffce0712200714u6702bd45l2ef2f2f6d98a113e@mail.gmail.com> Perhaps i should add that problem I always had was not making or even using new sketch objects , but seeing them - I could never see the results of anything but the default sketch instance... On 20/12/2007, Samuel Freeman wrote: > Perhaps someone else will be of more help, but I started with js in > max at a very similar position, and very soon just gave up on > newSketch() / sprite-ish approach an just redraw the whole sketch, > that's the way all the examples I've seen work do it. > > Try having separate functions for the various sliders which will each > be called by a master drawing function. > > On the other hand, I too would still be interested to find out how to > get the newSketch thing going... > > Sam > > On 20/12/2007, klaus filip wrote: > > hi > > i am trying to build a multi-2D slider as jsui and hanging at the > > very basics. > > since i don't want to redraw all sliders i want to use multiple > > sketches (like sprites). > > below is my basic misunderstanding, the function dsketch works, > > but the function dsketch2 is doing nothing... > > > > if somebody already did a jsui for multiple 2D-sliders and wants to > > share this, i would not mind as well ;-) > > > > thanks > > klaus > > > > autowatch = 1; > > inlets = 2; > > outlets = 1; > > sketch.default2d(); > > var vbrgb = [0.3,0.3,0.6,0.5]; > > var vfrgb = [0.8,0.8,0.3,0.5]; > > var width = box.rect[2] - box.rect[0]; > > var height = box.rect[3] - box.rect[1]; > > > > var sketch2 = new Sketch(width,height); > > sketch2.default2d(); > > > > > > > > function dsketch() > > { > > with (sketch) > > { > > glclearcolor(vbrgb); > > glclear(); > > refresh(); > > } > > } > > > > function dsketch2() > > { > > with (sketch2) > > { > > glclearcolor(vbrgb); > > glclear(); > > refresh(); > > } > > } > > _______________________________________________ > > javascript-dev mailing list > > javascript-dev@cycling74.com > > http://www.cycling74.com/mailman/listinfo/javascript-dev > > > From jkc at musork.com Thu Dec 20 13:13:15 2007 From: jkc at musork.com (Joshua Kit Clayton) Date: Thu Dec 20 13:13:34 2007 Subject: [javascript-dev] jsui mysketch In-Reply-To: References: Message-ID: On Dec 20, 2007, at 6:27 AM, klaus filip wrote: > hi > i am trying to build a multi-2D slider as jsui and hanging at the > very basics. > since i don't want to redraw all sliders i want to use multiple > sketches (like sprites). > below is my basic misunderstanding, the function dsketch works, > but the function dsketch2 is doing nothing... Other sketch instances are not visible. They must be drawn into the main sketch to see. This is demonstrated in the jsui_imagestuff- example.pat, in the sketchpix() js function, which I've included below. You can also copy sketch instances pixels to an image for use with the other image drawing functions. Hope this gets you on the right track. -Joshua // the sketchpix function demonstrates rendering into another instance of sketch // and then copying to the main Sketch object, this.sketch. this can be useful // to make sprites, or generating geometry based alpha masks, etc. function sketchpix(x,y) { // create a new instance of sketch var rendersketch = new Sketch(64,64); // draw some things in new sketch instance with (rendersketch) { default2d(); glcolor(0,1,0,1); moveto(0,0); circle(0.7); glcolor(1,0,0,1); roundedplane(0.1,0.3); } // copy to main sketch instance with (sketch) { glclearcolor(0,0,1,1); glclear(); if (myblend) glenable("blend"); else gldisable("blend"); copypixels(rendersketch,x,y); } refresh(); } From cycling at editions-ihs.com Sat Dec 22 08:30:34 2007 From: cycling at editions-ihs.com (Salvator) Date: Sat Dec 22 08:30:37 2007 Subject: [javascript-dev] Re: jsui mysketch In-Reply-To: Message-ID: <1e641.476d2d9a@www.cycling74.com> Hi Joshua, In the copypix example, the "blend" feature work, though it does not work anymore in this sketchpix + rendersketch case. How is it possible to make the white section in the rendersketch disapear ? I too like the idea of having several sketches, to avoid redrawing, and then render them in the main sketch. Salvator From klaus at klingt.org Sat Dec 22 11:29:44 2007 From: klaus at klingt.org (klaus filip) Date: Sat Dec 22 11:29:53 2007 Subject: [javascript-dev] jsui mysketch In-Reply-To: References: Message-ID: thanks joshua, so this means i have to clear the entire main sketch on every move of one of my sliders. maybe a good approach then would be to "record" all other sliders into one sketch instance, and redraw the moving slider together with a copypixels of that sketch instance. \\ klaus On Dec 20, 2007, at 9:13 PM, Joshua Kit Clayton wrote: > > On Dec 20, 2007, at 6:27 AM, klaus filip wrote: > >> hi >> i am trying to build a multi-2D slider as jsui and hanging at the >> very basics. >> since i don't want to redraw all sliders i want to use multiple >> sketches (like sprites). >> below is my basic misunderstanding, the function dsketch works, >> but the function dsketch2 is doing nothing... > > Other sketch instances are not visible. They must be drawn into the > main sketch to see. This is demonstrated in the jsui_imagestuff- > example.pat, in the sketchpix() js function, which I've included > below. You can also copy sketch instances pixels to an image for > use with the other image drawing functions. Hope this gets you on > the right track. > > > -Joshua From jkc at musork.com Sat Dec 22 13:23:24 2007 From: jkc at musork.com (Joshua Kit Clayton) Date: Sat Dec 22 13:23:33 2007 Subject: [javascript-dev] Re: jsui mysketch In-Reply-To: <1e641.476d2d9a@www.cycling74.com> References: <1e641.476d2d9a@www.cycling74.com> Message-ID: <5C07FF4D-39C5-4BC9-9A2E-48AFF15FABE7@musork.com> On Dec 22, 2007, at 7:30 AM, Salvator wrote: > In the copypix example, the "blend" feature work, though it does > not work anymore in this sketchpix + rendersketch case. > > How is it possible to make the white section in the rendersketch > disapear ? Did you see the sketchpixalpha example? It uses a chromakey type algorithm on a target color to generate an alpha channel. -Joshua From jkc at musork.com Sat Dec 22 13:27:15 2007 From: jkc at musork.com (Joshua Kit Clayton) Date: Sat Dec 22 13:27:24 2007 Subject: [javascript-dev] jsui mysketch In-Reply-To: References: Message-ID: <42A8A765-E889-42C2-B81B-934234796847@musork.com> On Dec 22, 2007, at 10:29 AM, klaus filip wrote: > thanks joshua, > so this means i have to clear the entire main sketch on every move > of one of my sliders. No, you can just draw on to the sub-region desired (if you need the background cleared for the sprite, you can draw a colored rectangle rather than use an entire glclear call). Make sense? > maybe a good approach then would be to "record" all other sliders > into one sketch instance, > and redraw the moving slider together with a copypixels of that > sketch instance. You can use the main sketch as this group buffer if you like as the above might suggest. If you have a clear example where you are having issues with the suggested approach, we could point out any remaining issues. -Joshua From klaus at klingt.org Thu Dec 27 09:56:28 2007 From: klaus at klingt.org (klaus filip) Date: Thu Dec 27 09:56:42 2007 Subject: [javascript-dev] jsui mysketch In-Reply-To: <42A8A765-E889-42C2-B81B-934234796847@musork.com> References: <42A8A765-E889-42C2-B81B-934234796847@musork.com> Message-ID: <80A36C63-8A28-495A-A608-D87E9DC21CA1@klingt.org> > > If you have a clear example where you are having issues with the > suggested approach, we could point out any remaining issues. > > -Joshua well, here is my second approach. i sticked to the copypixel of the buffer sketch (sketch2) because i need to redraw sliders that were covered by the moving slider. thanks for any advices. klaus the testing patch: #P toggle 154 31 15 0; #P window setfont "Sans Serif" 9.; #P window linecount 1; #P message 153 50 44 196617 fsaa \$1; #P message 34 405 87 196617 1 369 124; #P newex 34 380 62 196617 prepend set; #P flonum 83 27 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P message 82 47 53 196617 radius \$1; #P button 239 134 15 0; #N vpatcher 50 119 650 519; #P inlet 241 72 15 0; #P outlet 142 250 15 0; #P window setfont "Sans Serif" 9.; #P newex 242 221 75 196617 prepend points; #P newex 332 181 31 196617 + 20; #P newex 242 164 27 196617 - 1; #P button 241 96 15 0; #P newex 242 192 40 196617 0 0 0; #P newex 279 162 32 196617 * 20; #P newex 332 161 27 196617 * 2; #P newex 241 122 40 196617 uzi 20; #P connect 7 0 8 0; #P connect 0 1 8 0; #P connect 9 0 4 0; #P connect 4 0 0 0; #P connect 0 2 5 0; #P connect 5 0 3 0; #P connect 3 0 7 0; #P connect 2 0 3 1; #P connect 6 0 3 2; #P connect 0 2 2 0; #P connect 0 2 1 0; #P connect 1 0 6 0; #P pop; #P newobj 239 153 53 196617 p draw20; #P message 156 128 52 196617 0 200 10; #P message 34 113 87 196617 clearpoints \, bang; #P button 103 144 15 0; #P message 135 109 144 196617 0 200 70 \, 1 300 20 \, 2 50 50; #P newex 145 153 75 196617 prepend points; #P user jsui 34 179 571 191 3 0 0 llseq.js; #P connect 12 0 0 0; #P connect 8 0 0 0; #P connect 4 0 0 0; #P connect 3 0 0 0; #P connect 1 0 0 0; #P connect 6 0 0 0; #P connect 0 0 10 0; #P connect 10 0 11 0; #P connect 9 0 8 0; #P connect 5 0 3 0; #P connect 2 0 3 0; #P connect 5 0 1 0; #P connect 2 0 1 0; #P connect 13 0 12 0; #P connect 7 0 6 0; #P window clipboard copycount 14; the (hopefully not too messy) javascript: autowatch = 1; inlets = 2; outlets = 1; sketch.default2d(); var vbrgb = [0.3,0.3,0.6]; var vfrgb = [0.8,0.8,0.3]; var w = [0,0,0]; var vx = 0; var vy = 0; var vradius; var wradius; var width = box.rect[2] - box.rect[0]; var height = box.rect[3] - box.rect[1]; var point = new Array(); var dx, dy, selected; var sketch2 = new Sketch(width,height); sketch2.default2d(); radius(0.1); function clearpoints() { point.length = 0; selected = -1; rendersketch(); with (sketch) { glclearcolor(vbrgb); glclear(); } refresh(); } function points() { var a = arrayfromargs(arguments); var b = a.length; point[arguments[0]] = [arguments[1], height-arguments[2]]; if (a.length>3) point[a[0][3]] = a[3]; rendersketch(); } function draw() { w = sketch.screentoworld(point[selected]); with (sketch) { glclearcolor(vbrgb); glclear(); copypixels(sketch2,0,0); if (selected > -1) { glcolor(vfrgb); moveto(w[0]+vradius,w[1]-vradius); plane(vradius,vradius); moveto(w[0],w[1]-0.01); line(0,-2.); } } } function bang() { draw(); refresh(); } function fsaa(v) { sketch.fsaa = v; sketch2.fsaa = v; bang(); } function frgb(r,g,b) { vfrgb[0] = r/255.; vfrgb[1] = g/255.; vfrgb[2] = b/255.; draw(); refresh(); } function brgb(r,g,b) { vbrgb[0] = r/255.; vbrgb[1] = g/255.; vbrgb[2] = b/255.; draw(); refresh(); } function radius(v) { vradius = v; wradius = (sketch.worldtoscreen(v)[0]-sketch.worldtoscreen(0)[0])*2.; draw(); refresh(); } function onresize(w,h) { width = box.rect[2] - box.rect[0]; height = box.rect[3] - box.rect[1]; post("width", width, " height", height, "\n"); draw(); refresh(); } onresize.local = 1; //private function rendersketch() { with (sketch2) { glclearcolor(vbrgb); glclear(); } for (i=0;iwidth) x = width; if (y<0) y = 0; else if (y>height) y = height; selected = -1; for (i=0;ipoint[i][0] && xpoint[i][1] && y-1) { point[selected][0] = x+dx; point[selected][1] = y+dy; outlet(0,selected,point[selected][0],height-point[selected][1]); bang(); } } ondrag.local = 1; //private -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.cycling74.com/pipermail/javascript-dev/attachments/20071227/85f1b546/attachment.htm From cycling at editions-ihs.com Fri Dec 28 04:20:02 2007 From: cycling at editions-ihs.com (Salvator) Date: Fri Dec 28 04:20:05 2007 Subject: [javascript-dev] jsui border color Message-ID: <1e796.4774dbe1@www.cycling74.com> Hi, This jsui is very cool to design custom controls. Thanks ! Any way to change the "border" color of a JSUI ? Salvator From jkc at musork.com Fri Dec 28 12:32:16 2007 From: jkc at musork.com (Joshua Kit Clayton) Date: Fri Dec 28 12:32:23 2007 Subject: [javascript-dev] jsui border color In-Reply-To: <1e796.4774dbe1@www.cycling74.com> References: <1e796.4774dbe1@www.cycling74.com> Message-ID: <475B511C-B9AF-4CAD-A87C-9E6A24B6A8B5@musork.com> On Dec 28, 2007, at 3:20 AM, Salvator wrote: > Any way to change the "border" color of a JSUI ? You can always turn border off and draw your own border within the JSUI code. -Joshua From jackwphillips at gmail.com Sat Dec 29 23:14:07 2007 From: jackwphillips at gmail.com (Jack Phillips) Date: Sat Dec 29 23:14:21 2007 Subject: [javascript-dev] How to get matrixoutput from jit.gl.gridshape Message-ID: <0CF7375B-A8CF-476E-998E-683241C55BEC@gmail.com> Hi list, I'm currently trying to get the hang of javascript with jitter, but I've hit a bit of a snag. I'm trying to recreate Andrew's Jitter Recipe 12: Texture Distortion in js. I need to be able to grab the output matrix of a jit.gl.gridshape object in matrixoutput mode. 1) How do I do this? and 2) Is it necessary to declare a render destination if the gridshape is only used in matrixoutput mode? Here's the relevant code: var myShape = new JitterObject("jit.gl.gridshape"); //Render destination necessary? myShape.shape = "plane"; myShape.dim = [2, 2]; myShape.matrixoutput = 1; var shapeMatrix = new JitterMatrix(3, "float32", 2, 2); function bang() { myShape.matrixcalc(shapeMatrix, shapeMatrix) //What's the right method call? outlet(0, "jit_matrix", shapeMatrix.name); } Thanks for any insights. From wesley.hoke at gmail.com Sat Dec 29 23:21:10 2007 From: wesley.hoke at gmail.com (Wesley Smith) Date: Sat Dec 29 23:21:14 2007 Subject: [javascript-dev] How to get matrixoutput from jit.gl.gridshape In-Reply-To: <0CF7375B-A8CF-476E-998E-683241C55BEC@gmail.com> References: <0CF7375B-A8CF-476E-998E-683241C55BEC@gmail.com> Message-ID: <1079b050712292221r34c36e75vc17483bd2351ec9c@mail.gmail.com> I don't think you can grab the matrixoutput in JS since that is part of the maxwrapper which JS has no access to. JS Jitter objects simply reference the bare Jitter object (this will make more sense if you have ever done any Jitter C dev or have read related docs. It might even be mentioned in the JSJitter docs). Anyway, there have been threads on this topic before and I believe the conclusion was it's simply not possible due to the lack of outlet knowledge in JS. As an alternative, gridshapes can be easily built with jit.expr expressions. In fact the name jit.gl.gridshape comes from the mapping of the vertex data to a grid aka a matrix and the simple expressions used to generate the corresponding geometry. best, wes On Dec 30, 2007 12:14 AM, Jack Phillips wrote: > Hi list, > > I'm currently trying to get the hang of javascript with jitter, but > I've hit a bit of a snag. I'm trying to recreate Andrew's Jitter > Recipe 12: Texture Distortion in js. I need to be able to grab the > output matrix of a jit.gl.gridshape object in matrixoutput mode. 1) > How do I do this? and 2) Is it necessary to declare a render > destination if the gridshape is only used in matrixoutput mode? > > Here's the relevant code: > > var myShape = new JitterObject("jit.gl.gridshape"); //Render > destination necessary? > myShape.shape = "plane"; > myShape.dim = [2, 2]; > myShape.matrixoutput = 1; > var shapeMatrix = new JitterMatrix(3, "float32", 2, 2); > > function bang() { > myShape.matrixcalc(shapeMatrix, shapeMatrix) //What's the right > method call? > outlet(0, "jit_matrix", shapeMatrix.name); > } > > Thanks for any insights. > > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev > From jkc at musork.com Sun Dec 30 01:10:49 2007 From: jkc at musork.com (Joshua Kit Clayton) Date: Sun Dec 30 01:11:00 2007 Subject: [javascript-dev] How to get matrixoutput from jit.gl.gridshape In-Reply-To: <1079b050712292221r34c36e75vc17483bd2351ec9c@mail.gmail.com> References: <0CF7375B-A8CF-476E-998E-683241C55BEC@gmail.com> <1079b050712292221r34c36e75vc17483bd2351ec9c@mail.gmail.com> Message-ID: <7473A450-38BB-4C99-885A-447115E3389B@musork.com> I think if you use JitterListener with a jit.gl object with @matrixoutput 1 you can get access to the matrix output in javascript. Should work but long time since I tested this. Let us know if it doesn't work. -Joshua On Dec 29, 2007, at 10:21 PM, "Wesley Smith" wrote: > I don't think you can grab the matrixoutput in JS since that is part > of the maxwrapper which JS has no access to. JS Jitter objects simply > reference the bare Jitter object (this will make more sense if you > have ever done any Jitter C dev or have read related docs. It might > even be mentioned in the JSJitter docs). Anyway, there have been > threads on this topic before and I believe the conclusion was it's > simply not possible due to the lack of outlet knowledge in JS. > > As an alternative, gridshapes can be easily built with jit.expr > expressions. In fact the name jit.gl.gridshape comes from the mapping > of the vertex data to a grid aka a matrix and the simple expressions > used to generate the corresponding geometry. > > best, > wes > > On Dec 30, 2007 12:14 AM, Jack Phillips > wrote: >> Hi list, >> >> I'm currently trying to get the hang of javascript with jitter, but >> I've hit a bit of a snag. I'm trying to recreate Andrew's Jitter >> Recipe 12: Texture Distortion in js. I need to be able to grab the >> output matrix of a jit.gl.gridshape object in matrixoutput mode. 1) >> How do I do this? and 2) Is it necessary to declare a render >> destination if the gridshape is only used in matrixoutput mode? >> >> Here's the relevant code: >> >> var myShape = new JitterObject("jit.gl.gridshape"); //Render >> destination necessary? >> myShape.shape = "plane"; >> myShape.dim = [2, 2]; >> myShape.matrixoutput = 1; >> var shapeMatrix = new JitterMatrix(3, "float32", 2, 2); >> >> function bang() { >> myShape.matrixcalc(shapeMatrix, shapeMatrix) //What's the >> right >> method call? >> outlet(0, "jit_matrix", shapeMatrix.name); >> } >> >> Thanks for any insights. >> >> _______________________________________________ >> javascript-dev mailing list >> javascript-dev@cycling74.com >> http://www.cycling74.com/mailman/listinfo/javascript-dev >> > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev