From lists at zdomain.net Sun Nov 4 20:04:52 2007 From: lists at zdomain.net (lists@zdomain.net) Date: Sun Nov 4 20:04:55 2007 Subject: [javascript-dev] Searching through a string Message-ID: <20071104220452.6g8qugyxqzccwgoo@www.zdomain.net> Hi all: I've been trying to get the following search script to work, but I get "inputString.search is not a function". What am I doing wrong? ----BEGIN SCRIPT---- function anything() { var pattern=/href/; inputString = arrayfromargs(messagename, arguments); post("LENGTH IS " + inputString.length); for (var i=0; i References: <20071104220452.6g8qugyxqzccwgoo@www.zdomain.net> Message-ID: <1079b050711041912p5aee3c83w72c98ad61de368bf@mail.gmail.com> inputString is an array in your code. Perhaps you need to do inputString[i].search(pattern). wes On 11/4/07, lists@zdomain.net wrote: > Hi all: > > I've been trying to get the following search script to work, but I get > "inputString.search is not a function". What am I doing wrong? > > ----BEGIN SCRIPT---- > function anything() > { > var pattern=/href/; > inputString = arrayfromargs(messagename, arguments); > post("LENGTH IS " + inputString.length); > for (var i=0; i if (inputString.search(pattern)){ > outputString="There it is!"; > } > else{ > outputString = "Sorry, not here!"; > } > } > bang(); > } > ----END SCRIPT---- > > Thanks in advance, > > -R > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev > From lists at zdomain.net Sun Nov 4 20:36:23 2007 From: lists at zdomain.net (lists@zdomain.net) Date: Sun Nov 4 20:36:26 2007 Subject: [javascript-dev] Searching through a string In-Reply-To: <1079b050711041912p5aee3c83w72c98ad61de368bf@mail.gmail.com> References: <20071104220452.6g8qugyxqzccwgoo@www.zdomain.net> <1079b050711041912p5aee3c83w72c98ad61de368bf@mail.gmail.com> Message-ID: <20071104223623.65nfn7aozg4gcs4s@www.zdomain.net> Thanks for the reply, Wesley. I was able to get it to work, thanks in no small part to using your observation! Here is the working code: ----BEGIN SCRIPT---- function anything() { var pattern=/sleep/; inputString = arrayfromargs(messagename, arguments); post("LENGTH IS " + inputString.length); post(inputString); for (var i=0; i: > inputString is an array in your code. Perhaps you need to do > inputString[i].search(pattern). > > wes > > On 11/4/07, lists@zdomain.net wrote: >> Hi all: >> >> I've been trying to get the following search script to work, but I get >> "inputString.search is not a function". What am I doing wrong? >> >> ----BEGIN SCRIPT---- >> function anything() >> { >> var pattern=/href/; >> inputString = arrayfromargs(messagename, arguments); >> post("LENGTH IS " + inputString.length); >> for (var i=0; i> if (inputString.search(pattern)){ >> outputString="There it is!"; >> } >> else{ >> outputString = "Sorry, not here!"; >> } >> } >> bang(); >> } >> ----END SCRIPT---- >> >> Thanks in advance, >> >> -R >> _______________________________________________ >> 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 > From lists at lowfrequency.org Tue Nov 6 11:19:05 2007 From: lists at lowfrequency.org (evan.raskob [lists]) Date: Tue Nov 6 11:19:11 2007 Subject: [javascript-dev] js disobeys law of cause and effect Message-ID: Hello, I am banging my head against the wall with a very strange javascript problem. I've always assumed that messages passed from a javascript outlet occur in the order I send them. Apparently, this is not the case. I have code to draw on jit.lcd automatically - it should move the pen to an initial spot ("moveto x y"), send a bang (so that the pen is updated), then get the dimensions of jit.lcd ("getdim"). I have a function "dim (x,y)" that should receive the jit.lcd dimensions, and in turn query it for the pen location (via the "getpenloc" message to jit.lcd). I have a function in js called "penloc (x,y)" that should receive data from the jit.lcd telling me where the pen is located so i can continue drawing. Sounds very simple, no? In reality, I run the code and see the message "getdim" which triggered the "getpenloc" message AT THE END of the output from the js object. Which makes no sense, because getdim would have to be sent in order to trigger the drawing in the first place. Also, the "clear" message to jit.lcd is executed LAST, even though it appears in the max window as having been sent in the proper order (FIRST). In fact, the entire output seems absolutely arbitrary to me, with "getpenloc" calls all stacked in a row (or not at all). I have tried using immediate mode to see if there is a difference, and tried adding and subtracting [deferlow] and [jit.qball] objects after both the jit.lcd and the js, but no hope. Please help! -Evan From wesley.hoke at gmail.com Tue Nov 6 11:22:55 2007 From: wesley.hoke at gmail.com (Wesley Smith) Date: Tue Nov 6 11:22:58 2007 Subject: [javascript-dev] js disobeys law of cause and effect In-Reply-To: References: Message-ID: <1079b050711061022j66302deau8bacd8e5f11c569f@mail.gmail.com> While I understand roughly form your desription what's going on, there's no way to really help you without an actual script and patch. wes On 11/6/07, evan.raskob [lists] wrote: > Hello, > > I am banging my head against the wall with a very strange javascript > problem. > > I've always assumed that messages passed from a javascript outlet > occur in the order I send them. Apparently, this is not the case. > > I have code to draw on jit.lcd automatically - it should move the pen > to an initial spot ("moveto x y"), send a bang (so that the pen is > updated), then get the dimensions of jit.lcd ("getdim"). I have a > function "dim (x,y)" that should receive the jit.lcd dimensions, and > in turn query it for the pen location (via the "getpenloc" message to > jit.lcd). I have a function in js called "penloc (x,y)" that should > receive data from the jit.lcd telling me where the pen is located so > i can continue drawing. Sounds very simple, no? In reality, I run > the code and see the message "getdim" which triggered the "getpenloc" > message AT THE END of the output from the js object. Which makes no > sense, because getdim would have to be sent in order to trigger the > drawing in the first place. Also, the "clear" message to jit.lcd is > executed LAST, even though it appears in the max window as having > been sent in the proper order (FIRST). > > In fact, the entire output seems absolutely arbitrary to me, with > "getpenloc" calls all stacked in a row (or not at all). I have tried > using immediate mode to see if there is a difference, and tried > adding and subtracting [deferlow] and [jit.qball] objects after both > the jit.lcd and the js, but no hope. > > Please help! > > > > -Evan > > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev > From lists at lowfrequency.org Tue Nov 6 14:03:36 2007 From: lists at lowfrequency.org (evan.raskob [lists]) Date: Tue Nov 6 14:03:42 2007 Subject: [javascript-dev] js disobeys law of cause and effect In-Reply-To: <1079b050711061022j66302deau8bacd8e5f11c569f@mail.gmail.com> References: <1079b050711061022j66302deau8bacd8e5f11c569f@mail.gmail.com> Message-ID: <929D8C6D-B4F8-4149-8590-4438043A270F@lowfrequency.org> I guess there's no way around it: http://lowfrequency.org/stuff/js-lcd-draw-test.zip I don't want to make it public, but there it is. I'll take it down soon. Thanks Evan On Nov 6, 2007, at 6:22 PM, Wesley Smith wrote: > While I understand roughly form your desription what's going on, > there's no way to really help you without an actual script and patch. > > wes > > On 11/6/07, evan.raskob [lists] wrote: >> Hello, >> >> I am banging my head against the wall with a very strange javascript >> problem. >> >> I've always assumed that messages passed from a javascript outlet >> occur in the order I send them. Apparently, this is not the case. >> >> I have code to draw on jit.lcd automatically - it should move the pen >> to an initial spot ("moveto x y"), send a bang (so that the pen is >> updated), then get the dimensions of jit.lcd ("getdim"). I have a >> function "dim (x,y)" that should receive the jit.lcd dimensions, and >> in turn query it for the pen location (via the "getpenloc" message to >> jit.lcd). I have a function in js called "penloc (x,y)" that should >> receive data from the jit.lcd telling me where the pen is located so >> i can continue drawing. Sounds very simple, no? In reality, I run >> the code and see the message "getdim" which triggered the "getpenloc" >> message AT THE END of the output from the js object. Which makes no >> sense, because getdim would have to be sent in order to trigger the >> drawing in the first place. Also, the "clear" message to jit.lcd is >> executed LAST, even though it appears in the max window as having >> been sent in the proper order (FIRST). >> >> In fact, the entire output seems absolutely arbitrary to me, with >> "getpenloc" calls all stacked in a row (or not at all). I have tried >> using immediate mode to see if there is a difference, and tried >> adding and subtracting [deferlow] and [jit.qball] objects after both >> the jit.lcd and the js, but no hope. >> >> Please help! >> >> >> >> -Evan >> >> _______________________________________________ >> 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 From wesley.hoke at gmail.com Tue Nov 6 14:15:10 2007 From: wesley.hoke at gmail.com (Wesley Smith) Date: Tue Nov 6 14:15:15 2007 Subject: [javascript-dev] js disobeys law of cause and effect In-Reply-To: <929D8C6D-B4F8-4149-8590-4438043A270F@lowfrequency.org> References: <1079b050711061022j66302deau8bacd8e5f11c569f@mail.gmail.com> <929D8C6D-B4F8-4149-8590-4438043A270F@lowfrequency.org> Message-ID: <1079b050711061315te3e675ar46f505d4e866e63f@mail.gmail.com> One question I have is why don't you just put the jit.lcd object in your javasript? wes On 11/6/07, evan.raskob [lists] wrote: > I guess there's no way around it: > > http://lowfrequency.org/stuff/js-lcd-draw-test.zip > > I don't want to make it public, but there it is. I'll take it down > soon. > > > Thanks > Evan > > > On Nov 6, 2007, at 6:22 PM, Wesley Smith wrote: > > > While I understand roughly form your desription what's going on, > > there's no way to really help you without an actual script and patch. > > > > wes > > > > On 11/6/07, evan.raskob [lists] wrote: > >> Hello, > >> > >> I am banging my head against the wall with a very strange javascript > >> problem. > >> > >> I've always assumed that messages passed from a javascript outlet > >> occur in the order I send them. Apparently, this is not the case. > >> > >> I have code to draw on jit.lcd automatically - it should move the pen > >> to an initial spot ("moveto x y"), send a bang (so that the pen is > >> updated), then get the dimensions of jit.lcd ("getdim"). I have a > >> function "dim (x,y)" that should receive the jit.lcd dimensions, and > >> in turn query it for the pen location (via the "getpenloc" message to > >> jit.lcd). I have a function in js called "penloc (x,y)" that should > >> receive data from the jit.lcd telling me where the pen is located so > >> i can continue drawing. Sounds very simple, no? In reality, I run > >> the code and see the message "getdim" which triggered the "getpenloc" > >> message AT THE END of the output from the js object. Which makes no > >> sense, because getdim would have to be sent in order to trigger the > >> drawing in the first place. Also, the "clear" message to jit.lcd is > >> executed LAST, even though it appears in the max window as having > >> been sent in the proper order (FIRST). > >> > >> In fact, the entire output seems absolutely arbitrary to me, with > >> "getpenloc" calls all stacked in a row (or not at all). I have tried > >> using immediate mode to see if there is a difference, and tried > >> adding and subtracting [deferlow] and [jit.qball] objects after both > >> the jit.lcd and the js, but no hope. > >> > >> Please help! > >> > >> > >> > >> -Evan > >> > >> _______________________________________________ > >> 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 > > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev > From jkc at musork.com Tue Nov 6 14:30:57 2007 From: jkc at musork.com (Joshua Kit Clayton) Date: Tue Nov 6 14:31:01 2007 Subject: [javascript-dev] js disobeys law of cause and effect In-Reply-To: <1079b050711061315te3e675ar46f505d4e866e63f@mail.gmail.com> References: <1079b050711061022j66302deau8bacd8e5f11c569f@mail.gmail.com> <929D8C6D-B4F8-4149-8590-4438043A270F@lowfrequency.org> <1079b050711061315te3e675ar46f505d4e866e63f@mail.gmail.com> Message-ID: <9B4A7AC4-7204-4D3E-8AA7-9D9C0625BF82@musork.com> > One question I have is why don't you just put the jit.lcd object in > your javasript? IIRC, jit.lcd has issues when used from within scripting. Regardless, jit.lcd drawing commands do *not* execute until you trigger a bang, which is why I believe that penloc doesn't update when you're expecting it. -Joshua From lists at lowfrequency.org Tue Nov 6 14:44:50 2007 From: lists at lowfrequency.org (evan.raskob [lists]) Date: Tue Nov 6 14:44:55 2007 Subject: [javascript-dev] js disobeys law of cause and effect In-Reply-To: <9B4A7AC4-7204-4D3E-8AA7-9D9C0625BF82@musork.com> References: <1079b050711061022j66302deau8bacd8e5f11c569f@mail.gmail.com> <929D8C6D-B4F8-4149-8590-4438043A270F@lowfrequency.org> <1079b050711061315te3e675ar46f505d4e866e63f@mail.gmail.com> <9B4A7AC4-7204-4D3E-8AA7-9D9C0625BF82@musork.com> Message-ID: <6674C7CB-79CE-4855-87EC-3FAA5D0AF7E2@lowfrequency.org> Hi Joshua, I thought I remembered some threads about not using jit.lcd for scripting, because it doesn't work properly. About sending bangs - yes, I noticed that, which is why I am sending out many bangs to update the pen location after each "moveto" command. Even with that, try hooking up a print to the output of the js object and see what kind of funky order the commands are printed out in. Thanks Evan On Nov 6, 2007, at 9:30 PM, Joshua Kit Clayton wrote: >> One question I have is why don't you just put the jit.lcd object in >> your javasript? > > IIRC, jit.lcd has issues when used from within scripting. > Regardless, jit.lcd drawing commands do *not* execute until you > trigger a bang, which is why I believe that penloc doesn't update > when you're expecting it. > > -Joshua > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev From jkc at musork.com Tue Nov 6 14:53:59 2007 From: jkc at musork.com (Joshua Kit Clayton) Date: Tue Nov 6 14:54:03 2007 Subject: [javascript-dev] js disobeys law of cause and effect In-Reply-To: <6674C7CB-79CE-4855-87EC-3FAA5D0AF7E2@lowfrequency.org> References: <1079b050711061022j66302deau8bacd8e5f11c569f@mail.gmail.com> <929D8C6D-B4F8-4149-8590-4438043A270F@lowfrequency.org> <1079b050711061315te3e675ar46f505d4e866e63f@mail.gmail.com> <9B4A7AC4-7204-4D3E-8AA7-9D9C0625BF82@musork.com> <6674C7CB-79CE-4855-87EC-3FAA5D0AF7E2@lowfrequency.org> Message-ID: <79C9493D-7900-457A-B221-655F91CA6D9C@musork.com> On Nov 6, 2007, at 1:44 PM, evan.raskob [lists] wrote: > I thought I remembered some threads about not using jit.lcd for > scripting, because it doesn't work properly. > > About sending bangs - yes, I noticed that, which is why I am > sending out many bangs to update the pen location after each > "moveto" command. > > Even with that, try hooking up a print to the output of the js > object and see what kind of funky order the commands are printed > out in. This is expected with @mode defer, no? It pushes it to the end of the queue. I don't see anything other than what you'd expect with this sort of feedback loop and deferred messages. I would recommend you segment this so that it doesn't need feedback in this way--e.g. use two js files one to make the bang, getpenloc calls synchronously as necessary and pass in to a second js which does the drawing. Or something along these lines which avoids a feedback loop. Personally, I'd just use the JS Sketch object with fsaa disabled, but I guess you have a reason for doing it this way. -Joshua From lists at lowfrequency.org Wed Nov 7 02:48:13 2007 From: lists at lowfrequency.org (evan.raskob [lists]) Date: Wed Nov 7 02:48:17 2007 Subject: [javascript-dev] js disobeys law of cause and effect In-Reply-To: <79C9493D-7900-457A-B221-655F91CA6D9C@musork.com> References: <1079b050711061022j66302deau8bacd8e5f11c569f@mail.gmail.com> <929D8C6D-B4F8-4149-8590-4438043A270F@lowfrequency.org> <1079b050711061315te3e675ar46f505d4e866e63f@mail.gmail.com> <9B4A7AC4-7204-4D3E-8AA7-9D9C0625BF82@musork.com> <6674C7CB-79CE-4855-87EC-3FAA5D0AF7E2@lowfrequency.org> <79C9493D-7900-457A-B221-655F91CA6D9C@musork.com> Message-ID: <7E410462-5E15-4BB0-9ECF-BDCFB62500FA@lowfrequency.org> Hi Joshua The jit.qball was in there because I felt that events were getting lost between the js and jit.lcd. Even taking it out, it doesn't appear to work properly. I'm still a bit fuzzy as to how events that trigger events in other objects could happen after the events that they were supposed to trigger - perhaps there's something about scheduling that I'm missing here? I'm not very optimistic about using 2 js objects to do this - if the events are coming from jit.lcd and an uneven rate, will separating js objects make a difference? The reason I'm using jit.lcd instead of pure js is because I need to output to a matrix at some point. But now that you mention it, I'd forgotten that I could use jsui for this... I can use "tonamedmatrix" to copy the contents of the jsui to a matrix, right? Best Evan On Nov 6, 2007, at 9:53 PM, Joshua Kit Clayton wrote: > > On Nov 6, 2007, at 1:44 PM, evan.raskob [lists] wrote: > >> I thought I remembered some threads about not using jit.lcd for >> scripting, because it doesn't work properly. >> >> About sending bangs - yes, I noticed that, which is why I am >> sending out many bangs to update the pen location after each >> "moveto" command. >> >> Even with that, try hooking up a print to the output of the js >> object and see what kind of funky order the commands are printed >> out in. > > This is expected with @mode defer, no? It pushes it to the end of > the queue. I don't see anything other than what you'd expect with > this sort of feedback loop and deferred messages. I would recommend > you segment this so that it doesn't need feedback in this way--e.g. > use two js files one to make the bang, getpenloc calls > synchronously as necessary and pass in to a second js which does > the drawing. Or something along these lines which avoids a feedback > loop. > > Personally, I'd just use the JS Sketch object with fsaa disabled, > but I guess you have a reason for doing it this way. > > -Joshua > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev From jkc at musork.com Wed Nov 7 09:46:37 2007 From: jkc at musork.com (Joshua Kit Clayton) Date: Wed Nov 7 09:46:49 2007 Subject: [javascript-dev] js disobeys law of cause and effect In-Reply-To: <7E410462-5E15-4BB0-9ECF-BDCFB62500FA@lowfrequency.org> References: <1079b050711061022j66302deau8bacd8e5f11c569f@mail.gmail.com> <929D8C6D-B4F8-4149-8590-4438043A270F@lowfrequency.org> <1079b050711061315te3e675ar46f505d4e866e63f@mail.gmail.com> <9B4A7AC4-7204-4D3E-8AA7-9D9C0625BF82@musork.com> <6674C7CB-79CE-4855-87EC-3FAA5D0AF7E2@lowfrequency.org> <79C9493D-7900-457A-B221-655F91CA6D9C@musork.com> <7E410462-5E15-4BB0-9ECF-BDCFB62500FA@lowfrequency.org> Message-ID: On Nov 7, 2007, at 1:48 AM, evan.raskob [lists] wrote: > The jit.qball was in there because I felt that events were getting > lost between the js and jit.lcd. Even taking it out, it doesn't > appear to work properly. I'm still a bit fuzzy as to how events > that trigger events in other objects could happen after the events > that they were supposed to trigger - perhaps there's something > about scheduling that I'm missing here? Well if you take the defer out, you might re-enter the same JS before the previous function has completed, which also would give you some odd behavior. > I'm not very optimistic about using 2 js objects to do this - if > the events are coming from jit.lcd and an uneven rate, will > separating js objects make a difference? You could if you separate the logic of iterating N times (no feedback), querying values to be used by another one, and the actual drawing, but perhaps not worth it. Sorry I don't have time to be more detailed in my suggestion. > The reason I'm using jit.lcd instead of pure js is because I need > to output to a matrix at some point. But now that you mention it, > I'd forgotten that I could use jsui for this... I can use > "tonamedmatrix" to copy the contents of the jsui to a matrix, right? Yes. This is what I'd use. You can use the Sketch.gettextinfo() to get the width and height of the string for your positioning needs. -Joshua From gusanomaxlist at googlemail.com Wed Nov 7 11:18:16 2007 From: gusanomaxlist at googlemail.com (gusanomaxlist) Date: Wed Nov 7 11:18:18 2007 Subject: [javascript-dev] screentoworld misunderstanding Message-ID: <1d647.47320168@www.cycling74.com> Hi. I am trying to write a very basic jsui slider, just by modifying the simpleslider.js from the examples. Everything went ok until I tried to make the slider horizontal. It looks like I have a misunderstanding of "sketch.screentoworld". In vertical mode, I have this working perfectly: -------------------------------------------- function ondrag(x,y,....) { var f,a; a=sketch.screentoworld(x,y); f=(a[1]+1)*0.5; msg_float(f); } -------------------------------------------- I thought that replacing a[1] with a[0] would be enough to deal with x coordinates, but for example, if my object is 100x10 pixels, dragging will work horizontally only within 10 pixels around the center (5 left and 5 right) and not on the whole 100... I had a look at other jsui sliders (matsui,...) but they are way too complicated for me... Any help is welcome. Thanx. From c74-mailinglists at e--j.com Wed Nov 7 15:07:42 2007 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Wed Nov 7 15:08:07 2007 Subject: [javascript-dev] screentoworld misunderstanding In-Reply-To: <1d647.47320168@www.cycling74.com> References: <1d647.47320168@www.cycling74.com> Message-ID: On 7 nov. 07, at 19:18, gusanomaxlist wrote: > In vertical mode, I have this working perfectly: > -------------------------------------------- > function ondrag(x,y,....) > { > var f,a; > a=sketch.screentoworld(x,y); > f=(a[1]+1)*0.5; > msg_float(f); > } > -------------------------------------------- > I thought that replacing a[1] with a[0] would be enough to deal > with x coordinates, but for example, if my object is 100x10 pixels, > dragging will work horizontally only within 10 pixels around the > center (5 left and 5 right) and not on the whole 100... Your problem is that on the y axis the value are from -1 to 1 (with 0 being the center of the vertical axis). But for the x axis the location is from -aspect to +aspect (where aspect is the box width/ box height). Have a look to the "jsui_screentoworld-example.pat" example in the examples/javascript/ui folder. something like that should work, although I didn't test it: function ondrag(x,y,....) { var width = box.rect[2] - box.rect[0]; var height = box.rect[3] - box.rect[1]; var aspect = width/height; var a = sketch.screentoworld(x,y); var f = (a[0] + aspect) * aspect * 0.5; msg_float(f); } HTH, ej From gusanomaxlist at googlemail.com Thu Nov 8 03:28:38 2007 From: gusanomaxlist at googlemail.com (gusanomaxlist) Date: Thu Nov 8 03:28:40 2007 Subject: [javascript-dev] Re: screentoworld misunderstanding In-Reply-To: Message-ID: <1d6ab.4732e4d3@www.cycling74.com> got it ;) f = (a[0]+aspect)/aspect*0.5; Thanx a lot ! From c74-mailinglists at e--j.com Thu Nov 8 05:02:00 2007 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Thu Nov 8 05:02:23 2007 Subject: [javascript-dev] Re: screentoworld misunderstanding In-Reply-To: <1d6ab.4732e4d3@www.cycling74.com> References: <1d6ab.4732e4d3@www.cycling74.com> Message-ID: On 8 nov. 07, at 11:28, gusanomaxlist wrote: > f = (a[0]+aspect)/aspect*0.5; oups? Right? that should work better. ej From lists at lowfrequency.org Thu Nov 8 14:29:04 2007 From: lists at lowfrequency.org (evan.raskob [lists]) Date: Thu Nov 8 14:29:12 2007 Subject: [javascript-dev] js disobeys law of cause and effect In-Reply-To: References: <1079b050711061022j66302deau8bacd8e5f11c569f@mail.gmail.com> <929D8C6D-B4F8-4149-8590-4438043A270F@lowfrequency.org> <1079b050711061315te3e675ar46f505d4e866e63f@mail.gmail.com> <9B4A7AC4-7204-4D3E-8AA7-9D9C0625BF82@musork.com> <6674C7CB-79CE-4855-87EC-3FAA5D0AF7E2@lowfrequency.org> <79C9493D-7900-457A-B221-655F91CA6D9C@musork.com> <7E410462-5E15-4BB0-9ECF-BDCFB62500FA@lowfrequency.org> Message-ID: Thanks Joshua for your help. jsui is the way to go. Best Evan On Nov 7, 2007, at 4:46 PM, Joshua Kit Clayton wrote: > > On Nov 7, 2007, at 1:48 AM, evan.raskob [lists] wrote: > >> The jit.qball was in there because I felt that events were getting >> lost between the js and jit.lcd. Even taking it out, it doesn't >> appear to work properly. I'm still a bit fuzzy as to how events >> that trigger events in other objects could happen after the events >> that they were supposed to trigger - perhaps there's something >> about scheduling that I'm missing here? > > Well if you take the defer out, you might re-enter the same JS > before the previous function has completed, which also would give > you some odd behavior. > >> I'm not very optimistic about using 2 js objects to do this - if >> the events are coming from jit.lcd and an uneven rate, will >> separating js objects make a difference? > > You could if you separate the logic of iterating N times (no > feedback), querying values to be used by another one, and the > actual drawing, but perhaps not worth it. Sorry I don't have time > to be more detailed in my suggestion. > >> The reason I'm using jit.lcd instead of pure js is because I need >> to output to a matrix at some point. But now that you mention it, >> I'd forgotten that I could use jsui for this... I can use >> "tonamedmatrix" to copy the contents of the jsui to a matrix, right? > > Yes. This is what I'd use. You can use the Sketch.gettextinfo() to > get the width and height of the string for your positioning needs. > > -Joshua > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev From gusanomaxlist at googlemail.com Fri Nov 9 11:35:41 2007 From: gusanomaxlist at googlemail.com (gusanomaxlist) Date: Fri Nov 9 11:35:45 2007 Subject: [javascript-dev] Re: Re: screentoworld misunderstanding In-Reply-To: Message-ID: <1d753.4734a87c@www.cycling74.com> Hallo. I'm bothering you again... Now I'm stucked on the fine tuning (with shift key). It's (nearly!!) working, but if I press shift while dragging, I loose my value and the slider is fine tuning but re-starting from zero-left. Thanx for your hints. Here is the code: --------------------------------------------- function ondrag(x,y,...) ... var f,a,v,dx; a = sketch.screentoworld(x,y); v = (a[0]+aspect)/aspect*0.5; dx = v - last_x*0.2; //(last_x is initiated with 0) if (shift) { f = v - dx; } else { f = v; } msg_float(f); last_x = v; } --------------------------------------------- From c74-mailinglists at e--j.com Fri Nov 9 12:56:36 2007 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Fri Nov 9 12:56:58 2007 Subject: [javascript-dev] Re: Re: screentoworld misunderstanding In-Reply-To: <1d753.4734a87c@www.cycling74.com> References: <1d753.4734a87c@www.cycling74.com> Message-ID: On 9 nov. 07, at 19:35, gusanomaxlist wrote: > Thanx for your hints. > Here is the code: Something like that? function ondrag(x,y,...) { var f,a,v,dx; a = sketch.screentoworld(x,y); v = (a[0]+aspect)/aspect*0.5; dx = v - last_x; //(last_x is initiated with 0) if (shift) dx *= 0.2; f = v - dx; msg_float(f); last_x = v; } ej From gusanomaxlist at googlemail.com Fri Nov 9 15:12:55 2007 From: gusanomaxlist at googlemail.com (gusanomaxlist) Date: Fri Nov 9 15:12:57 2007 Subject: [javascript-dev] Re: Re: Re: screentoworld misunderstanding In-Reply-To: Message-ID: <1d762.4734db67@www.cycling74.com> Thanx Emmanuel, but I still don't get it. With this: if (shift) { dx = 0.2; f = v - dx; ... I just have a left offset from my mouse, and no "fine tuning". Any idea ? Cheers. From c74-mailinglists at e--j.com Fri Nov 9 15:19:27 2007 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Fri Nov 9 15:19:49 2007 Subject: [javascript-dev] Re: Re: Re: screentoworld misunderstanding In-Reply-To: <1d762.4734db67@www.cycling74.com> References: <1d762.4734db67@www.cycling74.com> Message-ID: On 9 nov. 07, at 23:12, gusanomaxlist wrote: > Thanx Emmanuel, but I still don't get it. > With this: > > if (shift) { > dx = 0.2; > f = v - dx; ... > > I just have a left offset from my mouse, and no "fine tuning". > Any idea ? I suggested that: dx = v - last_x; //(last_x is initiated with 0) // if shift is down, reduce the dx to have "fine tuning if (shift) dx *= 0.2; // means dx = dx * 0.2 f = v - dx; If that doesn't work, please provide the all jsui. ej From gusanomaxlist at googlemail.com Fri Nov 9 16:20:17 2007 From: gusanomaxlist at googlemail.com (gusanomaxlist) Date: Fri Nov 9 16:20:19 2007 Subject: [javascript-dev] Re: Re: Re: Re: screentoworld misunderstanding In-Reply-To: Message-ID: <1d768.4734eb31@www.cycling74.com> sorry, I miswrote it. I am sure that it's something really stupid but I just can't find it. The js is attached. Thanx. -------------- next part -------------- /* gusano@altern.org . 11/2007 horizontal slider with label (this is my first jsui ever...) adapted from jsui_simpleslider and jsui_textbutton */ autowatch = 1; inspector =1; setinletassist(0,"value"); setoutletassist(0,"value"); sketch.default2d(); var mytext = "slider"; var myfont = "Sans Serif"; var myfontsize = 0.6; // relative to height var val = 0; var vbrgb = [0.94,0.94,0.94]; var vfrgb = [0.55,0.76,1]; var vfrgb2 = [0.39,0.39,0.39]; var width = box.rect[2] - box.rect[0]; var height = box.rect[3] - box.rect[1]; var aspect = width/height; var last_x = 0; draw(); function draw() { with (sketch) { //scale everything to box size glmatrixmode("modelview"); glpushmatrix(); glscale(aspect,1,1); glenable("line_smooth"); // erase background glclearcolor(vbrgb); glclear(); // draw value glcolor(vfrgb); shapeslice(1,1); moveto(val-1,0); //relative left plane(val,1); //write text glcolor(vfrgb2); moveto( 0, 0); font(myfont); fontsize(myfontsize*height); textalign("center","center"); text(mytext); //reset transformation matrix glmatrixmode("modelview"); glpopmatrix(); } } function bang() { draw(); refresh(); outlet(0,val); } function text(v) { mytext = v.toString(); bang(); } function font(v) { myfont = v.toString(); bang(); } function fontsize(f) { myfontsize = f; bang(); } function msg_float(v) { val = Math.min(Math.max(0,v),1); notifyclients(); bang(); } function fsaa(v) { sketch.fsaa = v; bang(); } function frgb(r,g,b) { vfrgb[0] = r/255.; vfrgb[1] = g/255.; vfrgb[2] = b/255.; draw(); refresh(); } function frgb2(r,g,b) { vfrgb2[0] = r/255.; vfrgb2[1] = g/255.; vfrgb2[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 setvalueof(v) { msg_float(v); } function getvalueof() { return val; } function onclick(x,y,but,cmd,shift,capslock,option,ctrl) { ondrag(x,y,but,cmd,shift,capslock,option,ctrl) } onclick.local = 1; //private function ondrag(x,y,but,cmd,shift,capslock,option,ctrl) { var f,a,v,dx; a = sketch.screentoworld(x,y); v = (a[0]+aspect)/aspect*0.5; dx = v - last_x; if (shift) { dx *= 0.2; f = v - dx; } else { f = v; } msg_float(f); last_x = v; } ondrag.local = 1; //private function onresize(w,h) { draw(); refresh(); } onresize.local = 1; //private function save() { embedmessage("brgb", Math.floor(vbrgb[0]*255), Math.floor(vbrgb[1]*255), Math.floor(vbrgb[2]*255)); embedmessage("frgb2", Math.floor(vfrgb2[0]*255), Math.floor(vfrgb2[1]*255), Math.floor(vfrgb2[2]*255)); embedmessage("frgb", Math.floor(vfrgb[0]*255), Math.floor(vfrgb[1]*255), Math.floor(vfrgb[2]*255)); embedmessage("text", mytext); embedmessage("fontsize", myfontsize); embedmessage("notifyclients"); } From asger at komputerwolf.com Wed Nov 14 13:11:39 2007 From: asger at komputerwolf.com (asger) Date: Wed Nov 14 13:11:40 2007 Subject: [javascript-dev] Multislider in javascript Message-ID: <1d8f0.473b567a@www.cycling74.com> Hello I'm new to Javascript in max/msp, so this is probably a pretty straight forward question. How do i make a multislider? I found this code for creating a uslider in one of the examples: thesliders[k] = this.patcher.newdefault(300+(k*50), 100, "uslider"); - so I'm guessing that I just have to change property to "multislider", but that doesn't work. I would also love to be pointed to a more complete max/msp javascript reference than the one in the max documentation. thanks - asger From bthrew at gmail.com Fri Nov 16 16:08:04 2007 From: bthrew at gmail.com (barry threw) Date: Fri Nov 16 16:08:32 2007 Subject: [javascript-dev] jit.buffer~ Message-ID: <25E645B2-5258-4294-B15C-23636806C436@gmail.com> Hello friends, I am trying to load a folder of samples into buffer, have been attempting it this way, and it hasn't been working... I know its something simple...any help? outlets = 0; var buffers = new Array(); function read(foldername) { var f = new Folder(foldername); var i; f.reset(); for (i=0;i How do I apply a video texture to openGL objects in Javascript? I've looked through the documentation and can't seem to find it. I'm just modifying tutorial 47 at the moment, this is what I have so far. I think i'm just missing a name but I'm not sure the syntax for arguements in GL objects: //set video texture from movie var myvideo = new JitterObject("jit.qt.movie", 320, 240); //set Matrix for video var mymatrix = new JitterMatrix(4, "char", 320, 240); //Read a movie function read(filename) { if(arguments.length==0) { //no movie specified, so open a dialog myvideo.read(); } else {myvideo.read(filename); } } //create texture var tex1 = new JitterObject("jit.gl.texture", "ListenWindow"); // create a [jit.gl.gridshape] object for use to control with the mouse var mywidget = new JitterObject("jit.gl.gridshape","ListenWindow"); mywidget.shape = "sphere"; mywidget.lighting_enable = 1; mywidget.smooth_shading = 1; mywidget.texture = tex1; mywidget.scale = [0.1,0.1,0.1]; mywidget.color = [1,1,1,0.5] ; mywidget.blend_enable = 1; mywidget.position = [0,0]; From wesley.hoke at gmail.com Fri Nov 16 21:15:09 2007 From: wesley.hoke at gmail.com (Wesley Smith) Date: Fri Nov 16 21:15:11 2007 Subject: [javascript-dev] Video Texture on OpenGL in Javascript In-Reply-To: <1d9cf.473e6987@www.cycling74.com> References: <1d9cf.473e6987@www.cycling74.com> Message-ID: <1079b050711162015i1cc4e82l80ab9ea848d7f5f7@mail.gmail.com> the texture attribute takes a string of the texture name, not the object itself. mywidget.texture = tex1.name; wes On 11/16/07, Andrew Roth wrote: > > How do I apply a video texture to openGL objects in Javascript? I've looked through the documentation and can't seem to find it. > > I'm just modifying tutorial 47 at the moment, this is what I have so far. I think i'm just missing a name but I'm not sure the syntax for arguements in GL objects: > > //set video texture from movie > var myvideo = new JitterObject("jit.qt.movie", 320, 240); > //set Matrix for video > var mymatrix = new JitterMatrix(4, "char", 320, 240); > //Read a movie > function read(filename) > { > if(arguments.length==0) { > //no movie specified, so open a dialog > myvideo.read(); > } > else {myvideo.read(filename); > } > } > //create texture > var tex1 = new JitterObject("jit.gl.texture", "ListenWindow"); > > // create a [jit.gl.gridshape] object for use to control with the mouse > var mywidget = new JitterObject("jit.gl.gridshape","ListenWindow"); > mywidget.shape = "sphere"; > mywidget.lighting_enable = 1; > mywidget.smooth_shading = 1; > mywidget.texture = tex1; > mywidget.scale = [0.1,0.1,0.1]; > mywidget.color = [1,1,1,0.5] ; > mywidget.blend_enable = 1; > mywidget.position = [0,0]; > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev > From aroth21 at rogers.com Sat Nov 17 08:43:52 2007 From: aroth21 at rogers.com (Andrew Roth) Date: Sat Nov 17 08:43:53 2007 Subject: [javascript-dev] Re: Video Texture on OpenGL in Javascript In-Reply-To: <1d9cf.473e6987@www.cycling74.com> Message-ID: <1da05.473f0c38@www.cycling74.com> Thanks! That helps a lot! :) Is there a good guide or resource for learning Javascript in Max? Seems I haven't quite got the hang of it yet. From wesley.hoke at gmail.com Sat Nov 17 12:15:49 2007 From: wesley.hoke at gmail.com (Wesley Smith) Date: Sat Nov 17 12:15:53 2007 Subject: [javascript-dev] Re: Video Texture on OpenGL in Javascript In-Reply-To: <1da05.473f0c38@www.cycling74.com> References: <1d9cf.473e6987@www.cycling74.com> <1da05.473f0c38@www.cycling74.com> Message-ID: <1079b050711171115y48110c18w440c9bfe0b2605f@mail.gmail.com> check out the examples folder. That covers alot of things. wes On 11/17/07, Andrew Roth wrote: > > Thanks! That helps a lot! > > :) > > Is there a good guide or resource for learning Javascript in Max? Seems I haven't quite got the hang of it yet. > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev > From cyrilbiz at yahoo.com Wed Nov 21 11:39:15 2007 From: cyrilbiz at yahoo.com (tirilo) Date: Wed Nov 21 11:39:18 2007 Subject: [javascript-dev] newdefault failed on button? Message-ID: <1db5b.47447b53@www.cycling74.com> Hi, Is there a special arguments I should pass to create a button or a message box with newdefault? this.patcher.newdefault( 1000, 200, "uslider" ) does work but this.patcher.newdefault( 1000, 200, "button" ) or this.patcher.newdefault( 1000, 200, "message box" ) does NOT work and return a "newdefault failed" error. I have seen some old post mentioning a bug in newdefault for some objects. Is it still the same bug or am I doing something wrong? Thanks C