<?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 currentthread() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=currentthread%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:56:17 +0000</pubDate>
         <description>Tagged with currentthread() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedcurrentthread%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Multiple videos smoothness - threaded playback</title>
      <link>https://forum.processing.org/two/discussion/28057/multiple-videos-smoothness-threaded-playback</link>
      <pubDate>Fri, 15 Jun 2018 20:57:02 +0000</pubDate>
      <dc:creator>grumo</dc:creator>
      <guid isPermaLink="false">28057@/two/discussions</guid>
      <description><![CDATA[<p>Hello!
This script only requires a bunch of .mp4s in the data folder. You'll see a collage of 9 videos (or duplicates) in different positions and transparencies. The thing runs ok but even pre-loading the videos at the beginning every time there's a change/swap in one of the videos (around every 4 seconds) the whole thing freezes for a sec, sometimes (try to use mp4s of different sizes).</p>

<p>I tried to use the thread() command in the switching of the videos but nothing happened. I put a println to see the thread but alway show the main thread, I really don't know if I'm doing this ok..</p>

<p>Thanks a LOT for any help!</p>

<pre><code>import processing.video.*;

File path; 
String[] files;
int numfiles = 0;
int timer = -5000;
int tcontrol= 2000;
int numVideos=9;

VideoM[] v = new VideoM[numVideos];
Movie[] vv;

void setup(){
  size(1920, 1080, P2D);
  frameRate(60);
  files = files(); 
  numfiles = files.length;
  if (numfiles&gt;11) numfiles=11;
  loadvideos();

  for(int i = 0;i &lt; numVideos;i++){
     v[i] = new VideoM();
  }
}


void draw() {

  background(0);
  for(int i = 0; i &lt;numVideos; i++){
     v[i].display();
  }

  if ((millis() - timer) &gt; tcontrol)  {
    thread("newvideo");   
    timer = millis();
    tcontrol= int(random(2,6))*1000; 
}
}


void loadvideos(){

 String video;
 vv = new Movie[numfiles];

 for (int i=0; i&lt;numfiles; i++){
   video= files[int(random(numfiles))];
   vv[i] = new Movie(this, video);
   println ("Loading ", video);
 }
}

class VideoM {

 Movie m;
 String video;

 int x;
 int y;
 int w;
 int h;
 int alpha;
 int alphai;
 int fadeout=0;

 VideoM() {
  genera();
  println(numfiles);
  m = vv[int(random(numfiles)) ];
  m.loop();
  // m.volume(random(0.4,0.6));
  // m.speed(random(0.6,1.0));
  m.jump(random(m.duration()));  
  //m.play(); 
 }

 void genera(){
    x=int(random(50, width/2+width/4)); 
    y=int(random(50, height/2+height/4)); 
    w=int(random(280,820));
    h=int(w/1.88);
    alpha=int(random(100,255)); 
    alphai=0; 
 }

 void display(){
   tint(255, alphai);
   if (fadeout==0) {
     alphai++; if (alphai&gt;alpha) alphai=alpha;
   } else {  alphai--; if (alphai&lt;0) {alphai=0;fadeout=0;this.newvid();}
     }

   if (frameCount &gt; 1) { image(m, x, y, w, h); }
 } 

 void cambiavid(){
   fadeout=1;
 }

void newvid() {  
   m=null;
   int j=int(random(numfiles));
   println("cambio: ", j);
   m = vv[j];
   m.loop();
   genera();
   m.jump(random(m.duration())); 
   println(Thread.currentThread());
 }
}  

void newset(){
  for(int i = 0;i &lt; numVideos;i++){
    println(i);
    v[i].newvid();
  }
}

void newvideo(){
  int i = int(random(numVideos));
  //v[i].nuevovid(this);
  v[i].cambiavid();
}

void movieEvent(Movie m) {
  m.read();
}

boolean bStop,bColor=true;
boolean bSave=false,bVidO=false;
void keyPressed()
{
  int k = keyCode;

  // reset all videos
  if (key == 'n' || key == 'N') {
    newset();
    }

}  


// load files in data

String[] files(){
// The data path of the folder to look in (write your own)
java.io.File folder = new java.io.File(dataPath(""));

// let's set a filter (which returns true if file's extension is .jpg)
java.io.FilenameFilter pngFilter = new java.io.FilenameFilter() {
  public boolean accept(File dir, String name) {
    return name.toLowerCase().endsWith(".mp4");
  }
};

// list all the folders inside the main directory
String[] listFolders = folder.list(new java.io.FilenameFilter() {
  public boolean accept(File current, String name) {
    return new File(current, name).isDirectory();
  }
});

// list the files in the data folder, passing the filter as parameter
String[] filenames = folder.list(pngFilter);

return(filenames);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Is this a known bug?</title>
      <link>https://forum.processing.org/two/discussion/24624/is-this-a-known-bug</link>
      <pubDate>Wed, 18 Oct 2017 14:13:00 +0000</pubDate>
      <dc:creator>Puddle</dc:creator>
      <guid isPermaLink="false">24624@/two/discussions</guid>
      <description><![CDATA[<p>I am currently working on an assignment for my school and I am running into a problem I can not seem to solve.</p>

<p>As this is a graded problem I would like to ask not to give me a solution but just to point out what could be causing this or if it's a known bug.</p>

<p>I am coding a program that needs to draw some content. The drawing is managed by a function that is invoked at the mouseClicked event.</p>

<p>Before the screen is drawn, the entire screen is refreshed within the called function using background(255).</p>

<p>The thing I am running into is that from time to time text content is placed on top of old content or lines are drawn towards the point that make up the starting point from where the text is drawn.</p>

<p>It does not produce this problem every time the program runs nor are any variables used that could effect the logic behind what is happening. Most annoying is that I can not seem to reproduce it myself. Going through the application the exact same way twice could one time produce this issue and the other time everything goes fine.</p>

<p>Any suggestions into what could be causing this would be great.</p>
]]></description>
   </item>
   <item>
      <title>How can I detect a custom event while the draw method is still running?(See Description)</title>
      <link>https://forum.processing.org/two/discussion/22007/how-can-i-detect-a-custom-event-while-the-draw-method-is-still-running-see-description</link>
      <pubDate>Sat, 15 Apr 2017 07:18:19 +0000</pubDate>
      <dc:creator>mezbah</dc:creator>
      <guid isPermaLink="false">22007@/two/discussions</guid>
      <description><![CDATA[<p>I am using processing 2.2.1 with minim and writing code in java with netbeans. I have a situation where my processing sketch is running that means the draw method is running. While it is running an event is triggered by other class. For that I wrote a custom event handler and registered it in the class which is running the sketch..But the class is unable to detect the event..Any help..TIA</p>
]]></description>
   </item>
   <item>
      <title>Public void inside draw? Using librarie ControlP5</title>
      <link>https://forum.processing.org/two/discussion/21881/public-void-inside-draw-using-librarie-controlp5</link>
      <pubDate>Fri, 07 Apr 2017 14:51:16 +0000</pubDate>
      <dc:creator>tsunii</dc:creator>
      <guid isPermaLink="false">21881@/two/discussions</guid>
      <description><![CDATA[<p>My objective is that when you put the valor it'll draw the function "flor" but, it don't erase the last one that was drawn. How could i do that?</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/184/XS2UQ4DW3DCR.jpg" alt="question" title="question" /></p>
]]></description>
   </item>
   <item>
      <title>Is it possible to reset matrix in draw loop?</title>
      <link>https://forum.processing.org/two/discussion/21535/is-it-possible-to-reset-matrix-in-draw-loop</link>
      <pubDate>Wed, 22 Mar 2017 09:36:29 +0000</pubDate>
      <dc:creator>JDev</dc:creator>
      <guid isPermaLink="false">21535@/two/discussions</guid>
      <description><![CDATA[<p>I keep getting the "too many call to popMatrix" message even tough im pretty sure i paired them well and no multithreading involved, also in different executions i either get the error right off the bat or never, im also using awt components mixed in the PApplet.</p>

<p>Its there some way to ensure a clean state of the matrix right at the beginning of draw loop?</p>

<p>Edit:</p>

<pre><code>            father.clip(posX, posY, w, h);

    if(father.mouseX-posX&gt;0&amp;&amp;father.mouseX&lt;posX+w+l&amp;&amp;
       father.mouseY-posY&gt;0&amp;&amp;father.mouseY&lt;posY+h+l)
        sliderY-=father.mouseEvent.getCount()*7;
    father.mouseWheel();
    sliderX=sliderX&gt;0?0:sliderX&lt;-mW+w?-mW+w:sliderX;
    sliderY=sliderY&gt;0?0:sliderY&lt;-mH+h?-mH+h:sliderY;
    for(int i=0;i&lt;childs.size();i++){
        XYEntity child=childs.get(i); 
        if(down){ 
            sliderX+=hit1?+1:hit2?-1:0;
            sliderY+=(hit3?+1:hit4?-1:0);
            sliderX=hitX?-(((mW-w)/(w-2*l))*(father.mouseX-posX-l)):sliderX;
            sliderY=hitY?-(((mH-h)/(h-2*l))*(father.mouseY-posY-l)):sliderY;
            sliderX=sliderX&gt;0?0:sliderX&lt;-mW+w?-mW+w:sliderX;
            sliderY=sliderY&gt;0?0:sliderY&lt;-mH+h?-mH+h:sliderY;
        }
        father.pushMatrix();

        father.translate(sliderX, sliderY); 

        child.xt=sliderX+this.xt;
        child.yt=sliderY+this.yt;

        child.render(father);

        father.popMatrix();
    }

    father.noClip();

    &lt;child&gt;

@ Override
public void render(Container view) {
    father.stroke(25,25,200);
    father.fill(0);
    father.rect(posX, posY, w, h);
    String fullChat="";

    for(int i=chat.size()&gt;maxMsg?chat.size()-maxMsg:0;i&lt;chat.size();i++){
        fullChat+=chat.get(i)+"\n";
    }
    father.fill(/**i%2==0?style1:*/style2);
    //father.textSize(size);
    father.text(fullChat, posX+margin, posY+margin+size/2,w,h);
}
</code></pre>

<p>I put in the "faulty" code, i see a pair of clip,noClip and a pair of push and pop, i cant understand how possibly i could get an error on the pop, am i missing some implicit pop in my code?</p>
]]></description>
   </item>
   <item>
      <title>Help Converting to Arduino?</title>
      <link>https://forum.processing.org/two/discussion/20458/help-converting-to-arduino</link>
      <pubDate>Wed, 25 Jan 2017 00:24:30 +0000</pubDate>
      <dc:creator>Reefhermit</dc:creator>
      <guid isPermaLink="false">20458@/two/discussions</guid>
      <description><![CDATA[<p>I would appreciate some help (or direction) converting this perfect Processing code to an Arduino Sketch? It is the color conversion math/function I cannot seem to get through.</p>

<p>I have been through a lot of permutations with Linux/Windows platforms and SBCs' but the Arduino IDE and like microcontrollers seems to be the best option for this application.</p>

<p>Any help would be appreciated.</p>

<p>Thanks in Advance,</p>

<p>Ken</p>

<pre><code>void applyColor() {  // Generate the heat map
  pushStyle(); // Save current drawing style
  // Set drawing mode to HSB instead of RGB
  colorMode(HSB, 1, 1, 1);
  loadPixels();
  int p = 0;
  for (int r = 0; r &lt; height; r++) {
    for (int c = 0; c &lt; width; c++) {
      // Get the heat map value
      float value = interp_array[c][r];
      // Constrain value to acceptable range.
      value = constrain(value, mintemp, maxtemp);
      // Map the value to the hue
      // 0.2 blue
      // 1.0 red
      value = map(value, mintemp, maxtemp, 0.2, 1.0);
      pixels[p++] = color(value, 1, 2);
    }
  }
  updatePixels();
  popStyle(); // Restore original drawing style
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Processing IDE and java vs Eclipse or Netbeans</title>
      <link>https://forum.processing.org/two/discussion/18049/processing-ide-and-java-vs-eclipse-or-netbeans</link>
      <pubDate>Fri, 02 Sep 2016 13:46:50 +0000</pubDate>
      <dc:creator>Per</dc:creator>
      <guid isPermaLink="false">18049@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>I have been using processing for many years and are now starting learn more java. In my course we are using NetBeans. I wounder are there any advantages of starting to code processing sketches in NetBeans or Eclipse instead of Processing. For example if I want to integrate a processing sketch in a pure java sketch.</p>

<p><em>What advantages could there be of switching the IDE from Processing to NetBeans or Eclipse?</em></p>

<p><br /></p>

<p>I have integrated processing into netbeans by using these following steps. Posting it here if it could help anyone.</p>

<p>1) Create new java project<br />
2) Copy the files in ”contents/Resources/Java/core/library” to a new folder called for example ”_ProcessingLibraries”<br />
3) Right click ”Libraries” in your project in NetBeans and choose ”Add folder/library” and select and add all the jarfiles<br />
4) Create a new java class and call it for example ”MySketch”<br />
5) Write in MySketch class:<br /></p>

<pre><code>package pkg6_processing;

import processing.core.*;  // import the processing core

public class MySketch extends PApplet {  // extend the PApplet for inherit all

    @ Override
    public void settings() {
        size(300, 300);
    }

    @ Override
    public void setup() {
        fill(120, 50, 240);
    }

    @ Override
    public void draw() {
        ellipse(mouseX, mouseY, 20, 20);
    }
}
</code></pre>

<p>6) Run the PApplet in the main class</p>

