25 most Recent Topics - Processing Discourse catselect_help.html - Processing Discourse en-us Processing Discourse Thu, 22 Mar 2012 06:00:34 +0000 http://blogs.law.harvard.edu/tech/rss 30 Electronics,  Serial Library - Error inside Serial.ports() in exported app num_1251731980.html#6 Processing Discourse/Electronics,  Serial Library num_1251731980.html#6 Tue, 22 Nov 2011 08:24:57 +0000 Welcome back to playing this crazy game we love so much <br /><br />You could wait until the new EP Generations comes out and see if challenges will be introduced again since well be getting memories back in that EP. &nbsp;Itll be out May 31, 2011 here in North America so not too long to wait now Electronics,  Serial Library - Test, just a test num_1321114771.html#0 Processing Discourse/Electronics,  Serial Library num_1321114771.html#0 Sat, 12 Nov 2011 08:19:31 +0000 Hello. And Bye. Electronics,  Serial Library - so so easy walker horse shoes fisher cat num_1320642154.html#0 Processing Discourse/Electronics,  Serial Library num_1320642154.html#0 Sun, 06 Nov 2011 21:02:34 +0000 angiotensin i Other Libraries - using cocoa library to run applescript num_1225564736.html#9 Processing Discourse/Other Libraries num_1225564736.html#9 Mon, 05 Jul 2010 08:34:35 +0000 <b><a class="message" href="num_1225564736.html#8">Wind Up Toy wrote</a> on Mar 27<sup>th</sup>, 2010, 2:07pm:</b><br /><div class="quote" style="width: 90%">I also cannot find &quot;com&quot; inside my /System/Library/Java folder...<br /><br />OS X 10.6.2<br /> </div><br /><br />The Java/Cocoa bridge has been removed by Apple in 10.6. :-( AFAIK you can use the files from 10.5 – or switch to http://code.google.com/p/rococoa/ Programs - Using light, shading 3d num_1255494263.html#12 Processing Discourse/Programs num_1255494263.html#12 Wed, 30 Jun 2010 01:31:01 +0000 Hi everyone !<br /><br />I'm pretty near the solution, but I cant make it work:<br /><br />I've got a sketch running with toxiclib's triangleMesh.<br />I've got another one running with surfaceLib.<br /><br />They both work fine, and i can use useVertexNormals() with surfaceLib, but I can't figure out how to connect those two. <br />I understand that it's possible to have a toxiclib's triangleMesh with the nice useVertexNormals from surfaceLib. But how ?! <br />Does anyone have an example ? <br /><br />Thanks for your help Video Capture,  Movie Playback,  Vision Libraries - camara resolution erratic / windows 7x64 num_1274902266.html#2 Processing Discourse/Video Capture,  Movie Playback,  Vision Libraries num_1274902266.html#2 Wed, 23 Jun 2010 19:13:51 +0000 I was having the same issue with video capture being distorted in Windows 7. <br /><br />Just installed winVDIG version 1.01 (not 1.05), it did the trick. You may download here: <a href="http://www.eden.net.nz/7/20071008/" target="_blank">http://www.eden.net.nz/7/20071008/</a> Programs - Program to find the shortest path num_1276835418.html#2 Processing Discourse/Programs num_1276835418.html#2 Fri, 18 Jun 2010 12:50:35 +0000 ox and oy is the x and y cordinates of the object that needs to move to the goal. &nbsp;gx and gy is the x and y position of the goal. &nbsp;thanks for the out of bounds comment. &nbsp;I'll try that. Syntax Questions - why the outer circle does not fade away? num_1276889853.html#0 Processing Discourse/Syntax Questions num_1276889853.html#0 Fri, 18 Jun 2010 12:37:33 +0000 I'm just testing minim library, I want to create cirles that are fading away eventually. I get the main circle work(which radius is 2*radius), and I don't know why the outer ring doesn't work.<br /><br />P.S.: you need to change the add your own mp3 to the data folder.<br /><br /> <b>Code:</b><pre class="code">import processing&#46;video&#46;*;<br &#47;>import ddf&#46;minim&#46;*;<br &#47;>import ddf&#46;minim&#46;signals&#46;*;<br &#47;>import ddf&#46;minim&#46;analysis&#46;*;<br &#47;>import ddf&#46;minim&#46;effects&#46;*;<br &#47;>import ddf&#46;minim&#46;*;<br &#47;><br &#47;><br &#47;>Minim minim;<br &#47;>AudioPlayer song;<br &#47;>&#47;&#47;WaveformRenderer waveform;<br &#47;>FFT fft;<br &#47;>ArrayList trails;<br &#47;>MovieMaker mm;<br &#47;>boolean play = false;<br &#47;><br &#47;>void setup&#40;&#41;<br &#47;>&#123;<br &#47;>  size&#40;1024, 800&#41;;<br &#47;>  background&#40;0&#41;;<br &#47;>  smooth&#40;&#41;;<br &#47;>  &#47;&#47;frameRate&#40;128&#41;;<br &#47;>  &#47;&#47;mm = new MovieMaker&#40;this, width,height,&quot;bubbles&#46;mov&quot;,30,MovieMaker&#46;VI&#068;EO, MovieMaker&#46;LOSSLESS&#41;;<br &#47;>  &#47;&#47; always start Minim first&#33;<br &#47;>  minim = new Minim&#40;this&#41;;<br &#47;><br &#47;>  &#47;&#47; specify 1024 for the length of the sample buffers<br &#47;>  &#47;&#47; the default buffer size is 1024<br &#47;>  song = minim&#46;loadFile&#40;&quot;&#31958;&#19981;&#21388;&#46;mp3&quot;, 1024&#41;;<br &#47;>  play&#40;&#41;;<br &#47;><br &#47;>  &#47;&#47;waveform = new WaveformRenderer&#40;&#41;;<br &#47;>  &#47;&#47;song&#46;addListener&#40;waveform&#41;;<br &#47;><br &#47;>  &#47;&#47; an FFT needs to know how <br &#47;>  &#47;&#47; long the audio buffers it will be analyzing are<br &#47;>  &#47;&#47; and also needs to know <br &#47;>  &#47;&#47; the sample rate of the audio it is analyzing<br &#47;>  fft = new FFT&#40;song&#46;bufferSize&#40;&#41;, song&#46;sampleRate&#40;&#41;&#41;;<br &#47;><br &#47;>  trails = new ArrayList&#40;&#41;;<br &#47;><br &#47;>&#125;<br &#47;><br &#47;>void play&#40;&#41;&#123;<br &#47;>  if&#40;play == true&#41;  song&#46;play&#40;&#41;; <br &#47;>&#125;<br &#47;><br &#47;>void draw&#40;&#41;<br &#47;>&#123;<br &#47;>  <br &#47;>  &#47;&#47;waveform&#46;draw&#40;&#41;;<br &#47;>  &#47;&#47;spectrum<br &#47;>  &#47;&#47; first perform a forward fft on one of song's buffers<br &#47;>  &#47;&#47; I'm using the mix buffer<br &#47;>  &#47;&#47;  but you can use any one you like<br &#47;>  fft&#46;forward&#40;song&#46;mix&#41;;<br &#47;><br &#47;>  &#47;&#47;stroke&#40;255, 0, 0, 128&#41;;<br &#47;>  &#47;&#47;strokeWeight&#40;5&#41;;<br &#47;>  &#47;&#47; draw the spectrum as a series of vertical lines<br &#47;>  &#47;&#47; I multiple the value of getBand by 4 <br &#47;>  &#47;&#47; so that we can see the lines better<br &#47;>  for&#40;int i = 0; i &lt; &#40;fft&#46;specSize&#40;&#41;&#45;1&#41;*2; i+=1024&#47;&#40;fft&#46;specSize&#40;&#41;&#45;1&#41;&#41;<br &#47;>  &#123;<br &#47;>    &#47;&#47;line&#40;i, height, i, height &#45; fft&#46;getBand&#40;i&#41;*5&#41;;<br &#47;><br &#47;>    if&#40;dist&#40;i,height, i, height &#45; fft&#46;getBand&#40;i&#41;*5&#41;&gt;height&#47;20&#41;&#123;<br &#47;> Circle c = new Circle&#40;int&#40;random&#40;0,width&#41;&#41;, int&#40;random&#40;0,height&#41;&#41;, random&#40;10,50&#41;, 255&#41;;<br &#47;> c&#46;drawOneCircle&#40;&#41;; <br &#47;>    &#125;<br &#47;>  &#125;<br &#47;><br &#47;>  &#47;&#47;trails<br &#47;>  for&#40;int j = 0; j &lt; trails&#46;size&#40;&#41;; j++&#41;&#123;<br &#47;>    Trail t = &#40;Trail&#41; trails&#46;get&#40;j&#41;;<br &#47;>    t&#46;update&#40;&#41;;<br &#47;>    t&#46;drawOneCircle&#40;&#41;;<br &#47;>  &#125;<br &#47;><br &#47;><br &#47;>  &#47;&#47;waveform<br &#47;>  stroke&#40;255&#41;;<br &#47;>  strokeWeight&#40;0&#41;;<br &#47;>  &#47;&#47; we draw the waveform by connecting neighbor values with a line<br &#47;>  &#47;&#47; we multiply each of the values by 50 <br &#47;>  &#47;&#47; because the values in the buffers are normalized<br &#47;>  &#47;&#47; this means that they have values between &#45;1 and 1&#46; <br &#47;>  &#47;&#47; If we don't scale them up our waveform <br &#47;>  &#47;&#47; will look more or less like a straight line&#46;<br &#47;>  for&#40;int i = 0; i &lt; song&#46;bufferSize&#40;&#41; &#45; 1; i++&#41;<br &#47;>  &#123;<br &#47;>    &#47;&#47;    line&#40;i, height&#47;2 &#45; 50 + song&#46;left&#46;get&#40;i&#41;*50, i+1, height&#47;2 &#45; 50 + song&#46;left&#46;get&#40;i+1&#41;*50&#41;;<br &#47;>    &#47;&#47;    line&#40;i, height&#47;2 + 50 + song&#46;right&#46;get&#40;i&#41;*50, i+1, height&#47;2 + 50 + song&#46;right&#46;get&#40;i+1&#41;*50&#41;;<br &#47;>    &#47;&#47;    line&#40;i, height&#47;2 + song&#46;mix&#46;get&#40;i&#41;*50, i +1, height&#47;2 + song&#46;mix&#46;get&#40;i+1&#41;*50&#41;;<br &#47;>  &#125;<br &#47;><br &#47;>  &#47;&#47;mm&#46;addFrame&#40;&#41;;<br &#47;><br &#47;><br &#47;>&#125;<br &#47;><br &#47;>void stop&#40;&#41;<br &#47;>&#123;<br &#47;>  song&#46;close&#40;&#41;;<br &#47;>  minim&#46;stop&#40;&#41;;<br &#47;><br &#47;>  super&#46;stop&#40;&#41;;<br &#47;>&#125;<br &#47;><br &#47;>void keyPressed&#40;&#41;&#123;<br &#47;>  if&#40;key == 'f'&#41;&#123;<br &#47;>    mm&#46;finish&#40;&#41;;<br &#47;>    println&#40;&quot;movie saved&quot;&#41;;  <br &#47;>  &#125; <br &#47;><br &#47;>  if &#40; key == 'p' &#41; &#123;<br &#47;>    play = true;<br &#47;>    play&#40;&#41;;<br &#47;>  &#125;<br &#47;>&#125;<br &#47;><br &#47;>class Circle&#123;<br &#47;>  &#47;&#47;variable<br &#47;>  int posx;<br &#47;>  int posy;<br &#47;>  float radius;<br &#47;>  float magnatude;<br &#47;><br &#47;>  &#47;&#47;constructor<br &#47;>  Circle&#40;int _posx, int _posy, float _radius, float _magnatude&#41;&#123;<br &#47;>    posx = _posx;<br &#47;>    posy = _posy;<br &#47;>    radius = _radius;<br &#47;>    magnatude = _magnatude;<br &#47;>  &#125;<br &#47;><br &#47;>  &#47;&#47;method<br &#47;>  void drawOneCircle&#40;&#41;&#123;<br &#47;><br &#47;><span class="highlight">    noStroke&#40;&#41;;<br &#47;>    fill&#40;magnatude,10&#41;;<br &#47;>    ellipse&#40;posx,posy,radius*4,radius*4&#41;;<br &#47;>    &#47;&#47;fill&#40;magnatude,magnatude,magnatude,10&#41;;<br &#47;>    ellipse&#40;posx,posy,radius*3,radius*3&#41;;<br &#47;>    &#47;&#47;fill&#40;magnatude,magnatude,magnatude,10&#41;;<br &#47;>    ellipse&#40;posx,posy,radius*2&#46;5,radius*2&#46;5&#41;;<br &#47;><br &#47;>    &#47;&#47;stroke&#40;0,60&#41;;<br &#47;>    fill&#40;magnatude&#41;;<br &#47;>    ellipse&#40;posx,posy,radius*2,radius*2&#41;;</span><br &#47;><br &#47;>    &#47;&#47;color<br &#47;>    &#47;&#47;noStroke&#40;&#41;;<br &#47;>&#47;&#47;    for&#40;int k = 1; k &lt; 30; k++&#41;&#123;<br &#47;>&#47;&#47; fill&#40;random&#40;0,magnatude&#41;,random&#40;0,magnatude&#41;,random&#40;0,magnatude&#41;,20&#41;;<br &#47;>&#47;&#47; arc&#40;posx, posy, radius*2, radius*2, random&#40;0,2*PI&#41;, random&#40;0,2*PI&#41;&#41;;<br &#47;>&#47;&#47;    &#125;<br &#47;><br &#47;><br &#47;>&#47;&#47;    for&#40;float i = 0&#46;0; i &lt; 2&#46;0*PI; i+=0&#46;5&#45;radius&#47;200&#41;&#123;<br &#47;>&#47;&#47; stroke&#40;0,random&#40;0,100&#41;&#41;;<br &#47;>&#47;&#47; line&#40;posx,posy,posx+sin&#40;i&#41;*radius,posy+cos&#40;i&#41;*radius&#41;;<br &#47;>&#47;&#47;    &#125;<br &#47;><br &#47;>    trails&#46;add&#40;new Trail&#40;posx, posy, radius, magnatude&#41;&#41;;<br &#47;><br &#47;>  &#125;<br &#47;><br &#47;><br &#47;>&#125;<br &#47;><br &#47;>class Trail&#123;<br &#47;>  &#47;&#47;variable<br &#47;>  int posx;<br &#47;>  int posy;<br &#47;>  float radius;<br &#47;>  float magnatude;<br &#47;><br &#47;>  &#47;&#47;constructor<br &#47;>  Trail&#40;int _posx, int _posy, float _radius, float _magnatude&#41;&#123;<br &#47;>    posx = _posx;<br &#47;>    posy = _posy;<br &#47;>    radius = _radius;<br &#47;>    magnatude = _magnatude; <br &#47;>  &#125;<br &#47;><br &#47;>  &#47;&#47;method<br &#47;>  void update&#40;&#41;&#123;<br &#47;>  <span class="highlight">  magnatude&#45;=30;</span><br &#47;><br &#47;>    if&#40;magnatude &lt; 0&#41;&#123;<br &#47;> trails&#46;remove&#40;this&#41;; <br &#47;> &#47;&#47;println&#40;&quot;circle remove&quot;&#41;;<br &#47;>    &#125;<br &#47;>  &#125;<br &#47;><br &#47;>  void drawOneCircle&#40;&#41;&#123;<br &#47;><span class="highlight"><br &#47;>    noStroke&#40;&#41;;<br &#47;>    fill&#40;magnatude,10&#41;;<br &#47;>    ellipse&#40;posx,posy,radius*4,radius*4&#41;;<br &#47;>    &#47;&#47;fill&#40;magnatude,magnatude,magnatude,10&#41;;<br &#47;>    ellipse&#40;posx,posy,radius*3,radius*3&#41;;<br &#47;>    &#47;&#47;fill&#40;magnatude,magnatude,magnatude,10&#41;;<br &#47;>    ellipse&#40;posx,posy,radius*2&#46;5,radius*2&#46;5&#41;;<br &#47;><br &#47;>    &#47;&#47;stroke&#40;0,60&#41;;<br &#47;>    fill&#40;magnatude&#41;;<br &#47;>    ellipse&#40;posx,posy,radius*2,radius*2&#41;;</span><br &#47;><br &#47;>    &#47;&#47;color<br &#47;>&#47;&#47;    noStroke&#40;&#41;;<br &#47;>&#47;&#47;    for&#40;int k = 1; k &lt; 30; k++&#41;&#123;<br &#47;>&#47;&#47; fill&#40;random&#40;0,magnatude&#41;,random&#40;0,magnatude&#41;,random&#40;0,magnatude&#41;,20&#41;;<br &#47;>&#47;&#47; arc&#40;posx, posy, radius*2, radius*2, random&#40;0,2*PI&#41;, random&#40;0,2*PI&#41;&#41;;<br &#47;>&#47;&#47;    &#125;<br &#47;><br &#47;><br &#47;>&#47;&#47;    for&#40;float i = 0&#46;0; i &lt; 2&#46;0*PI; i+=0&#46;5&#45;radius&#47;200&#41;&#123;<br &#47;>&#47;&#47; stroke&#40;0,random&#40;0,100&#41;&#41;;<br &#47;>&#47;&#47; line&#40;posx,posy,posx+sin&#40;i&#41;*radius,posy+cos&#40;i&#41;*radius&#41;;<br &#47;>&#47;&#47;    &#125;<br &#47;><br &#47;>  &#125;<br &#47;><br &#47;><br &#47;>&#125;<br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;><br &#47;> </pre> Syntax Questions - loadStrings num_1276884781.html#2 Processing Discourse/Syntax Questions num_1276884781.html#2 Fri, 18 Jun 2010 12:13:18 +0000 That gives me the same error, if i try:<br /><br /> <b>Code:</b><pre class="code">int numPics = 292; &#47;&#47; change with number of points, numPics = # pictures<br &#47;>int numPts = 866; &#47;&#47; number of points in spectra<br &#47;>PImage&#91;&#93; pics = new PImage&#91;numPics&#93;;<br &#47;>String&#91;&#93;&#91;&#93; spec;<br &#47;><br &#47;>void setup&#40;&#41; &#123;<br &#47;>  size&#40;1000,950&#41;;<br &#47;>  smooth&#40;&#41;;<br &#47;>  for &#40;int k = 0; k &lt; numPics; k++&#41; &#123;<br &#47;>    for &#40;int h = 0; h &lt; numPts; h++&#41; &#123;<br &#47;>    String imageName =  &quot;S5_stamp_&quot; + nf&#40;k, 5&#41; + &quot;&#46;png&quot;;<br &#47;>    pics&#91;k&#93; = loadImage&#40;imageName&#41;;<br &#47;>    String spectra = &quot;S5_hi_spectra_&quot; + nf&#40;k, 5&#41; + &quot;&#46;txt&quot;;<br &#47;>    spec&#91;k&#93;&#91;h&#93; = loadStrings&#40;spectra&#41;;  <br &#47;>  &#125;<br &#47;>  &#125; </pre><br /><br />If I just try:<br /><br /> <b>Code:</b><pre class="code">int numPics = 292; &#47;&#47; change with number of points, numPics = # pictures<br &#47;>int numPts = 866; &#47;&#47; number of points in spectra<br &#47;>PImage&#91;&#93; pics = new PImage&#91;numPics&#93;;<br &#47;>String&#91;&#93;&#91;&#93; spec;<br &#47;><br &#47;>void setup&#40;&#41; &#123;<br &#47;>  size&#40;1000,950&#41;;<br &#47;>  smooth&#40;&#41;;<br &#47;>  for &#40;int k = 0; k &lt; numPics; k++&#41; &#123;<br &#47;>    for &#40;int h = 0; h &lt; numPts; h++&#41; &#123;<br &#47;>    String imageName =  &quot;S5_stamp_&quot; + nf&#40;k, 5&#41; + &quot;&#46;png&quot;;<br &#47;>    pics&#91;k&#93; = loadImage&#40;imageName&#41;;<br &#47;>    String spectra = &quot;S5_hi_spectra_&quot; + nf&#40;k, 5&#41; + &quot;&#46;txt&quot;;<br &#47;>    spec = loadStrings&#40;spectra&#41;;  <br &#47;>  &#125;<br &#47;>  &#125; </pre><br /><br />I get &quot;cannot convert from String[] to String[][]&quot;. It does actually work if I make spec just a String[] and don't specify spec[k], but that isn't what I want it to do. I want each spec[k] to be one filename so that I can then split the data from each file into the form I need for my graph. Syntax Questions - open console in draw window. Is possible? num_1276884627.html#1 Processing Discourse/Syntax Questions num_1276884627.html#1 Fri, 18 Jun 2010 12:00:18 +0000 Looks like it -- I haven't done it but check out <a href="http://java.sun.com/javase/6/docs/api/java/io/Console.html" target="_blank">http://java.sun.com/javase/6/docs/api/java/io/Console.html</a> Programs - Point to line distance num_1276644884.html#4 Processing Discourse/Programs num_1276644884.html#4 Fri, 18 Jun 2010 10:43:28 +0000 hey smitty! <br /><br />thanks again for suggestions, i removed mY completely. <br /><br />as for your other suggestion about pre-calculating distance+cos/sin: this definitely makes sense if one always checks against a static set of lines, but also means more work before the function call can happen. <br />i think the current version is a good trade-off between ease of use and speed. <br /><br />so for completeness: here's a version that is totally crazy fast as long as your lines rarely change. <br />i put the whole thing into a class cause i'm not a big fan of having many variables flying around. <br /><br /> <b>Code:</b><pre class="code"><br &#47;>&#47;&#47; press space to reset<br &#47;>&#47;&#47; click for randomness<br &#47;>&#47;&#47; drag to move<br &#47;><br &#47;>Line myLine; <br &#47;><br &#47;>void setup&#40;&#41;&#123;<br &#47;>  size&#40; 600, 600 &#41;; <br &#47;>  smooth&#40;&#41;; <br &#47;>  textFont&#40; loadFont&#40; &quot;SansSerif&#45;12&#46;vlw&quot; &#41; &#41;; <br &#47;>  <br &#47;>  myLine = new Line&#40; width&#47;2 &#45; 100, height&#47;2, width&#47;2 + 100, height&#47;2 &#41;; <br &#47;>&#125;<br &#47;><br &#47;><br &#47;>void draw&#40;&#41;&#123;<br &#47;>  background&#40; 0 &#41;; <br &#47;>  <br &#47;>  stroke&#40; 255 &#41;; <br &#47;>  myLine&#46;draw&#40;&#41;; <br &#47;><br &#47;>  fill&#40; 255, 255, 0 &#41;; <br &#47;>  noStroke&#40;&#41;; <br &#47;>  ellipse&#40; mouseX, mouseY, 10, 10 &#41;; <br &#47;>  <br &#47;>  PVector result = myLine&#46;get&#068;istance&#40; mouseX, mouseY &#41;; <br &#47;>  stroke&#40; 150 &#41;; <br &#47;>  line&#40; mouseX, mouseY, result&#46;x, result&#46;y &#41;; <br &#47;>  <br &#47;>  fill&#40; 255 &#41;; <br &#47;>  text&#40; &quot;The distance to the line is&#58; &quot; + result&#46;z, 10, 10 &#41;; <br &#47;>&#125;<br &#47;><br &#47;><br &#47;>void mousePressed&#40;&#41;&#123;<br &#47;>  myLine&#46;x1 = 100+random&#40;width&#45;200&#41;; <br &#47;>  myLine&#46;y1 = 100+random&#40;height&#45;200&#41;; <br &#47;>  myLine&#46;update&#40;&#41;; <br &#47;>&#125;<br &#47;><br &#47;>void mouse&#068;ragged&#40;&#41;&#123;<br &#47;>  myLine&#46;x1 = mouseX; <br &#47;>  myLine&#46;y1 = mouseY; <br &#47;>  myLine&#46;update&#40;&#41;; <br &#47;>&#125;<br &#47;><br &#47;>void keyPressed&#40;&#41;&#123;<br &#47;>  myLine&#46;x1 = width&#47;2&#45;100; <br &#47;>  myLine&#46;y1 = height&#47;2; <br &#47;>  myLine&#46;update&#40;&#41;; <br &#47;>&#125;<br &#47;><br &#47;>&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;<br &#47;><br &#47;>class Line&#123;<br &#47;>  &#47;&#47; where does the line start&#47;end&#63; <br &#47;>  public float x1, x2, y1, y2; <br &#47;>  <br &#47;>  &#47;&#47; some happy math variables<br &#47;>  private float dx, dy, d, ca, sa, mx, dx2, dy2; <br &#47;>  <br &#47;>  &#47;&#47; we use this to store the result, <br &#47;>  &#47;&#47; so if you want to store the result and calculate again <br &#47;>  &#47;&#47; you should do <br &#47;>  &#47;&#47; PVector mine = new PVector&#40;&#41;; <br &#47;>  &#47;&#47; mine&#46;set&#40; line&#46;get&#068;istance&#40; mouseX, mouseY &#41; &#41;; <br &#47;>  private PVector result; <br &#47;>  <br &#47;>  public Line&#40; float x1, float y1, float x2, float y2 &#41;&#123;<br &#47;>    this&#46;x1 = x1; <br &#47;>    this&#46;y1 = y1; <br &#47;>    this&#46;x2 = x2; <br &#47;>    this&#46;y2 = y2; <br &#47;>    result = new PVector&#40;&#41;; <br &#47;>    update&#40;&#41;; <br &#47;>  &#125;<br &#47;>  <br &#47;>  &#47;**<br &#47;>   * Call this after changing the coordinates&#33;&#33;&#33; <br &#47;>   *&#47;<br &#47;>  public void update&#40;&#41;&#123;<br &#47;>    dx = x2 &#45; x1; <br &#47;>    dy = y2 &#45; y1; <br &#47;>    d = sqrt&#40; dx*dx + dy*dy &#41;; <br &#47;>    ca = dx&#47;d; &#47;&#47; cosine<br &#47;>    sa = dy&#47;d; &#47;&#47; sine <br &#47;>  &#125;<br &#47;>  <br &#47;>  &#47;**<br &#47;>   * Returns a point on this line<br &#47;>   * that is closest to the point &#40;x,y&#41;<br &#47;>   * <br &#47;>   * The result is a PVector&#46; <br &#47;>   * result&#46;x and result&#46;y are points on the line&#46; <br &#47;>   * The result&#46;z variable contains the distance from &#40;x,y&#41; to the line, just in case you need it &#58;&#41; <br &#47;>   *&#47;<br &#47;>  PVector get&#068;istance&#40; float x, float y &#41;&#123;<br &#47;>    mx = &#40;&#45;x1+x&#41;*ca + &#40;&#45;y1+y&#41;*sa;<br &#47;>    <br &#47;>    if&#40; mx &lt;= 0 &#41;&#123;<br &#47;>      result&#46;x = x1; <br &#47;>      result&#46;y = y1; <br &#47;>    &#125;<br &#47;>    else if&#40; mx &gt;= d &#41;&#123;<br &#47;>      result&#46;x = x2; <br &#47;>      result&#46;y = y2; <br &#47;>    &#125;<br &#47;>    else&#123;<br &#47;>      result&#46;x = x1 + mx*ca; <br &#47;>      result&#46;y = y1 + mx*sa; <br &#47;>    &#125;<br &#47;>    <br &#47;>    dx2 = x &#45; result&#46;x; <br &#47;>    dy2 = y &#45; result&#46;y; <br &#47;>    result&#46;z = sqrt&#40; dx2*dx2 + dy2*dy2 &#41;; <br &#47;>    <br &#47;>    return result;   <br &#47;>  &#125;<br &#47;>  <br &#47;>  &#47;**<br &#47;>   * &#068;raw it&#33; <br &#47;>   *&#47;<br &#47;>  public void draw&#40;&#41;&#123;<br &#47;>    line&#40; x1, y1, x2, y2 &#41;; <br &#47;>  &#125;<br &#47;>&#125;<br &#47;> </pre><br /><br /><br />obviously there are many more optimizations one could go for, e.g. in my own project i don't even need the result.x/result.y variables so i threw them out alltogether and only return the distance. Syntax Questions - moving ellipses using array of coordinates num_1276614899.html#5 Processing Discourse/Syntax Questions num_1276614899.html#5 Fri, 18 Jun 2010 10:04:46 +0000 I have corrected my sketch in this way: &nbsp;<br /> <b>Code:</b><pre class="code">PImage mapImage;<br &#47;>Table locationTable;<br &#47;>Table destinationTable;<br &#47;>float size =&#46;7;<br &#47;>float x;<br &#47;>float y;<br &#47;>float targetX;<br &#47;>float targetY;<br &#47;>float easing;<br &#47;>int rowCount;<br &#47;>int start;<br &#47;><br &#47;>PVector&#91;&#93; location = new PVector&#91;110&#93;;<br &#47;>PVector&#91;&#93; destination = new PVector&#91;110&#93;;<br &#47;>PVector&#91;&#93; velocity = new PVector &#91;110&#93;;<br &#47;><br &#47;><br &#47;>void setup&#40;&#41;&#123;<br &#47;>  background &#40;0, 0, 0&#41;;<br &#47;>  size&#40;450,551&#41;;<br &#47;>  ellipseMode&#40;CENTER&#41;;<br &#47;>  colorMode&#40;RGB,255,255,255,255&#41;;<br &#47;>  noStroke&#40;&#41;;<br &#47;>  smooth&#40;&#41;;<br &#47;>  noise&#068;etail&#40;14&#41;;<br &#47;><br &#47;>  mapImage = loadImage&#40;&quot;pianta&#45;italia&#45;regione&#46;png&quot;&#41;;<br &#47;><br &#47;>  easing = 0&#46;008;<br &#47;>  frameRate &#40;10&#41;;<br &#47;>  start = millis&#40;&#41;;<br &#47;><br &#47;>  locationTable = new Table&#40;&quot;locations&#46;tsv&quot;&#41;;<br &#47;>  destinationTable = new Table&#40;&quot;destinations&#46;tsv&quot;&#41;;<br &#47;>  rowCount = locationTable&#46;getRowCount&#40;&#41;;<br &#47;><br &#47;>  for &#40;int row = 0; row &lt; 110; row++&#41; &#123;<br &#47;><br &#47;>    x = locationTable&#46;getFloat&#40;row, 1&#41;; <br &#47;>    y = locationTable&#46;getFloat&#40;row, 2&#41;;<br &#47;><br &#47;>    targetX = destinationTable&#46;getFloat&#40;row, 1&#41;; <br &#47;>    targetY = destinationTable&#46;getFloat&#40;row, 2&#41;;<br &#47;>    location&#91;row&#93; = new PVector &#40;x, y&#41;;<br &#47;>    <br &#47;>    <br &#47;>  &#125;<br &#47;><br &#47;>&#125;<br &#47;><br &#47;>void draw&#40;&#41;&#123;<br &#47;><br &#47;>  tint&#40;100,100,100, 6&#41;; <br &#47;>  image&#40;mapImage, 0, 0&#41;;<br &#47;><br &#47;>  &#47;&#47;fill&#40;0,0,0,2&#41;;<br &#47;>  &#47;&#47;rect&#40;&#45;5,&#45;5,width+5,height+5&#41;;<br &#47;><br &#47;>  for &#40;int row = 0; row &lt; 110; row++&#41; &#123;<br &#47;>    <br &#47;>    destination&#91;row&#93; = new PVector &#40;targetX, targetY&#41;;<br &#47;><br &#47;>    velocity&#91;row&#93; = new PVector &#40;&#40;destination&#91;row&#93;&#46;x &#45; location&#91;row&#93;&#46;x&#41;*easing , &#40;&#40;destination&#91;row&#93;&#46;x &#45; location&#91;row&#93;&#46;y&#41;+30&#41;*easing &#41;;<br &#47;>    location&#91;row&#93;&#46;add&#40;velocity&#91;row&#93;&#41;;<br &#47;><br &#47;>    for&#40;int i=0; i&lt;50; i++&#41;&#123;<br &#47;> fill&#40;255,255,250,122&#47;&#40;i+1&#41;&#41;;<br &#47;> ellipse&#40;location&#91;row&#93;&#46;x,location&#91;row&#93;&#46;y,size&#47;8*i,size&#47;8*i&#41;;<br &#47;>    &#125;<br &#47;>  &#125;<br &#47;><br &#47;><br &#47;>  if&#40;&#40;millis&#40;&#41;&#45;start&#41; &gt;= 4000&#41;&#123;<br &#47;>    for &#40;int row = 0; row &lt; 110; row++&#41; &#123;<br &#47;> <br &#47;> destination&#91;row&#93; = new PVector &#40;targetX, targetY&#41;;<br &#47;><br &#47;> velocity&#91;row&#93; = new PVector &#40;&#40;destination&#91;row&#93;&#46;x &#45; location&#91;row&#93;&#46;x&#41;*easing , &#40;&#40;destination&#91;row&#93;&#46;x &#45; location&#91;row&#93;&#46;y&#41;+30&#41;*easing &#41;;<br &#47;> location&#91;row&#93;&#46;add&#40;velocity&#91;row&#93;&#41;;<br &#47;><br &#47;> for&#40;int i=0; i&lt;50; i++&#41;&#123;<br &#47;>  fill&#40;255,255,250,122&#47;&#40;i+1&#41;&#41;;<br &#47;>  ellipse&#40;location&#91;row&#93;&#46;x,location&#91;row&#93;&#46;y,size&#47;8*i,size&#47;8*i&#41;;<br &#47;> &#125;<br &#47;>    &#125;<br &#47;>  &#125;<br &#47;>&#125; </pre><br /><br />but now I can't delay with millis() the second block of ellipse, why? Video Capture,  Movie Playback,  Vision Libraries - Install OpenCV library num_1276875144.html#0 Processing Discourse/Video Capture,  Movie Playback,  Vision Libraries num_1276875144.html#0 hugo.assanti@gmail.com (HugoA) Fri, 18 Jun 2010 08:32:24 +0000 I'm trying to install openCV library. I Download the framework and the OpenCV Processing Library. Place the folder into Documents/Processing/libraries.<br /><br />When i run this code<br /> <b>Code:</b><pre class="code"><br &#47;>import hypermedia&#46;video&#46;*;        &#47;&#47;  Imports the OpenCV library<br &#47;>OpenCV opencv;                    &#47;&#47;  Creates a new OpenCV Object<br &#47;><br &#47;>void setup&#40;&#41;<br &#47;>&#123;<br &#47;><br &#47;>  size&#40; 320, 240 &#41;;<br &#47;><br &#47;>  opencv = new OpenCV&#40; this &#41;;    &#47;&#47;  Initialises the OpenCV object<br &#47;>  opencv&#46;capture&#40; 320, 240 &#41;;     &#47;&#47;  Opens a video capture stream<br &#47;><br &#47;>&#125;<br &#47;><br &#47;>void draw&#40;&#41;<br &#47;>&#123;<br &#47;><br &#47;>  opencv&#46;read&#40;&#41;;                  &#47;&#47;  Grabs a frame from the camera<br &#47;>  image&#40; opencv&#46;image&#40;&#41;, 0, 0 &#41;;  &#47;&#47;  &#068;isplays the image in the OpenCV buffer to the screen<br &#47;><br &#47;>&#125;<br &#47;> </pre><br /><br />I get this error<br />The package &quot;hypermedia&quot; does not exist. You might be missing a library<br />Note that release 1.0, libraries must be installed in a folder named 'libraries' inside the 'sketchbook' folder.<br /><br />I'm using a Mac.<br /><br />How can i solve this?<br />Thanks Syntax Questions - removing elements of an arrayList num_1275642093.html#11 Processing Discourse/Syntax Questions num_1275642093.html#11 Fri, 18 Jun 2010 07:21:30 +0000 i'm still stuck on this <img src="yabbfiles/Templates/Forum/processing_one/shocked.gif" border="0" alt="Shocked" title="Shocked" /><br /><br />i think, as blindfish says , i am &quot;setting a reference to the original array rather than creating a true copy&quot;.<br /><br /><u>my code</u>:<br />ObjectA [] objecta= new ObjectA[objecta];<br />void setup() &#123;<br />//data is loaded from an xml file<br /><br />objecta[i] = new ObjectA(id, color(H, S, B), area, new PVector(position.x, position.y));     //defines ObjectA<br /> //add associates to arrayList of ObjectA and ObjectB<br />    objecta[i].associates.add(asso1);<br />    objecta[i].objectb.associates.add(asso1); <br />    objecta[i].associates.add(asso2);<br />    objecta[i].objectb.associates.add(asso2);<br />&#125;<br />////////////////////////////////////////////////////////////////////<br />class ObjectA&#123;<br />  ObjectB objectb;<br />  ArrayList objectCs;<br />  PVector origin; <br />  ArrayList associates = new ArrayList();<br />  int objectcCount = population;<br /><br />  ObjectA(int id, int colour, int Size, PVector loc) &#123;<br />    objectb= new ObjectB (id, colour, Size, loc);                 <br />    //ObjectC<br />    objectCs = new ArrayList();<br />    origin = loc.get();<br />    for (int i = 0; i &lt; population; i++) &#123;<br />      objectCs.add(new objectC(id, Size, origin, false, i, associates));<br /><span style="color: #ff0000;">//i think this is were i go wrong passing the associates to objectCs </span>      <br />    &#125;<br />  &#125;<br />////////////////////////////////////////////////////////////////////<br />class ObjectB &#123;<br />  int id;<br />  color colour;<br />  int Size;<br />  int x;<br />  int y;<br />  PVector position;<br />  ArrayList associates = new ArrayList();<br /><br />  ObjectB(int identity, int c, int area, PVector loc) &#123;   <br />    id = identity;<br />    colour = c;<br />    Size = area;<br />    position = loc.get();<br />    &#125;<br />////////////////////////////////////////////////////////////////////<br />class objectC&#123;<br />  ArrayList associates = new ArrayList();<br /><br />objectC(int identity, int Size, PVector loc, boolean mode, int whom, ArrayList asso) &#123;<br />  associates = asso;<br />  &#125;<br /><br />ObjectA is composed of ObjectB and ObjectC. ObjectCs is an arrayList.<br />how can i copy the arrayList associates of either ObjectA or ObjectB to each ObjectC? <br /><br />Thanks Syntax Questions - layering art with transparency never gets opaque num_1276848262.html#2 Processing Discourse/Syntax Questions num_1276848262.html#2 Fri, 18 Jun 2010 07:07:54 +0000 yes to what smitty said. &nbsp;alpha-blending just doesn't work that way, it *never* fully accumulates, because it's always adding a &quot;portion of the difference&quot;, and as the difference gets smaller, so does the portion. &nbsp;a process of diminishing gains, sooner or later you hit a wall (exactly *where* that wall is depends on your alpha value, but it's still there, somewhere)<br /><br />google for &quot;zeno's second paradox&quot;, it's an apt analogy.<br /><br />smitty's stuck-at value of 230 is right for your case too. &nbsp;why? &nbsp;let's say you have a current pixel value of 230 in your image, trying to blend it towards 255 (white) at alpha 10 (3.9%). &nbsp;the difference is 25, and what is 3.9% of 25? &nbsp;0.975, less than one, so after addition it will truncate back to 230. &nbsp;so you could do that a bazillion times and you'd never reach 255, you're stuck. &nbsp;(in practice you'll possibly hit the limit a bit earlier than 230, due to other similar problems with integer math in the alpha blending code)<br /><br />hth Programs - Need help with Project Euler question. num_1276829883.html#4 Processing Discourse/Programs num_1276829883.html#4 Fri, 18 Jun 2010 06:51:01 +0000 Two things:<br />1) why are you solving math problems and learning the basics of programming in processing I mean, sure there's nothing wrong with it, it just seems a bit odd if you ask me :p<br /><br />2) You should <u>really</u> do some reading on the Modulo operator (%) <a href="http://en.wikipedia.org/wiki/Modulo_operation" target="_blank">http://en.wikipedia.org/wiki/Modulo_operation</a> <br /><a href="http://processing.org/reference/modulo.html" target="_blank">http://processing.org/reference/modulo.html</a>. <br />Your entire program can be written in 9 lines of code while at the same time giving the right answer <img src="yabbfiles/Templates/Forum/processing_one/smiley.gif" border="0" alt="Smiley" title="Smiley" /><br /><br />on a side note though: &quot;multiples of 3 or 5&quot; is that a normal &quot;or&quot; or a &quot;exclusive or&quot; (xor) Syntax Questions - Having a hard time coding a parabola num_1276797573.html#4 Processing Discourse/Syntax Questions num_1276797573.html#4 Fri, 18 Jun 2010 06:43:34 +0000 Glad to help! &nbsp;You can probably skip the calc refresher if all you're interested in is ballistic objects, but it might be handy for other things.<br /><br />Also, one minor thing: if you want your numbers for the second method to be &quot;exact&quot;, you'll want to do this:<br /><br /> <b>Code:</b><pre class="code">  &#47;&#47; double assignment creates y acceleration<br &#47;>  y += ySpeed + 0&#46;5*accel;<br &#47;>  ySpeed += accel;<br &#47;><br &#47;>  &#47;&#47; instead of&#58;<br &#47;>  &#47;&#47; ySpeed += accel;<br &#47;>  &#47;&#47; y += ySpeed;   </pre><br /><br />This will correctly calculate the position for a uniform constant acceleration, whereas the other method (commented out) treats it as a series of acceleration &quot;bursts&quot;, one at each frame of the simulation.<br /><br />In most cases the difference won't be noticeable to the naked eye, but for large accelerations it can make a difference. &nbsp;It's also nice if you need the numbers to come out exactly right.<br /> Syntax Questions - OOP num_1276785147.html#3 Processing Discourse/Syntax Questions num_1276785147.html#3 Fri, 18 Jun 2010 05:57:11 +0000 Well I guess this basically all boils down to how you construct your code, and the techniques you use will depend on the context.<br /><br />TBH we already use the 'composition' technique the moment we start adding properties to a class.  More often than not these properties are built-in objects, but it doesn't take much to also start using custom objects; and that's where polymorphism can be really useful as it ensures that your custom object conforms to a required standard.<br /><br />Obviously if working alone it's possible to manually ensure that your new objects conform, but it doesn't take much effort to write a base Interface (or abstract class), which means that if you come back to the project 6 months later you don't have to spend ages figuring out how to make your object fit the container: you just implement the Interface and you know it will work.  This is also especially useful when working on collaborative projects.  Colleagues just implement an interface, write any required methods and it should just work... Programs - JPG Image Deterioration Sketch num_1276788023.html#5 Processing Discourse/Programs num_1276788023.html#5 Fri, 18 Jun 2010 02:30:12 +0000 Enlightening, thanks for the replies!<br /><br />Looks like what I wanted to do may not work the way I intended - essentially I wanted to reduce an image down to highly visible artifacts and &quot;glitches&quot; by reproducing it many times over. Hmmm... Syntax Questions - get all pixels in a certain area (slice) num_1276536212.html#2 Processing Discourse/Syntax Questions num_1276536212.html#2 Fri, 18 Jun 2010 02:11:20 +0000 thank you very much quark, this works very nice!<br /><br />i used your code and added a part that builds a minimum size rectangle over the circle slice, and i only check the pixels within that rectangle, to save some resources by not checking every pixel on the screen each frame.<br /><br /> Syntax Questions - Forcing screen updates num_1276757786.html#3 Processing Discourse/Syntax Questions num_1276757786.html#3 Fri, 18 Jun 2010 01:19:50 +0000 As PhiLho says, this is a FAQ, which might have prompted you to search the forum...<br /><br />Entering into a loop within draw will cause the same problems as using delay(): all you'll see drawn to the screen is the result of the last iteration of the loop.<br /><br />The answer is to use conditions within draw to determine what state something is in and change the result of these conditions using the value of millis() compared to a stored start time + some arbitrary threshold... Electronics,  Serial Library - 'The package "cc" does not exist' (Ubuntu) num_1259105373.html#5 Processing Discourse/Electronics,  Serial Library num_1259105373.html#5 Thu, 17 Jun 2010 15:35:40 +0000 The Arduino website page that discusses 'Arduino and Processing(and Firmata') has two links, one older than the next.<br /> <br />Processing Library: processing-arduino-0017.zip (Updated 22 Sept. 2009) <br /><br /><br />Processing library for arduinoMega: processing-arduinomega.zip (Updated 12 Apr. 2010) <br /><br />I think the contents of the second(newer) Zip file is incomplete; there should be a file called Arduio.jar in the &lt;library&gt; folder.<br /><br />So i installed the contents of the older one and I no longer get the message &nbsp;&quot;The package &quot;cc.arduino does not exist&quot;<br /><br />Dree Programs - help with converting 2d image to 3d shape num_1276630718_15.html#18 Processing Discourse/Programs num_1276630718_15.html#18 Thu, 17 Jun 2010 13:16:40 +0000 OK Toxi, <br />Now that I know something about your libraries, I'm inspired. I also have questions.<br />If I understand correctly, you're creating a series of blobs in 3D space and then skinning them to create the final watertight model...correct?<br /><br />Can I import a model and skin it the same way?<br /> In your sketch this line:<br />mesh.saveAsSTL(sketchPath(&quot;test.stl&quot;), true);<br />saves the STL file from the sketch, is it possible to save the STL from an applet back to the server?  How?<br /> Video Capture,  Movie Playback,  Vision Libraries - combining live & recorded video in processing? num_1274159369.html#2 Processing Discourse/Video Capture,  Movie Playback,  Vision Libraries num_1274159369.html#2 Thu, 17 Jun 2010 12:22:11 +0000 Hi, I am new to Processing. But there is another program called &quot;isadora&quot; could easily combining live and recorded video together. Video Capture,  Movie Playback,  Vision Libraries - AR markers + OS X? num_1268760168.html#3 Processing Discourse/Video Capture,  Movie Playback,  Vision Libraries num_1268760168.html#3 Thu, 17 Jun 2010 12:10:01 +0000 Two things:<br /><br />1. For whatever it's worth, I just downloaded the library and got the examples running and it seems like small changes in marker angle and distance interfere with tracking. For example, rotating the marker 5-10 degrees seems to make the difference between detected and not, even when the marker is, for the most part, facing the camera and within a reasonable distance.<br /><br />Does anyone else have that problem?<br /><br />2. I had to follow these directions in order to get the toolkit to work:<br /> (http://www.engadgeted.net/2009/09/28/nyartoolkit-for-processing-on-mac-os-x-troubleshooting/):<br /><br /> <b>Code:</b><pre class="code">If you’ve been trying to use the NyARToolkit for Processing library on Mac OS X, you might’ve noticed that running the example sketch results in an unresponsive, empty gray window&#46; So here’s what you need to do to fix this – add the following lines in the setup&#40;&#41; function before any other code&#58;<br &#47;>try &#123;<br &#47;>    quicktime&#46;QTSession&#46;open&#40;&#41;;<br &#47;>&#125; catch &#40;quicktime&#46;QTException qte&#41; &#123;<br &#47;>    qte&#46;printStackTrace&#40;&#41;;<br &#47;>&#125;<br &#47;>I spent something like 8 hours trying to find a solution for this problem, until i found this workaround in this bugtracker thread&#46; Hopefully this can save you some time&#46; Tested and worked on Mac OS X 10&#46;5&#46;8, Processing 1&#46;0&#46;7 and nyar4psg&#45;0&#46;2&#46;2&#46; </pre><br /><br />