Syntax Questions - Processing Discourse board_Syntax.html Syntax Questions - Processing Discourse en-us Processing Discourse Thu, 22 Mar 2012 06:30:56 +0000 http://blogs.law.harvard.edu/tech/rss 30 why the outer circle does not fade away? num_1276889853.html Processing Discourse/Syntax Questions num_1276889853.html 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> loadStrings num_1276884781.html Processing Discourse/Syntax Questions num_1276884781.html 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. open console in draw window. Is possible? num_1276884627.html Processing Discourse/Syntax Questions num_1276884627.html 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> moving ellipses using array of coordinates num_1276614899.html Processing Discourse/Syntax Questions num_1276614899.html 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? removing elements of an arrayList num_1275642093.html Processing Discourse/Syntax Questions num_1275642093.html 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 layering art with transparency never gets opaque num_1276848262.html Processing Discourse/Syntax Questions num_1276848262.html 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 Having a hard time coding a parabola num_1276797573.html Processing Discourse/Syntax Questions num_1276797573.html 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 /> OOP num_1276785147.html Processing Discourse/Syntax Questions num_1276785147.html 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... get all pixels in a certain area (slice) num_1276536212.html Processing Discourse/Syntax Questions num_1276536212.html 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 /> Forcing screen updates num_1276757786.html Processing Discourse/Syntax Questions num_1276757786.html 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... Showing HashMap result in a String num_1276703472.html Processing Discourse/Syntax Questions num_1276703472.html eau-lit@hotmail.com (Eau-Lit) Thu, 17 Jun 2010 06:32:20 +0000 Ok so there is a list of words that fry and REAS choosed to be the most common used that are colored. When I started learning Processing my teacher used those keywords that wern't colored and I was always mystified!<br /><br />Thanks for your time PhiLho and again, thanks guyy for those precious tips! static class variables num_1263237645.html Processing Discourse/Syntax Questions num_1263237645.html Thu, 17 Jun 2010 05:20:46 +0000 Interesting trick, Tiago, but the more classical way is to make instead an interface...<br />The interest is that you can &quot;implement&quot; several interfaces (so &quot;import&quot; several sets of constants) while you can extend only one class (thus your trick prevents you from doing real inheritance), and it is more logical in OOP terms.<br />But even that is deprecated, in newer version of Java, in favor of <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html" target="_blank">Static Import</a> (the page explains why it is better).<br />Note that you might need latest version of Processing (&gt; 1.1) to use this syntax. Cleaning a PGraphics Object num_1276647056.html Processing Discourse/Syntax Questions num_1276647056.html Wed, 16 Jun 2010 18:20:02 +0000 Thank you guys, gonna check it out Conditional size num_1276691899.html Processing Discourse/Syntax Questions num_1276691899.html Wed, 16 Jun 2010 08:43:55 +0000 There's an article about this on the wiki (ex-hacks section):<br /><a href="http://wiki.processing.org/w/Setting_width/height_dynamically" target="_blank">http://wiki.processing.org/w/Setting_width/height_dynamically</a><br /> Displaying "&" instead of &amp num_1195151004.html Processing Discourse/Syntax Questions num_1195151004.html Tue, 15 Jun 2010 09:07:04 +0000 I am trying to do the exact same thing, and I am getting the same error. <br />Machiel, did you manage to solve the problem?<br /><br />Can anyone guide me as to what I would have to do here?<br /><br />Thanks,<br />Akshay Moved: 'using google api' num_1276555780.html Processing Discourse/Syntax Questions num_1276555780.html Tue, 15 Jun 2010 07:03:59 +0000 <b>This Topic has been moved to </b><a href="num_1276555781.html#0"><i><b>Other Libraries</b></i></a><b> by <i>PhiLho </i></b> if() num_1276567479.html Processing Discourse/Syntax Questions num_1276567479.html Mon, 14 Jun 2010 19:42:15 +0000 You're looking for &quot;==&quot;, as in:<br /> <b>Code:</b><pre class="code">if &#40;x == 2&#41; &#123;<br &#47;>  &#47;&#47; blah blah blah<br &#47;>&#125; </pre><br />(A lot of languages use just &quot;=&quot; for both assignment and equality testing, but Java isn't one of them.)<br /> Null pointer exception when calling a .txt num_1276524227.html Processing Discourse/Syntax Questions num_1276524227.html eau-lit@hotmail.com (Eau-Lit) Mon, 14 Jun 2010 08:03:34 +0000 Okay my error, the NullPointerException wasn't in that particular line, it was in the next lines where I filled subStrings with parts of the the .txt file. Now it does works, thanks for your reference koogy. Problem with images transitions num_1276218811.html Processing Discourse/Syntax Questions num_1276218811.html Sun, 13 Jun 2010 16:27:53 +0000 Hi Gustavo,<br /><br />The tint(...) function works like the stroke(...) and fill(...) functions: it prepares the &quot;painting brush&quot; for the next image.  They don't change images that have already been drawn.<br /><br />Thus, you want to move the image(...) and tint(...) calls into draw(), which is better anyway because setup() is for setup and draw() is for drawing <img src="yabbfiles/Templates/Forum/processing_one/wink.gif" border="0" alt="Wink" title="Wink" />  Make sure each tint(...) call is before the image(...) call for which you intended it.<br /><br />You'll need to move the PImage a/b declarations outside the setup() function to make them available in draw(), of course.  Also, your cont variable should be a global variable as well.  You can increase it if arduino sends pulses, and decrease it otherwise.<br /><br />Hope that helps.<br />Cheers,<br />  Christian getting a for loop to reffer to a variable num_1276194565.html Processing Discourse/Syntax Questions num_1276194565.html processing@tiemenrapati.com (Rapatsk1) Sat, 12 Jun 2010 16:56:24 +0000 This is a simplified view on the recursive class. How would I handle the focus of such object?<br /><br /> <b>Code:</b><pre class="code">public class Element &#123;<br &#47;><br &#47;>  float x, y, z;<br &#47;>  float orbitradius, sze; &#47;&#47; radius determines the distance of children, sze is size of object<br &#47;>  String txt; &#47;&#47; content<br &#47;><br &#47;>  Element&#91;&#93; heritage;<br &#47;>  Element&#91;&#93; children;<br &#47;><br &#47;>  boolean mouseover = false;<br &#47;>  boolean is_selected = false;<br &#47;>  boolean is_clicked = false;<br &#47;><br &#47;>  Element&#40;float psize, float radius, String txt&#41; &#123;<br &#47;><br &#47;>    this&#46;txt = txt;<br &#47;><br &#47;>    this&#46;sze = psize;<br &#47;>    this&#46;orbitradius = radius;<br &#47;><br &#47;>    children = new Element&#91;0&#93;;<br &#47;><br &#47;>  &#125;<br &#47;><br &#47;>  Element&#40;int id, Element parent, String txt&#41; &#123; &#47;&#47; constructor for children<br &#47;><br &#47;>    this&#46;txt = txt;<br &#47;><br &#47;>    this&#46;sze = parent&#46;sze&#47;2;<br &#47;>    this&#46;orbitradius = parent&#46;orbitradius&#47;4;<br &#47;><br &#47;>    children = new Element&#91;0&#93;;<br &#47;><br &#47;>  &#125;<br &#47;><br &#47;>  void updatePositions&#40;float newx, float newy, float newz&#41; &#123;<br &#47;><br &#47;>    x = newx;<br &#47;>    y = newy;<br &#47;>    z = newz;<br &#47;><br &#47;>    &#47;&#47; calculating position of children<br &#47;>    for&#40;int i = 0; i &lt; children&#46;length; i++&#41; &#123;<br &#47;> Point p = returnPosition&#40;i, children&#46;length, orbitradius&#41;;<br &#47;> children&#91;i&#93;&#46;updatePositions&#40;p&#46;x, p&#46;y, p&#46;z&#41;;<br &#47;>    &#125;<br &#47;><br &#47;>  &#125;<br &#47;><br &#47;>  void updateSelection&#40;boolean p_selected&#41; &#123;<br &#47;><br &#47;>    if&#40;p_selected&#41; &#123;<br &#47;> is_selected = true;<br &#47;>    &#125;<br &#47;><br &#47;>    for&#40;int i = 0; i &lt; children&#46;length; i++&#41; &#123;<br &#47;> children&#91;i&#93;&#46;updateSelection&#40;is_selected&#41;;<br &#47;>    &#125;<br &#47;>    <br &#47;>    if&#40;&#33;mousedragged&#41; &#123;<br &#47;><br &#47;> if&#40;mouseover&#41; &#123;<br &#47;><br &#47;>  if&#40;mousePressed&#41; &#123;<br &#47;>    is_clicked = true;<br &#47;>    is_selected = true;<br &#47;><br &#47;>    &#47;&#47;set global selection reference here&#63;<br &#47;>  &#125;<br &#47;>  <br &#47;> &#125; <br &#47;> else &#123;<br &#47;>  &#47;&#47; mouseover is false<br &#47;> &#125;<br &#47;><br &#47;>    &#125;<br &#47;><br &#47;>  &#125;<br &#47;><br &#47;>  void draw&#40;&#41; &#123;<br &#47;><br &#47;>    pushMatrix&#40;&#41;;<br &#47;>    translate&#40;x, y, z&#41;;<br &#47;>    <br &#47;>    for&#40;int i = 0; i &lt; children&#46;length; i++&#41; &#123;<br &#47;><br &#47;> &#47;&#47; draw lines to children<br &#47;> stroke&#40;scolor&#41;;<br &#47;> line&#40;0,0,0, children&#91;i&#93;&#46;x, children&#91;i&#93;&#46;y, children&#91;i&#93;&#46;z&#41;;<br &#47;><br &#47;> &#47;&#47; recursive draw<br &#47;> children&#91;i&#93;&#46;draw&#40;&#41;;<br &#47;><br &#47;>    &#125;<br &#47;><br &#47;>    &#47;&#47; rectangle<br &#47;>    stroke&#40;scolor&#41;;<br &#47;>    rect&#40;&#45;sze&#47;2&#46;0, &#45;sze&#47;2&#46;0, sze, sze&#41;;<br &#47;>    <br &#47;>    &#47;&#47; using translated matrix to determine mouseover<br &#47;>    mouseover = isMouseover&#40;mouseX, mouseY&#41;;<br &#47;><br &#47;>    popMatrix&#40;&#41;;<br &#47;><br &#47;>  &#125;<br &#47;>&#125; </pre> arrayCopy() copying into pixels array num_1276208138.html Processing Discourse/Syntax Questions num_1276208138.html Sat, 12 Jun 2010 10:50:34 +0000 yes i am getting used to doing things like you say  and then using<br /><br />= new whatever in setup() <br /><br />now i can have mouse buttons and key presses either copy pixels into my array and vice versa in combination with loadPixels() and updatePixels. <br /><br />i can clear the screen or partially fill and/or clear bits of the screen  and draw into myarray and then show the changes much faster than waiting for a for loop to finish. <br /><br />next i will experiment with applying some alpha values and masking . Thank you all for getting me back on track for some faster animations and screen changes. Keeping arduino+processing project in sync num_1276102025.html Processing Discourse/Syntax Questions num_1276102025.html Fri, 11 Jun 2010 01:09:36 +0000 Put your interface in a .java file instead of a .pde one.<br />Note: you can use <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html" target="_blank">import static</a> to make them regular global variables.<br />Note sure if static import works with Processing 1.1, should work with 018x. ESC key code is used only for exitting a program! num_1276201899.html Processing Discourse/Syntax Questions num_1276201899.html sonic555gr@gmail.com (Lord_Sonic) Thu, 10 Jun 2010 15:44:05 +0000 thank you ben hemme!! thank you both! THE GAME IS COMPLETE! i am presenting it next thursday here in greece! .equals() use in a string with sentences num_1276188279.html Processing Discourse/Syntax Questions num_1276188279.html Thu, 10 Jun 2010 13:25:36 +0000 All works as expected here...<br /><br /> <b>Quote:</b><br /><div class="quote" style="width: 90%; overflow: auto;"><span style="color: #CC6600;">ArrayList</span> words = <span style="color: #CC6600;">new</span> <span style="color: #CC6600;">ArrayList</span>();<br /><br /><span style="color: #CC6600;">void</span> <span style="color: #CC6600;"><b>setup</b></span>()&#123;<br />  words.<span style="color: #CC6600;">add</span>(<span style="color: #006699;">&quot;This sentence contains penguins.&quot;</span>);<br />  words.<span style="color: #CC6600;">add</span>(<span style="color: #006699;">&quot;This sentence contains rats.&quot;</span>);<br />  words.<span style="color: #CC6600;">add</span>(<span style="color: #006699;">&quot;This sentence is about lobsters.&quot;</span>);<br />  <span style="color: #CC6600;">println</span>(<span style="color: #006699;">&quot;Entire match tests:&quot;</span>);<br />  <span style="color: #CC6600;">for</span> (<span style="color: #CC6600;">int</span> i=0;i&lt;words.<span style="color: #CC6600;">size</span>();i++)&#123;<br />    <span style="color: #CC6600;">println</span>(((<span style="color: #CC6600;">String</span>)words.<span style="color: #CC6600;">get</span>(i)).<span style="color: #CC6600;">equals</span>(<span style="color: #006699;">&quot;This sentence contains rats.&quot;</span>));<br />  &#125;<br />  <span style="color: #CC6600;">println</span>(<span style="color: #006699;">&quot;Single word tests:&quot;</span>);<br />  <span style="color: #CC6600;">for</span> (<span style="color: #CC6600;">int</span> i=0;i&lt;words.<span style="color: #CC6600;">size</span>();i++)&#123;<br />    <span style="color: #CC6600;">println</span>(((<span style="color: #CC6600;">String</span>)words.<span style="color: #CC6600;">get</span>(i)).contains(<span style="color: #006699;">&quot;contains&quot;</span>));<br />  &#125;<br />&#125;<br /> </div> image alpha num_1276169985.html Processing Discourse/Syntax Questions num_1276169985.html Thu, 10 Jun 2010 10:10:49 +0000 Use mask() instead of alpha().<br /><a href="http://processing.org/reference/PImage_mask_.html" target="_blank">http://processing.org/reference/PImage_mask_.html</a>