<pre><code>package pkg6_processing;

public class Main {

    public static void main(String[] args) {
        MySketch.main("pkg6_processing.MySketch"); // run the applet in main
    }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>run object method in parallel thread</title>
      <link>https://forum.processing.org/two/discussion/17767/run-object-method-in-parallel-thread</link>
      <pubDate>Sat, 06 Aug 2016 13:41:18 +0000</pubDate>
      <dc:creator>secondsky</dc:creator>
      <guid isPermaLink="false">17767@/two/discussions</guid>
      <description><![CDATA[<p>Hi everybody, i know how to run a function in a parallel thread (easy, just passing the name in "thread()"), but is there a way to run an object method in a parallel thread?
Thanks</p>
]]></description>
   </item>
   <item>
      <title>push exceeding 32 use limit</title>
      <link>https://forum.processing.org/two/discussion/15972/push-exceeding-32-use-limit</link>
      <pubDate>Mon, 11 Apr 2016 23:31:44 +0000</pubDate>
      <dc:creator>murenrb</dc:creator>
      <guid isPermaLink="false">15972@/two/discussions</guid>
      <description><![CDATA[<p>I am writing a dashboard UI for an arduino and am running into the error "pushmatrix cannot use push more than 32 times" this appears to be caused when a pushmatrix is used too many times without popmatrix. I am not totally sure what is causing it as all my pushes have pops. Additionally I tried putting all my different draw sections in try statements so I could see what was causing the problem, but this did not stop the error from happening. This makes me think I am not catching it in a try because there is really no drawing going on outside a try at this point. Finally, I am using the graphica library to plot the data in real time from the arduino. All graphing is in seperate try statements, so its the same thing.</p>

<p>Does anybody know what exception I should use for this error? Right now I am using runtime.</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>ControlP5 Overwriting Screen when writing to the screen with a text("ccc") Command</title>
      <link>https://forum.processing.org/two/discussion/14152/controlp5-overwriting-screen-when-writing-to-the-screen-with-a-text-ccc-command</link>
      <pubDate>Sat, 26 Dec 2015 02:47:24 +0000</pubDate>
      <dc:creator>CyberMerln</dc:creator>
      <guid isPermaLink="false">14152@/two/discussions</guid>
      <description><![CDATA[<p>Actually have to two issues.  The first is pretty much described in the question.  I created a button that writes text to the screen using text("" + q[3]*rad2deg, 280, 360) in the button function as follows:</p>

<pre><code>     public void controlEvent(ControlEvent theEvent) {
     //println(theEvent.getController().getName());

    }

    public void Button1() {
          println("a button event from colorB: ");
            fill(255,0,0); 
            textSize(12);
            text("" + q[0]*rad2deg, 170, 360);
            text("" + q[1]*rad2deg, 170, 380);    
            text("" + q[2]*rad2deg, 170, 400);
            text("" + q[3]*rad2deg, 280, 360);
            text("" + q[4]*rad2deg, 280, 380);
            text("" + q[5]*rad2deg, 280, 40); 

        }
</code></pre>

<p>On release of the button the values flashes on the screen and then disappears.  Not sure how to fix this issue.  I did a web search but nothing. I am using processing 3 with the latest library.  I have attached a screen shot of the GUI for reference.  The offending fields are t0 through t6.  Ultimate intent to have these update as the calculations for robot arm position is calculated.  Also tried to this with a ControlP5 textfield and textarea but they don't update until after the last iteration is completed and only shows the last iteration.</p>

<p><img src="https://drive.google.com/file/d/0BwzZjH9KYYMDcXBHWkdrdU1yZEk/view?usp=sharing" alt="" /></p>

<p>Heres the actual link: <a rel="nofollow" href="https://drive.google.com/file/d/0BwzZjH9KYYMDcXBHWkdrdU1yZEk/view?usp=sharing">https://drive.google.com/file/d/0BwzZjH9KYYMDcXBHWkdrdU1yZEk/view?usp=sharing</a></p>

<p>v/R
Mike</p>
]]></description>
   </item>
   <item>
      <title>Sketch Priority ?</title>
      <link>https://forum.processing.org/two/discussion/13682/sketch-priority</link>
      <pubDate>Fri, 27 Nov 2015 06:43:11 +0000</pubDate>
      <dc:creator>pxgator</dc:creator>
      <guid isPermaLink="false">13682@/two/discussions</guid>
      <description><![CDATA[<p>Is there a way to give a sketch a higher priority ?</p>
]]></description>
   </item>
   <item>
      <title>Processing and garbage collection ?</title>
      <link>https://forum.processing.org/two/discussion/13671/processing-and-garbage-collection</link>
      <pubDate>Thu, 26 Nov 2015 18:38:23 +0000</pubDate>
      <dc:creator>pxgator</dc:creator>
      <guid isPermaLink="false">13671@/two/discussions</guid>
      <description><![CDATA[<p>I'm using a Raspberry Pi 2 with the raspbian jessie image. Processing and the G4P lib and gui builder are working very well but when I close a window by clicking the 'x' the task manager still shows a java thread and a thread with the name of the sketch still running. The java thread is also still consuming some CPU time. So, by using the exit() function what code should I be using to do a complete 'clean up' ??</p>
]]></description>
   </item>
   <item>
      <title>How to understand the execution order when draw() and mousePressed() are next to each other?</title>
      <link>https://forum.processing.org/two/discussion/13161/how-to-understand-the-execution-order-when-draw-and-mousepressed-are-next-to-each-other</link>
      <pubDate>Wed, 21 Oct 2015 23:30:21 +0000</pubDate>
      <dc:creator>kennyLiao</dc:creator>
      <guid isPermaLink="false">13161@/two/discussions</guid>
      <description><![CDATA[<p>Here is a code example from <a rel="nofollow" href="http://learningprocessing.com/examples/chp09/example-09-11-array-append/">LearningProcessing book</a>:</p>

<pre><code>void draw() {
  background(255);

  // Update and display all balls
  for (int i = 0; i &lt; balls.length; i ++ ) { // Whatever the length of that array, update and display all of the objects.
    balls[i].gravity();
    balls[i].move();
    balls[i].display();
  }
}

void mousePressed() {
  // A new ball object
  Ball b = new Ball(mouseX,mouseY,24); // Make a new object at the mouse location.
  balls = (Ball[]) append(balls,b);
</code></pre>

<p>What I am not clear about is: <em>when the program is running, and then press mouse</em>, <br /></p>

<ol>
<li><code>draw</code> function will halt immediately (even it is in the middle line of its code), <code>mousePressed</code> function will run once, then <code>draw</code> function continue to run until <code>mousePressed</code> is triggered again or the program reload or stopped? <br /></li>
<li><code>draw</code> function will finish its latest run and then halts, then <code>mousePressed</code> function will run once, then <code>draw</code> function continue to run until <code>mousePressed</code> is triggered again or the program reload or stopped?  <br /></li>
<li>both <code>draw</code> and <code>mousePressed</code> functions are running at the same time, but <code>mousePressed</code> runs only once, <code>draw</code> will continue until the program is stopped. <br /></li>
</ol>

<p>which one is correct way of understanding their execution order behind the curtain? or how should I understand it?</p>

<p>Thank you!</p>

<p>Kenny</p>
]]></description>
   </item>
   <item>
      <title>Need to Minimize PApplet for keyPressed to Work</title>
      <link>https://forum.processing.org/two/discussion/8406/need-to-minimize-papplet-for-keypressed-to-work</link>
      <pubDate>Mon, 01 Dec 2014 01:38:37 +0000</pubDate>
      <dc:creator>hellocello</dc:creator>
      <guid isPermaLink="false">8406@/two/discussions</guid>
      <description><![CDATA[<p>I'm having trouble using multiple keyPressed functions.  It will work, but only after minimizing the PApplet window.  Does anyone have any idea why this is?  This seems like a java problem, but I really have no clue.  I have the problem on two mac OS Xs, an older 10.9.2 and a newer 10.9.4 Mavericks.  The Processing revision number is 2.2.1.  Here is an example (pressing 'e' will not produce results after pressing 'p' until after the papplet window is minimized):</p>

<pre><code>    void setup() {
     size(525, 680);
    }

    void draw() {
       background(0);
      rect(50, 50, 400, 400);
    }

    void keyPressed() {
     if (key == 'p'){         //pixelates a large portion of the screen
     loadPixels();
     for (int i = 100000; i &lt; pixels.length; i++) {
     float rand = random(255);
     color a = color(rand, 110, 200, 100);
     pixels[i] = a;
    }
     updatePixels();  
     noLoop(); 
    }
    if (key == 'e') {   //switches two parts of the image
    PImage p = get();
    copy(p, 0, 0, 100, 400, 0, 280, 100, 400);
    copy(p, 0, 400, 100, 280, 0, 0, 100, 280);  
    }
    } 
</code></pre>

<p>Thank you for any help and ideas!!</p>
]]></description>
   </item>
   </channel>
</rss>