<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with println() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=println%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:15:24 +0000</pubDate>
         <description>Tagged with println() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedprintln%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>What to look for if processing sketch freezes occassionally but doesn't produce an error message?</title>
      <link>https://forum.processing.org/two/discussion/23810/what-to-look-for-if-processing-sketch-freezes-occassionally-but-doesn-t-produce-an-error-message</link>
      <pubDate>Mon, 14 Aug 2017 15:55:21 +0000</pubDate>
      <dc:creator>r3dm</dc:creator>
      <guid isPermaLink="false">23810@/two/discussions</guid>
      <description><![CDATA[<p>Hey everyone, not sure how to fully describe this, but the problem I'm running into is that a cyclical sketch is supposed to run 300 times then pause, but sometimes the sketch freezes without showing an error message. To add to the confusion, what I'm seeing on-screen in the run window doesn't seem to match the println commands that are coming out of the console during the crash. Does this sound familiar to anyone?</p>

<p>The code is pretty long so I won't post it here, but if anyone's run into similar problems with more intensive processing sketches (this one is trying to simulate city growth using voxels), or has any troubleshooting advice that would be very helpful! Could it be running out of allocated memory for processing or something like that, causing it to freeze without causing an error?</p>
]]></description>
   </item>
   <item>
      <title>testing code instability</title>
      <link>https://forum.processing.org/two/discussion/24764/testing-code-instability</link>
      <pubDate>Fri, 27 Oct 2017 09:04:23 +0000</pubDate>
      <dc:creator>Denis</dc:creator>
      <guid isPermaLink="false">24764@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I am puzzled about an instability that i reproduced with the following test code :</p>

<p>//scoping test<br />
void setup(){<br />
  surface.setVisible(false);<br />
}<br />
void draw(){<br />
  noLoop();<br />
  scoping();<br />
}<br />
void scoping(){<br />
  int w =300; int h = 300;<br />
  for (int y = 0; y &lt; h; y++) {<br />
      for (int x = 0; x &lt; w; x++) {<br />
        int loc = x + y*w;<br />
        println(x+" "+y+" "+loc);<br />
    }<br />
  }<br />
}</p>

<p>For values of w*h larger than  #100000 (and sometime less), the code stops with no error display. I need to kill the task for restart.
Any idea ? Thank you for helping</p>
]]></description>
   </item>
   <item>
      <title>How many conditions can be used inside an if statement?</title>
      <link>https://forum.processing.org/two/discussion/21463/how-many-conditions-can-be-used-inside-an-if-statement</link>
      <pubDate>Sat, 18 Mar 2017 00:12:26 +0000</pubDate>
      <dc:creator>Nasif</dc:creator>
      <guid isPermaLink="false">21463@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>I'm currently developing an interactive data visualization and I'm attempting to use an if statement with 8 conditions. After I added the last condition, the program didn't carry it out so I decided to println the variable that defined the condition. Upon adding this prinln() to the code, the program started crashing processing every time I run it. Do if statements have a limit on the amount of conditions they can carry out? Can I use nested if statements to solve this or will that not work either?</p>

<p>Thanks!!</p>
]]></description>
   </item>
   <item>
      <title>Why is my program not responding after running this code?</title>
      <link>https://forum.processing.org/two/discussion/20810/why-is-my-program-not-responding-after-running-this-code</link>
      <pubDate>Wed, 15 Feb 2017 17:28:02 +0000</pubDate>
      <dc:creator>Skybird0</dc:creator>
      <guid isPermaLink="false">20810@/two/discussions</guid>
      <description><![CDATA[<p>Why is my program not responding after running this code?  I have to kill it in Task Manager after I run it, very inconvenient. I think it is because of how I am filling the array.  Not sure if I am doing this correctly.  This program is supposed to take data from a file, fill an array, read values from the array, perform math on some of these values, and display it.  I just need help with the array parts.
Processing 3.2.3, Win 10.
Here is my code, I included it all.  I hope you don't mind.  If I missed something let me know and I will include it.</p>

<p>Sample of the data being processed:</p>

<pre>
24,38010,1.

23,38011,1.

27,38012,1.

25,38013,1.

27,38014,1.

27,38016,2.

28,38017,1.

27,38018,1.
</pre>

<p>Code:</p>

<pre>
    /*
    
     Future Changelog:
     (Overall: Clean code, good code practice, comments)
     Multi line buffer reading (Read only)(V.1):
     Dynamic grid size(V.1.2)
     Metric or Imperial detection and displaying(V.2)
     On screen buttons(V.1.1)
     File selection?
     Replay function(V.1.2)
     Zoom function(V.1.3)
     */
    
    //File
    PrintWriter output;
    BufferedReader reader;
    int [] v = {};
    int [] t = {};
    int [] s = {};
    //int [][][] data = {{v}, {t}, {s}};
    //Data
    float time = 0;             // horizontal position of the graph
    float oldtime = 0;
    float thrust = 0;             // vertical position of the graph
    float oldthrust = 0;
    //Running average
    float ravg = 0;
    float s1 = 0;
    float s2 = 0;
    float s3 = 0;
    float s4 = 0;
    float s5 = 0;
    float s6 = 0;
    float s7 = 0;
    float s8 = 0;
    float s9 = 0;
    float s10 = 0;
    float s11 = 0;
    float s12 = 0;
    float s13 = 0;
    float s14 = 0;
    float s15 = 0;
    float s16 = 0;
    float ravgOut = 0;
    float ravgOutold = 0;
    //Calculation
    float maxmem = 0;
    float total = 0;
    float avgval = 0;
    float totimp = 0;
    float IsP = 0;
    float mclass = 0;
    //Constants
    float cval = 0.142;
    float cval2 = 7.04225352112676;
    float grain = 0.032;
    float gconst = 9.81;
    //Misc.
    boolean pause;//Playback pause/play
    int speed = 0;//Playback speed
    int modclass = 0;//Motor Class modifier
    char txtclass = '!';//Motor Class character
    //graph
    int gry = 0;
    int grx = 0;
    
    void setup()
    {
      //Screen size
      fullScreen();
      //size(1024, 768);
      surface.setResizable(true);
      reader = createReader("sim.txt");  // Open the file
      //Text formating, backgound color, framerate
      textFont(createFont("Sans", 48));
      background(#AAAAAA); 
      frameRate(1000000);
      //delay for windowed mode
      delay(3000);
    }
    
    void draw()
    {
      Fileparse();
      if (time &lt; 1)
      {
        graph();
      }
      //Runs when not paused
      if (!pause)
      {
    
        if (thrust != 0)
        {
          //Function calls
          //txt();
          thrust();        
          smoothing();
          maxval();
          avgval();
          totimp();
          IsP();
          mclass();
          time();
        }
      }
    }
    
    
    void Fileparse()
    {
      String line;
      String[] pieces;
      boolean trigger = false;
      while (trigger == false )
      {
        //Exception error handling (Unrecognized char etc.)
        try
        {
          line = reader.readLine();
        }
        catch (IOException e)
        {
          e.printStackTrace();
          line = null;
        }
        //If end of file, 
        if (line == null)
        {
          //txt();
          // Stop reading because of an error or file is empty
          trigger = true;
        }
        //File parsing (String to float)
        else
        {
          //if (thrust != 0)
          //{
          //  oldthrust = thrust;
          //}
          pieces = splitTokens(line, ",.");
          for (int i = 0; i &lt; pieces.length; i++)
          {
            if (i==0)
            {
              v = append(v, int(pieces[i]));//*cval
            }
            if (i==1)
            {
              t = append(t, int(pieces[i]));//-38010
            }
            if (i==2)
            {
              s = append(s, int(pieces[i]));
            }
            print("v");
            printArray(v);
            print("t");
            printArray(t);
            print("s");
            printArray(s);
            println();
            delay(50);
          }
        }
      }
    }
    
    void keyReleased()//Keyboard function
    {
      if (key== 27) exit();
      if (key== 32) pause = !pause;
      if (key==',') speed = speed + 10;
      if (key=='.') speed = 0;
      if (key=='s') saveFrame(month() + "_" + day() + "_" + year() + "_" + "####.jpeg");
    }
    
    void time()
    {
      //Time display
      fill(#000000);
      stroke(#000000);
      text(time*.001, 250, 55);
      oldtime = time;
      //Delay for controlling playback speed  (Usually 5(ms))
      delay(speed);
    }
    
    void thrust()
    {
      stroke(#000000);
      strokeWeight(1);
      line(oldtime+30, height-(oldthrust/cval)-30, time+30, height-(thrust/cval)-30);
      //Raw values display
      fill(#000000);
      stroke(#000000);
      textSize(25);
      text(thrust, 50, 55);
    }
    
    void smoothing()//Running average
    {
      ravgOutold = ravgOut;
      ravg = thrust;
      s16 = s15;
      s15 = s14;
      s14 = s13;
      s13 = s12;
      s12 = s11;
      s11 = s10;
      s10 = s9;
      s9 = s8;
      s8 = s7;
      s7 = s6;
      s6 = s5;
      s5 = s4;
      s4 = s3;
      s3 = s2;
      s2 = s1;
      s1 = ravg;
      ravgOut = (s16 +s15 +s14 +s13 +s12 +s11 +s10 +s9 +s8 + s7 + s6 + s5 + s4 + s3 + s2 + s1)/16;
    
      stroke(#FF0C00);
      strokeWeight(2);
      line(time+30, height-(ravgOutold/cval)-30, time+30, height-(ravgOut/cval)-30);
      //Smoothing
      fill(#FF0C00);
      stroke(#FF0C00);
      text(ravgOut, 150, 55);
    }
    
    void maxval()//Max thrust
    {
      if (thrust &gt; maxmem)
      {
        maxmem = thrust;
      }
    }
    
    void avgval()//Average thrust
    {
      total = total + thrust;
      avgval = total/time;
    }
    
    void totimp()//Total impulse
    {
      totimp = total*.001;
    }
    
    void IsP()//Specific Impulse
    {
      IsP = (totimp/grain)/gconst;
    }
    
    void mclass()//Motor class (NAR)
    {
      mclass = (totimp-modclass)*100/modclass;
    
      if (totimp&lt;20)
      {
        modclass = 10;
        txtclass = 'D';
      } else if (totimp&lt;40)
      {
        modclass = 20;
        txtclass = 'E';
      } else if (totimp&lt;80)
      {
        modclass = 40;
        txtclass = 'F';
      } else if (totimp&lt;160)
      {
        modclass = 80;
        txtclass = 'G';
      }
    }
    
    void graph()//Graph lines
    {
      stroke(#0000FF);
      strokeWeight(1);
      for (int i = 0; i &lt; 1400; i = i+100)//X
      {
        line(i+30, (height-30)-(cval2*90), i+30, height-30);
        fill(#003B9B);
        stroke(#003B9B);
        textSize(20);
        if (grx &lt; 1300)
        {
          text(grx, i+35, height-5);
        }
        grx = grx + 100;
      }
      for (float i = height; i &gt; 100; i = i-cval2*5)//Y
      {
        line(30, i-30, 1330, i-30);
        fill(#003B9B);
        stroke(#003B9B);
        textSize(20);
        if (gry &lt; 90)
        {
          text(gry, 5, i-35);
        }
        gry = gry + 5;
      }
    }
</pre>
]]></description>
   </item>
   <item>
      <title>Uncaught ReferenceError: println is not defined</title>
      <link>https://forum.processing.org/two/discussion/20353/uncaught-referenceerror-println-is-not-defined</link>
      <pubDate>Thu, 19 Jan 2017 15:45:32 +0000</pubDate>
      <dc:creator>BabluKumar</dc:creator>
      <guid isPermaLink="false">20353@/two/discussions</guid>
      <description><![CDATA[<p>What is the problem in my code?
<img src="https://forum.processing.org/two/uploads/imageupload/099/7JL1VBCKT7GE.PNG" alt="1" title="1" /></p>
]]></description>
   </item>
   <item>
      <title>Performance issue with ArrayList</title>
      <link>https://forum.processing.org/two/discussion/17014/performance-issue-with-arraylist</link>
      <pubDate>Mon, 06 Jun 2016 20:29:47 +0000</pubDate>
      <dc:creator>unparadise</dc:creator>
      <guid isPermaLink="false">17014@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone,</p>

<p>I am having performance issue with ArrayList. I have spend about a day trying to figure out what's the potential cause but with no success. I was wondering whether anyone could help me. The code is below. What I am trying to do is to create a sphere with points. I want to allow the user to control the number of points through the slider. But when I change the number of points to 2000 the sketch really slows down. Below is the code of my sketch.</p>

<p>Thank you very much for your time.</p>

<p>Best,
Frank</p>

<pre><code>import peasy.*;
import controlP5.*;

PeasyCam cam;
ControlP5 cp5;
PMatrix3D currCameraMatrix;
PGraphics3D g3;

float r = 100;
float alpha, beta;
float noiseScale = 0.003;
int numPoints = 100;

Slider pNum;
ArrayList&lt;SPoint&gt; particles = new ArrayList&lt;SPoint&gt;();

void setup() {
  size(600, 600, P3D);
  g3 = (PGraphics3D)g;

  background(0);
  frameRate(60);
  noSmooth();

  cp5 = new ControlP5(this);

  cp5.addSlider("numPoints")
     .setPosition(20, 20)
     .setRange(10, 2000)
     .setCaptionLabel("Number of Points")
     .setHeight(20)
     .setValue(numPoints)
     ;

  cp5.setAutoDraw(false);

  // Setup the camera
  cam = new PeasyCam(this, 250);

  noFill();
  stroke(5, 207, 255);

  // Initialize the points
  for(int i = 0; i &lt; numPoints; i++) {
    particles.add(new SPoint(random(0, TWO_PI), random(0, TWO_PI), r));
  }
}

void draw() {
  pushMatrix();
  background(0);

  // Update the location of the points
  for(int i = 0; i &lt; numPoints; i++) {

    // Decide whether the system needs to remove or add points responding to the slider
    if(numPoints &lt; particles.size()) {
      particles.remove(particles.size()-1);
    } else if (numPoints &gt; particles.size()) {
      particles.add(new SPoint(random(0, TWO_PI), random(0, TWO_PI), r));
    }
    particles.get(i).updateAngles(noiseScale);
    particles.get(i).update();
    println("numPoints: " + numPoints);
    println(particles.size());
  }
  popMatrix();
  gui();
}

void gui() {
  currCameraMatrix = new PMatrix3D(g3.camera);
  camera();
  cp5.draw();
  g3.camera = currCameraMatrix; 
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Sketch checking if pixel is black or white crashes.</title>
      <link>https://forum.processing.org/two/discussion/16864/sketch-checking-if-pixel-is-black-or-white-crashes</link>
      <pubDate>Sat, 28 May 2016 17:17:13 +0000</pubDate>
      <dc:creator>Lolo112</dc:creator>
      <guid isPermaLink="false">16864@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I´m trying to make a sketch that checks if pixels are black or white in order to find it´s geometrical center. 
I got the comparing done, however, I can compare only half of the image. Whenever I want to check the whole image the sketch crashes. I was wandering if you could tell me if there´s any bug in my code or if I´m missing anything.</p>

<p>This is the image I´m using right now. I tried changing it but the problem persists.
<img src="https://forum.processing.org/two/uploads/imageupload/654/2YSFYIJ0Z65L.jpg" alt="1" title="1" /></p>

<p>And this is the sketch I came up with:</p>

<pre><code>PImage img;  

void setup() {
  size(500,500);

  img = loadImage("1.jpg");
  image(img,0,0);
  loadPixels();

  println(pixels.length);
  for(int a=0;a&lt;pixels.length/5;a++){
    if(brightness(pixels[a])==255){
      println("white");
    }else if(brightness(pixels[a])==0){
      println("black");
    }
    //println(a);
    //println(brightness(pixels[a]));
  }
}

void draw() {

}
</code></pre>

<p>Thank you in advance.</p>
]]></description>
   </item>
   <item>
      <title>Colorful println()s</title>
      <link>https://forum.processing.org/two/discussion/15589/colorful-println-s</link>
      <pubDate>Sun, 20 Mar 2016 19:58:44 +0000</pubDate>
      <dc:creator>BleuBox</dc:creator>
      <guid isPermaLink="false">15589@/two/discussions</guid>
      <description><![CDATA[<p>Without a using a library, is there a way to set the color of text in a println()? If not, does a library for that exist? I think color-coding data like that would be convenient (and fun to look at).</p>
]]></description>
   </item>
   <item>
      <title>JSONs files</title>
      <link>https://forum.processing.org/two/discussion/14208/jsons-files</link>
      <pubDate>Thu, 31 Dec 2015 15:32:23 +0000</pubDate>
      <dc:creator>ondsinet_</dc:creator>
      <guid isPermaLink="false">14208@/two/discussions</guid>
      <description><![CDATA[<p>I need to read (and write in the future) a list of names and infos that will congregate into many array of objects, and to make it easyer to store and organize this infos I would like to save it to a JSON file;The problem is that using P5.js, every attempt to read such files results in a "Array[ ]" response from the browser consolle. I tryed to debug the <a rel="nofollow" href="http://p5js.org/reference/#/p5/loadJSON">example page</a> at p5.js reference and it gives the same result, an empty array.
Trying to load a local file gives this errors:
"syntax error    file.json:1:1"  "not well formatted    file.json:1:1" and printing it gives an empty array.
This files should be well written as I copyed them from online examples unless thwy all where missing some part of the file(something that's well possible as I don't know the structure of the file, while knowing the object properties".
Also, saving the same files as a variable inside the sketch gives no problem, but in fact I need it as external file.</p>

<p>EDIT: I have the same problem with loadStrings, and I only tryed in locale with firefox developer ed</p>
]]></description>
   </item>
   <item>
      <title>Truncation of float with println</title>
      <link>https://forum.processing.org/two/discussion/13079/truncation-of-float-with-println</link>
      <pubDate>Sat, 17 Oct 2015 23:56:51 +0000</pubDate>
      <dc:creator>Haunted</dc:creator>
      <guid isPermaLink="false">13079@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I'm using processing to read in GPS data from a wireless sensor, over serial. I'm finding that converting the float to a string and then displaying it is leading to a loss of precision that is unacceptable for precise GPS. In fact, just printing a long float in Processing, or displaying it as text also causes truncation:</p>

<pre><code>  println(float("41.312320709"));
  println(41.312320709);
</code></pre>

<p>in both cases the output is 41.31232, so the '0709' at the end has been lost. Though the conversion may actually be converting the data to the correct precision, it's very hard to work with the truncated values.</p>

<p>I've also tried <code>Float.valueOf(f2_str).floatValue();</code> 
and <code>Float.parseFloat(f2_str);</code>
but when I println I get the same results.</p>

<p>I've checked the print reference but can't find an alternative format or explanation on why it is limited to a certain number of characters.</p>

<p>Any help appreciated.</p>
]]></description>
   </item>
   <item>
      <title>How to print specific elements of an array?</title>
      <link>https://forum.processing.org/two/discussion/12498/how-to-print-specific-elements-of-an-array</link>
      <pubDate>Sun, 13 Sep 2015 22:14:11 +0000</pubDate>
      <dc:creator>Altharis</dc:creator>
      <guid isPermaLink="false">12498@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm trying to print out parts of an array</p>

<p>If I have 
<code>int[] numbers = {7, 3, 9, 1, 2, 8, 4, 5, 6, 10};</code></p>

<p>How can I print numbers above 5 from that array? I know I can just write print(numbers[0]), but that's not what I want...
I tried a simple if and println; but that doesn't work ("The operator &gt; is undefined for the argument type(s) int[], int).</p>

<p>I also tried to sort it (numbers = sort(numbers)) and then print all the elements from index 5 through 9, but I have no clue how to write one line to print multiple numbers. I searched a lot and I'm getting frustrated because it looks like it's extremely easy to do :(</p>
]]></description>
   </item>
   <item>
      <title>array prints weird stuff</title>
      <link>https://forum.processing.org/two/discussion/11524/array-prints-weird-stuff</link>
      <pubDate>Wed, 01 Jul 2015 03:22:25 +0000</pubDate>
      <dc:creator>plux</dc:creator>
      <guid isPermaLink="false">11524@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I have this simple code that does not work in my sketch. I have a function which creates and prints an array of 3 elements..but I don't understand why it will print weird stuff instead of the values stored inside of it</p>

<pre><code>void makeChord(int tuning){

    float[] chord = new float[3];
    chord[0] = 10;
    chord[1] = 11;
    chord[2] = 12;
    println("CHORD "+chord);
}
</code></pre>

<p>will print something like</p>

<pre><code>CHORD [F@704c6d5c
CHORD [F@299fec9d
CHORD [F@42674cc4
CHORD [F@be0f9eb
CHORD [F@436c8512
</code></pre>

<p>the function gets callend inside another function that's inside the draw. if I put this code in the draw, it will throw the same result. In a new sketch instead it will work fine. no errors in the console</p>

<p>same result also if I do this way</p>

<pre><code>float[] chord = {10,10,10};
println("CHORD "+chord);
</code></pre>

<p>note that I have other arrays in the same sketch and they all work fine)
thanks</p>
]]></description>
   </item>
   </channel>
</rss>