<?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 tint() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=tint%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:56:55 +0000</pubDate>
         <description>Tagged with tint() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedtint%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Fade background with animation at the same time</title>
      <link>https://forum.processing.org/two/discussion/27697/fade-background-with-animation-at-the-same-time</link>
      <pubDate>Thu, 05 Apr 2018 15:14:28 +0000</pubDate>
      <dc:creator>LoCamillo</dc:creator>
      <guid isPermaLink="false">27697@/two/discussions</guid>
      <description><![CDATA[<p>I've been trying to do a project that fade in/out a series of backgrounds. These backgrounds are made of images and they fade/in and out in a sequence showing a text in between. But at the same time, there's an animation of stars playing in the background. The problem is that when the fade of the backgrounds are happening, the stars get slower. I want to fade the backgrounds and keep the stars with the same speed. This is what I have:</p>

<pre><code>     var particles = [];
        var fundos = [];
        var glifos = [];
        var img;
        var logotri;
        var teste;
        var m = 0;
        var loop;
        var alphafade = 255;
        var idlogo= 255;
        var idglifo = 0;


        function setup() {
          cvn = createCanvas(windowWidth, windowHeight);
          logotri = loadImage("logofinal.png");
          teste = loadImage("primeira-tela-1.png");
          loop = 0;

          for (var i = 0; i &lt; 8; i++){
            fundos[i] = loadImage("primeira-tela-" + (i+1) + ".png");
          }

          for (var i = 0; i &lt; 7; i++){
            glifos[i] = loadImage("Glifo" + (i+1) + ".png");
          }

          for (var i = 0; i &lt; 256; i++) {
            p = new Estrelas();
            particles.push(p); // Criação do vetor das estrelas do fundo
          }
        }

        function draw() {
          background(fundos[0]);

          if (m == 0) { //Página inicial estática
            estrelas();
            image(logotri, windowWidth / 3, windowHeight / 3);
          }

          else if (m == 1){ //Fadeout do logo
            tint(255, alphafade);
            image(logotri, windowWidth / 3, windowHeight / 3);
            estrelas();
            fadeout(2, 2);
            noTint();
            }

          else if (m == 2){ //Fadein do glifo 1 + mudança de fundo
            tint(255, alphafade);
            image(fundos[1], 0,0);
            image(glifos[0], windowWidth / 2, windowHeight / 2, 100, 100);
            fadein(3, 3);
            estrelas();
            noTint();

          }

          else if (m == 3){
            image(fundos[1], 0,0);
            tint(255, alphafade);
            image(glifos[0], windowWidth / 2, windowHeight / 2, 100, 100);
            fadeout(4, 2);
            estrelas();
            noTint();


          }
            else if (m == 4){
            image(fundos[1], 0,0);
            texto('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent posuere sapien vitae vulputate aliquam.');
            estrelas();
            fadein(5, 1);

          }
          else if (m == 5){
            image(fundos[1], 0,0);
            texto('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent posuere sapien vitae vulputate aliquam.');
            estrelas();
            fadeout(6, 2);
          }

          else if (m == 6){
            image(fundos[1], 0,0);
            tint(255, alphafade);
            image(fundos[2], 0,0);
            image(glifos[1], windowWidth / 2, windowHeight / 2, 100, 100);
            estrelas();
            fadein(7, 1);
            noTint();
          }

          else if (m == 7){
            image(fundos[2], 0,0);
            tint(255, alphafade);
            image(glifos[1], windowWidth / 2, windowHeight / 2, 100, 100);
            estrelas();
            fadeout(8, 1);
            noTint();
          }


          else if (m == 8){
            image(fundos[2], 0,0);
            estrelas();
            }
          }

        //Função que controla o movimento das estrelas do fundo
        function estrelas() {
          for (var i = 0; i &lt; particles.length - 1; i++) {
            if (particles[i].getalfa() &lt; 5) {
              particles[i].reset(); //Quando o alfa das particulas está quase apagando, ele reseta a particula
              break;
            }
          }

          for (i = 0; i &lt;= particles.length - 1; i++) {
            particles[i].update();
            particles[i].show(); //Mostra as particulas se movendo
          }
        }

        //Função que controla o fadeout das imagens e passa pro proximo nivel de animação
        function fadeout(proximonivel, speed){
          alphafade = alphafade - speed;
          if (alphafade &lt; 0)
            {
                alphafade = 0;
                m = proximonivel;
              }
        }

        //Função que controla o fadein das imagens e passa pro proximo nivel de animação
        function fadein(proximonivel, speed){
          alphafade = alphafade + speed;
          if (alphafade &gt; 255)
            {
                alphafade = 255;
                m = proximonivel;
              }
        }

        //Função que controla no início se houve movimento na roda do mouse
        function mouseWheel(event) {
          if (event.delta != 0 &amp;&amp; loop == 0) {
            m = 1;
            loop = 1;
          }
        }

        //Função que controla no inicio se houve clique do mouse
        function mouseClicked(){
          if ( loop == 0){
            m = 1;
            loop = 1;
          }
        }

        //Função que mostra texto e controla as propriedades
        function texto(string){
          tint(255, alphafade);
          fill(255, alphafade);
          textSize(20);
          textAlign(CENTER, CENTER);
          text(string, windowWidth / 2, windowHeight / 2);
          noTint();
        }

        class Estrelas {

          constructor() {
            this.x = random(0, 1200);
            this.y = random(0, 800);
            this.vx = random(-1, 1);
            this.vy = random(-2, -1);
            this.alfa = random(0, 100);
          }

          getalfa() {
            return this.alfa;
          }

          reset() {
            this.x = random(0, 1200);
            this.y = random(0, 800);
            this.vx = random(-1, 1);
            this.vy = random(-2, -1);
            this.alfa = 100;


          }

          update() {
            this.x += this.vx;
            this.y += this.vy;
            this.alfa--;

          }

          show() {
            fill(255, 255, 255, this.alfa);
            noStroke();
            ellipse(this.x, this.y, 5, 5);
          }

        }
</code></pre>

<p>I have tried a lot of things but i can't make it work.</p>
]]></description>
   </item>
   <item>
      <title>How to control tint of image in Processing with audio output volume</title>
      <link>https://forum.processing.org/two/discussion/17803/how-to-control-tint-of-image-in-processing-with-audio-output-volume</link>
      <pubDate>Tue, 09 Aug 2016 21:18:54 +0000</pubDate>
      <dc:creator>elf</dc:creator>
      <guid isPermaLink="false">17803@/two/discussions</guid>
      <description><![CDATA[<p>Ok, so I'd like to project a few pictures to the wall. I'd like the tint to change gradually, depending on the volume of audio output. 
The audio is coming from audio samples (so not MIDI instruments, if that makes any difference) in Ableton Live Suite, which I'm controlling in real-time.
Any codes/links would be super helpful - stressed postgrad student :)
Thank you!</p>
]]></description>
   </item>
   <item>
      <title>set transparency of texture(image) on sphere primitive P3D</title>
      <link>https://forum.processing.org/two/discussion/27787/set-transparency-of-texture-image-on-sphere-primitive-p3d</link>
      <pubDate>Tue, 17 Apr 2018 12:13:41 +0000</pubDate>
      <dc:creator>mala</dc:creator>
      <guid isPermaLink="false">27787@/two/discussions</guid>
      <description><![CDATA[<p>I thought this could be done with tint() or setTint().... but I can't make it work. Can anyone help ?</p>

<p>I'm using setTexture() to apply a user choosen image to the sphere and would like the user to be able to change the transparency of this texture/image... as there are other 3D objects rendered within the sphere I would like to be able to see.</p>

<p>simple example from a question regarding setTexture but not about transparency:</p>

<pre><code>PImage earth; 
PShape globe;

void setup() { 
  size(600, 600, P3D); 
  background(0); 
  earth = loadImage( "world32k.jpg");
  globe = createShape(SPHERE, 200); 
  globe.setStroke(false);
  globe.setTexture(earth);
}

void draw() { 
  translate(width/2, height/2);
  shape(globe);
}
</code></pre>

<p>where would you use tint() or setTint() in the above to make the globe semi transparent ?</p>

<p>Cheers,
mala</p>
]]></description>
   </item>
   <item>
      <title>How can I get sound to fade in and out depending on your location?</title>
      <link>https://forum.processing.org/two/discussion/27718/how-can-i-get-sound-to-fade-in-and-out-depending-on-your-location</link>
      <pubDate>Sat, 07 Apr 2018 19:15:18 +0000</pubDate>
      <dc:creator>karinalopez87</dc:creator>
      <guid isPermaLink="false">27718@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I was able to make my sound play and stop with Kinect but it doesn't loop or fade out. I want my sound to continue playing with the video and just fade in if the interaction is activated and fade out when the interaction is no longer happening. Also, I want my sound to loop.</p>

<pre><code>     import processing.sound.*;
     import org.openkinect.processing.*;
     import processing.video.*;


    Movie vid;
    Movie vid1;
    SoundFile sound1;
    SoundFile sound2;
    Kinect2 kinect2;

    //PImage depthImg;
    //PImage img1;

    //pixel
    int minDepth=0;
    int maxDepth=4500; //4.5m

    boolean off = false;

    void setup() {
      size(1920,1080);
      //fullScreen();
      vid = new Movie(this, "test_1.1.mp4");
      vid1 = new Movie(this, "test_1.1.mp4");
      sound1 = new SoundFile(this, "cosmos.mp3");
      sound2 = new SoundFile(this, "NosajThing_Distance.mp3");

      //MOVIE FILES
          //01.MOV
          //03.MOV
          //02.mov (File's too big)
          //Urban Streams.mp4
          //HiddenNumbers_KarinaLopez.mov
          //test_w-sound.mp4
          //test_1.1.mp4
          //test005.mov
      //SOUND FILES      
          //cosmos.mp3
          //NosajThing_Distance.mp3

      vid.loop();
      vid1.loop();
      kinect2 = new Kinect2(this);
      kinect2.initDepth();
      kinect2.initDevice();
    //depthImg = new PImage(kinect2.depthWidth, kinect2.depthHeight);
    //img1 = createImage(kinect2.depthWidth, kinect2.depthHeight, RGB);
    }

    void movieEvent(Movie vid){
      vid.read();
      vid1.read();
    }


    void draw() { 
      vid.loadPixels();
      vid1.loadPixels();

      //image(kinect2.getDepthImage(), 0, 0);

        int[] depth = kinect2.getRawDepth();

      float sumX=0;
      float sumY=0;
      float totalPixels=0;

        for (int x = 0; x &lt; kinect2.depthWidth; x++){
          for (int y = 0; y &lt; kinect2.depthHeight; y++){
            int offset = x + y * kinect2.depthWidth;
            int d = depth[offset];

            if ( d &gt; 0 &amp;&amp; d &lt; 1000){
          //    //video.pixels[offset] = color(255, 100, 15);
          sumX +=x;
          sumY+=y;
          totalPixels++;
             brightness(0);
            } else {
          //    //video.pixels[offset] = color(150, 250, 180);
              brightness(255);
            }      }
        }
    vid.updatePixels();
    vid1.updatePixels();

    float avgX = sumX/totalPixels;
    float avgY=sumY/totalPixels;


    //VID 01 - Screen 01
    if (avgX&gt;300 &amp;&amp; avgX&lt;500){
    tint(255, (avgX)/2);
    image(vid1, 1920/2, 0);
    if(sound2.isPlaying()==0){
    sound2.play(0.5);
    sound2.amp(0.5);
    }
    }else{
    tint(0, (avgX)/2);
    image(vid1, 1920/2, 0);
    if(sound2.isPlaying()==1){
     delay(1);
    //IT DIMS THE VOLUME TO 0 BUT IT DOESN'T GO BACK TO VOLUME 0.5 [sound2.amp(0.5);]
     sound2.amp(0);
     }
    }
     //VID 02 - Screen 01
     if (avgX&gt;50 &amp;&amp; avgX&lt;200){
    tint(255, (avgX)/3);
    image(vid, 0-(1920/2), 0);
    }else{
       tint(0, (avgX)/3);
       image(vid, 0-(1920/2), 0);
     }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Less 10 fps if i load many images</title>
      <link>https://forum.processing.org/two/discussion/27367/less-10-fps-if-i-load-many-images</link>
      <pubDate>Mon, 26 Mar 2018 13:14:11 +0000</pubDate>
      <dc:creator>R_Sørensen</dc:creator>
      <guid isPermaLink="false">27367@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys, my sketch is very very slow. I think the problem is the several images loaded (188 images, on average 6 KB each one, 1784 x 870, .png, every images are pratically all trasparent). I solve this problem just write P2D in the size() but after some minutes passed, i see images go out of time. I think the problem is in the images, the frameRate with P2D is 60 while without P2D fps are less than 10. 
I post parts of my huge code just for show you where are my images:</p>

<pre><code>PImage imgR1_1_1;
PImage imgR1_1_2;

void setup () {
  size (1784, 870, P2D);
  frameRate(fr);
  imgR1_1_1 = loadImage("Riquadro1.1.1.png");
  imgR1_1_2 = loadImage("Riquadro1.1.2.png");
}

void draw () {  

    if ((mll-prg1_3) - ((timer1)-prg1_3) &gt;= secondi) { 
      timer1 = mll;
      Aa1 = random(1, 3);
      A1 = int(Aa1);
      Bb1 = random(1, 3);
      B1 = int(Bb1);
      BBbb1 = random(1, 3);
      BB1 = int(BBbb1);
    }


  if (A1 == 1) {
    if (B1 == 1) {
      if (mll - timer1 &lt;= Is2) {  
        tint(255, 0);
        Radd1 = 0;
      } else {
        tint(255, 255-trah);
        Radd1 = ((((657 * perc) / 100) *  S1_1 ) / (secondi - Is2));
      }
      image(imgR1_1_1, 0, 0 + Radd1, width, width/prop);
    }


    if (B1 == 2) {
      if (mll - timer1 &lt;= Is2) {  
        tint(255, 0);
        Radd1 = 0;
      } else {
        tint(255, 255-trah);
        Radd1 = ((((657 * perc) / 100) *  S1_1 ) / (secondi - Is2));
      }
      image(imgR1_1_2, 0, 0 + Radd1, width, width/prop);
    }
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>tint() PImage Android Mode</title>
      <link>https://forum.processing.org/two/discussion/26691/tint-pimage-android-mode</link>
      <pubDate>Wed, 07 Mar 2018 12:48:35 +0000</pubDate>
      <dc:creator>noel</dc:creator>
      <guid isPermaLink="false">26691@/two/discussions</guid>
      <description><![CDATA[<p>Hi.</p>

<p>Code below does exactly what I want; fading picture into almost white.
However it does fade always in Java mode  it does not in Android mode, better to say I've only one image that does fade in Android mode.
I've checked if the pictures have an alpha channel with GIMP and they do.
How to generate images that will fade?
This is driving me nuts.
You can download my fading image <a rel="nofollow" href="https://drive.google.com/file/d/13k36gHH9vPSf1raDcSMROLMhdNY880HK/view?usp=drivesdk">here</a>.</p>

<p>Any rescue?</p>

<pre><code>(int i = 255;
boolean flag1;
PImage img;

void setup() {
  size (600, 600);
  background(255);
  img = loadImage("uyf.png");
  tint(255, 255); 
  image(img, 0, 0);
}

void draw() {  
  if (flag1){
  background(255);
  tint(255, i); 
  image(img, 0, 0); 
  i -= 6;
  if(i &lt; 40) flag1 = false;
  }
}

void mousePressed(){
  flag1 = true;
}
)
</code></pre>
]]></description>
   </item>
   <item>
      <title>Kinect and .mov files</title>
      <link>https://forum.processing.org/two/discussion/26694/kinect-and-mov-files</link>
      <pubDate>Wed, 07 Mar 2018 15:27:41 +0000</pubDate>
      <dc:creator>karinalopez87</dc:creator>
      <guid isPermaLink="false">26694@/two/discussions</guid>
      <description><![CDATA[<p>I'm having trouble controlling the .mov file's tint with rawdepth from kinect</p>

<pre><code> import org.openkinect.processing.*;
 import processing.video.*;
  Movie video;
  Kinect2 kinect2;
 int minDepth=0;
  int maxDepth=4500; //4.5m
  void setup() {
  size(1920,1080);
  video = new Movie(this, "final-02.mov");
  video.loop();
  kinect2 = new Kinect2(this);
  kinect2.initDepth();
  kinect2.initDevice();
  }
  void movieEvent(Movie video){
 video.read();
  }
  void draw() { 
  image(video, 0, 0);
  video.loadPixels();

int[] depth = kinect2.getRawDepth();

for (int x = 0; x &lt; kinect2.depthWidth; x++){
  for (int y = 0; y &lt; kinect2.depthHeight; y++){
    int offset = x + y * kinect2.depthWidth;
    int d = depth[offset];


    if (d &gt; 10 &amp;&amp; d &lt; 400){
      //video.pixels[offset] = color(255, 100, 15);
      tint(10,255);
    } else {
      //video.pixels[offset] = color(150, 250, 180);
      tint(250,10);
    }
  }
  println(x);
}

  video.updatePixels();
  image(video,0,0);
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How do you use the tint(0,0,0); command?</title>
      <link>https://forum.processing.org/two/discussion/26116/how-do-you-use-the-tint-0-0-0-command</link>
      <pubDate>Thu, 25 Jan 2018 15:31:19 +0000</pubDate>
      <dc:creator>DeTjomas</dc:creator>
      <guid isPermaLink="false">26116@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to create a little effect in my game and i need to use the tint command for it.</p>

<p>What I want to know is how to create a pulse from 50% opacity to 100% opacity.</p>

<p>Can somebody help me?</p>
]]></description>
   </item>
   <item>
      <title>Simulating long exposure shots on Processing</title>
      <link>https://forum.processing.org/two/discussion/25904/simulating-long-exposure-shots-on-processing</link>
      <pubDate>Wed, 10 Jan 2018 19:44:32 +0000</pubDate>
      <dc:creator>ferkrum</dc:creator>
      <guid isPermaLink="false">25904@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone,</p>

<p>I am trying to create a sketch that simulates a long exposure shot captured on camera.
I searched for smth similar on the web and found <a rel="nofollow" href="http://forum.luminous-landscape.com/index.php?topic=64233.0">this reference</a> which proposes to append different layers using different opacities. 
I did that with the following code, but it doesn't seem to quite do the job properly.</p>

<p>Anybody tried to do that before?</p>

<p>Any other suggestions?</p>

<p>Thanks for your time! :-)</p>

<pre><code>// This patch proposes to simulate a long exposure shot using Processing.

import processing.video.*;

Capture video;

void setup() {
  size(640, 480);
  printArray(Capture.list());
  video = new Capture(this, 640, 480, 30);
  video.start();
}

void mousePressed()
{
  int steps = 10;  // also means amount of pictures taken and merged later
  long opac = 255 / steps; 

  for (int i = 1; i &lt;= steps; i++) 
  {
    if (video.available())
    {
      video.read();
      image(video, 0, 0);
      tint(255, opac * i);    // changes the opacity every step
      delay (100);            // delay between each step
      print(i); 
      println(" " + opac * i);
    }
  }
}

void keyPressed()
{
  background(0);
}

void draw() {
  // Step 5. Display the video image.
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>blend() and filter() significantly slow down 1080p Video FPS to 7; Any solutions?</title>
      <link>https://forum.processing.org/two/discussion/23072/blend-and-filter-significantly-slow-down-1080p-video-fps-to-7-any-solutions</link>
      <pubDate>Thu, 15 Jun 2017 06:03:24 +0000</pubDate>
      <dc:creator>SpPank</dc:creator>
      <guid isPermaLink="false">23072@/two/discussions</guid>
      <description><![CDATA[<p>//hey, I'm probably not doing this right
//is it cause I'm using the context of PGraphics and PImage mixed up??
//IM GETTING 7 FPS W/ I7 7700K AND 1070 sli
//CPU AND GPU ARE NOT BEING PUSHED
///NEED HELP!!!!</p>

<p>import java.util.ArrayList;
import KinectPV2.KJoint;
import KinectPV2.*;</p>

<p>KinectPV2 kinect;</p>

<p>import processing.video.*;</p>

<p>Movie coral;
PGraphics feedback;</p>

<p>void setup() {
  fullScreen(P2D, 2);
  feedback = createGraphics(1920,1080,P2D);
  background(0);
  //blendMode(ADD);</p>

<p>//Video stuff
  coral = new Movie(this, "CoralReef.mp4");
  coral.loop();</p>

<p>//Kinect stuff
  kinect = new KinectPV2(this);
  kinect.enableBodyTrackImg(true);
  kinect.enableSkeletonDepthMap(true);
  kinect.init();
}</p>

<p>void movieEvent(Movie m) {
  m.read();
}</p>

<p>PImage kinectSil;</p>

<p>void draw() {</p>

<p>kinectSil = kinect.getBodyTrackImage();</p>

<p>kinectSil.filter(INVERT);
  kinectSil.loadPixels();
  for (int i = 0; i &lt; kinectSil.pixels.length; i++) {
    if (kinectSil.pixels[i] == color(0)) {
      kinectSil.pixels[i] = color(0, 0);
    } else {
      kinectSil.pixels[i] = color(255,255);
    }
  }
  kinectSil.updatePixels();</p>

<p>feedback.beginDraw();
  feedback.image(kinectSil,0,0,1920,1080);
  feedback.blend(coral, 0, 0, coral.width, coral.height, 0, 0, coral.width, coral.height, MULTIPLY);
  feedback.filter(THRESHOLD);
  feedback.endDraw();
  tint(255,10);
  image(coral,0,0,width,height);
  blend(feedback,0,0,feedback.width,feedback.height, 0, 0, width, height, LIGHTEST);
  fill(45);
  rect(0,0,150,54);
  textSize(30);
  fill(255);
  text(frameRate, 20,40);
}</p>
]]></description>
   </item>
   <item>
      <title>Tint carries on to next function?</title>
      <link>https://forum.processing.org/two/discussion/25101/tint-carries-on-to-next-function</link>
      <pubDate>Mon, 20 Nov 2017 02:52:25 +0000</pubDate>
      <dc:creator>Zolinal</dc:creator>
      <guid isPermaLink="false">25101@/two/discussions</guid>
      <description><![CDATA[<pre><code>PImage[] walkcycle = new PImage[8];
PImage[] walkcycle1 = new PImage[8];
PImage mandrell;
float x = 0;
float y = 0;
float z = 0;
float c = 0;
float v = 380;
float g = 500;
int walkPics = 0;
  int number = 0;


void setup() {
  size(500, 600);
    walkcycle[0] = loadImage("1.png");
  walkcycle[1] = loadImage("2.png");
  walkcycle[2] = loadImage("3.png");
  walkcycle[3] = loadImage("4.png");
  walkcycle[4] = loadImage("5.png");
  walkcycle[5] = loadImage("6.png");
  walkcycle[6] = loadImage("7.png");
  walkcycle[7] = loadImage("8.png"); 
 mandrell = loadImage("mandrill.jpg");
  mainMenu();
}

void draw() {
  if (key == '1') {
    fourWalkers();
  }
}

void keyPressed() {
  if (key == '0') {
    mainMenu();
  }
 else if (key == '1') {
    fourWalkers();
  }
  else if (key == '2') {
    mainMandrell();
  }
}


void mainMenu() {
  fill(255);
  strokeWeight(2);
  rect(0, 0, width, 480);
  rect(0, 480, width, 120);
  textSize(25);
  fill(1);
 textSize(15);
 number = 0;
  text("Main Menu", 200, 50);
  text("0 - Main Menu", 150, 200);
  text("1 - Four Walkers", 150, 230);
  text("2 - Mandrill", 150, 260);
  text("3 - Love", 150, 290);
    text("Last Key Pressed:" + number, 350, 550);
}



void fourWalkers() {
  background(255);
 fill(150);
  rect(0, 0, width, 480);

  noTint();
  image(walkcycle[walkPics], x, y, 58.9, 100);
    x+= 7;
  y+= 5;
  walkPics++;
  if (walkPics &gt;= walkcycle.length) {
    walkPics = 0;
  }
  if (x &gt; width) {
    x = 0;
    y = 0;
  }

  tint(255, 0, 0);
   image(walkcycle[walkPics], z, 180, 58.9, 100);
   z += 7;
  walkPics++;
  if (walkPics &gt;= walkcycle.length) {
    walkPics = 0;
    if (z &gt; 500) {
      z = 0;
    }
  }

    tint(0, 0, 255);
   image(walkcycle[walkPics], c, v, 58.9, 100);
   c += 7;
   v -= 5;
  walkPics++;
  if (walkPics &gt;= walkcycle.length) {
    walkPics = 0;
  }
      if (c &gt; width) {
     c = 0;
     v = 380;
      }
          tint(0, 255, 0);
   image(walkcycle[walkPics], g, 180, 58.9, 100);
   g -= 7;
  walkPics++;
  if (walkPics &gt;= walkcycle.length) {
    walkPics = 0;
    if (g &lt; 0) {
      g = 500;
    }
  }
  number = 1;
  textSize(15);
  fill(1);
  text("Man Original Height: 158.0", 10, 510);
  text("Man Original Width: 93.0", 10, 530);
  text("Man New Heigh: 100", 10, 550);
  text("Man New Scaled Width: 58.9", 10, 570);
  text("Last Key Pressed:" + number, 350, 550);
}


void mainMandrell() {
  background(255);
  rect(1, 1, width, height - 120);
  image(mandrell, 1, 1, width, height - 120);
  loadPixels();
  mandrell.loadPixels();
  for (int n = 0; n &lt; mandrell. width; n++) {
    for (int m = 0; m &lt; mandrell.height; m++) {
      int i = n + m * mandrell.width;
      float r = red(mandrell.pixels[i]);
      float g = green(mandrell.pixels[i]);
      float b = blue(mandrell.pixels[i]);
      if (x &lt; 200) {
        pixels[i] = color( g, r, b);
      } else {
        pixels[i] = color(r, g, b);
      }
    }
  }
    mandrell.updatePixels();
}
</code></pre>

<p>when I press 1, then 2 the picture of the mandrill is in green tint. I'm trying to tint the mandrill into 1/3rd red, 1/3rd green and 1/3rd blue. Did i make a mistake? thanks!</p>
]]></description>
   </item>
   <item>
      <title>OpenCV kill old Faces loop</title>
      <link>https://forum.processing.org/two/discussion/24820/opencv-kill-old-faces-loop</link>
      <pubDate>Tue, 31 Oct 2017 16:40:17 +0000</pubDate>
      <dc:creator>corbinyo</dc:creator>
      <guid isPermaLink="false">24820@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,
I am using openCV and face detection to control the transparency of images. The position of the detected face on the x axis controls transparency. What I would like to do is be able to ignore the other faces that get picked up by the webcam. Is there a way to get the value of face 1 and ignore face 2, face 3, face 4 etc., but upon face 1 being killed, make face 2 = face 1, face 3 = face 2 etc., and constantly only use the data from face 1 as the controlling parameter?</p>

<p>I have looked into the OpenCV example (Example: Whichface) and I can't seem to wrangle it to what i need it for.
Here is my existing code</p>

<pre><code>    import gab.opencv.*;
    import processing.video.*;
    import java.awt.*;

    Capture video;
    OpenCV opencv;

    PImage ed;
    PImage genie;
    int offset = 0;

    float easing = 0.05;

    void setup() {

    size(724,960);


      video = new Capture(this, 640/2, 480/2);
      opencv = new OpenCV(this, 640/2, 480/2);
      opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  
      video.start();
      ed = loadImage("ed.jpg");
      genie = loadImage("genie.jpg");

    }




    void draw() {

      scale(1);
      opencv.loadImage(video);

      noFill();
      stroke(0, 255, 0);
      strokeWeight(3);

       Rectangle[] faces = opencv.detect();
      println(faces.length);




    for (int i = 0; i &lt; faces.length; i++) {



 tint(255, 230);  // Display at half opacity
image(genie, 0, 0);  // Display at full opacity


  int dx = (faces[i].x-genie.width/2) - offset;
  offset += dx * easing;
  tint(255, faces[i].x);  // Display at half opacity
  image(ed, 0, 0);



   }
} 





void captureEvent(Capture c) {
  c.read();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to improve OpenCV performance on ARM?</title>
      <link>https://forum.processing.org/two/discussion/24529/how-to-improve-opencv-performance-on-arm</link>
      <pubDate>Fri, 13 Oct 2017 16:00:05 +0000</pubDate>
      <dc:creator>Isaac96</dc:creator>
      <guid isPermaLink="false">24529@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys</p>

<p>I am making a face-tracking Nerf blaster using OpenCV on the Raspberry Pi. I am using a Microsoft LifeCam webcam for capture input and the SoftwareServo class for blaster control. However, my code runs at 1-2 FPS on the Pi (Pi 3 model B). I am currently using scale to improve performance, but the code still runs at 1 FPS. Additionally, the servos are extremely jittery. I am powering the servos using a 2A 5V regulator. The Pi is powered off a 2A USB supply. The grounds <em>are</em> connected. Does anyone know how to improve performance? Maybe a different CV library?</p>

<p>Thanks for input!
Code:</p>

<pre><code>import processing.io.*;
import gab.opencv.*;
import processing.video.*;
import java.awt.*; 

PImage img;
Rectangle[] faceRect; 

Capture cam;
OpenCV opencv; 
SoftwareServo panServo;
SoftwareServo trigServo;

int widthCapture=320; 
int heightCapture=240;
int fpsCapture=30; 
int panpos=90;
int firePos = 80;
int readyPos = 0;
long time;
int wait = 500;

int targetCenterX;
int targetCenterY;

int threshold = 20;
int thresholdLeft;
int thresholdRight;
int moveIncrement = 2;


int circleExpand = 20;
int circleWidth = 3;

boolean isFiring = false;
boolean isFound = false;
boolean manual = false;

void setup()
{ 
  size (320, 240); 
  frameRate(fpsCapture); 
  background(0);
  panServo = new SoftwareServo(this);
  trigServo = new SoftwareServo(this);
  panServo.attach(17);
  trigServo.attach(4);

  cam = new Capture(this, widthCapture, heightCapture);
  cam.start(); 

  opencv = new OpenCV(this, widthCapture, heightCapture); 
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
}

void  draw() 
{
  if (millis() - time &gt;= wait)
  {
    trigServo.write(readyPos);
    isFiring = false;
  }
  if (isFiring) 
  {
    trigServo.write(firePos);
    tint(255, 0, 0);
  } else
  {
    trigServo.write(readyPos);
    noTint();
  }
  if (cam.available() == true) 
  { 
    cam.read();  
    img = cam.get(); 

    opencv.loadImage(img);

    image(img, 0, 0);
    blend(img, 0, 0, widthCapture, heightCapture, 0, 0, widthCapture, heightCapture, HARD_LIGHT);
    faceRect = opencv.detect();
  }

  stroke(255, 255, 255);
  strokeWeight(1);
  thresholdLeft = (widthCapture/2)-threshold;
  thresholdRight =  (widthCapture/2)+threshold;

  stroke(255, 255, 255, 128);
  strokeWeight(1);
  line(thresholdLeft, 0, thresholdLeft, heightCapture); //left line
  line(thresholdRight, 0, thresholdRight, heightCapture); //right line

  if ((faceRect != null) &amp;&amp; (faceRect.length != 0))
  {
    isFound = true;
    //Get center point of identified target
    targetCenterX = faceRect[0].x + (faceRect[0].width/2);
    targetCenterY = faceRect[0].y + (faceRect[0].height/2);    

    //Draw circle around face
    noFill();
    strokeWeight(circleWidth);
    stroke(255, 255, 255);
    ellipse(targetCenterX, targetCenterY, faceRect[0].width+circleExpand, faceRect[0].height+circleExpand);
    if (!manual) {
      //Handle rotation
      if (targetCenterX &lt; thresholdLeft)
      {
        panpos -=  moveIncrement;
        //delay(70);
      }
      if (targetCenterX &gt; thresholdRight)
      {
        panpos+=  moveIncrement;
        //delay(70);
      }

      //Fire
      if ((targetCenterX &gt;= thresholdLeft) &amp;&amp; (targetCenterX &lt;= thresholdRight))
      {
        isFiring = true;
        println("Gotem");
        noFill();
      }
    }
  }
}
void keyPressed() {
  if (key == 'm') {
    manual = !manual;
    println("manual mode toggled");
    isFiring = false;
  } else if (key == 'a' &amp;&amp; manual) {
    panpos-= moveIncrement;
    println("left");
  } else if (key == 'f' &amp;&amp; manual) {
    isFiring = !isFiring;
  } else if (key == 'd' &amp;&amp; manual) {
    panpos+= moveIncrement;
    println("right");
  } else if (key == 'c' )
  {
    panServo.write(90);
  } else {
    println(key);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Is it possible to adjust tint on a movie?</title>
      <link>https://forum.processing.org/two/discussion/24357/is-it-possible-to-adjust-tint-on-a-movie</link>
      <pubDate>Tue, 03 Oct 2017 16:32:27 +0000</pubDate>
      <dc:creator>kyatsu</dc:creator>
      <guid isPermaLink="false">24357@/two/discussions</guid>
      <description><![CDATA[<p>I am interested in learning how to fade tint(255,255) to tint(255,0) with a key press, and then from tint(255,0) back to tint(255,255) with a key release on a movie. I can't figure out how to do this with imported video!</p>
]]></description>
   </item>
   <item>
      <title>Mouse clicking and database questions?</title>
      <link>https://forum.processing.org/two/discussion/24133/mouse-clicking-and-database-questions</link>
      <pubDate>Sat, 16 Sep 2017 03:19:10 +0000</pubDate>
      <dc:creator>ImJaz</dc:creator>
      <guid isPermaLink="false">24133@/two/discussions</guid>
      <description><![CDATA[<p>Hi there! 
I've spent a long time trying to figure out how I can get my database and my mouse clicks to work. If someone could help me with it I would appreciate it so much. What I want to do is get the buttons on the side to individually have their own information from the database. When I use my mouse click command it goes on all three of the buttons but I want it to only work on one each. When you click on a button I wanted it to grab something from the database I've made so the first button would be the first bit in my database then where the database is spaced, that's for the second button. I'm quite confused on how to do this and my video is now not working as well (it's meant to tint to the jellyfish and it). If someone could help it would be great!</p>

<p><a href="http://alpha.editor.p5js.org/Jaz/sketches/rkNRPAuqb" target="_blank" rel="nofollow">http://alpha.editor.p5js.org/Jaz/sketches/rkNRPAuqb</a></p>
]]></description>
   </item>
   <item>
      <title>Combining textures onto a shape?</title>
      <link>https://forum.processing.org/two/discussion/24100/combining-textures-onto-a-shape</link>
      <pubDate>Tue, 12 Sep 2017 16:06:38 +0000</pubDate>
      <dc:creator>steve_j</dc:creator>
      <guid isPermaLink="false">24100@/two/discussions</guid>
      <description><![CDATA[<p>Im trying to mix images on a texture using tint (as i would sending it directly to image) but it doesnt seem to be working. Can anyone explain to me why? Do i need to render the mix before applying them to the texture? if so how?</p>

<p>What i currently have</p>

<pre><code>PImage img1, img2;

int alpha = 0;
boolean up = true;


void setup() {
  size(640, 360, P2D);
  img1 = loadImage("layer1.jpg");
  img2 = loadImage("layer2.jpg");
}

void draw() {
  background(0);

  if (up == true &amp;&amp; alpha &lt; 255)
  {
    alpha++;
  } else up = false;
  if (up == false &amp;&amp; alpha &gt; 0) 
  {
    alpha--;
  } else up = true;

  beginShape();
  tint(255, 255);
  texture(img1);
  tint(255, alpha);
  texture(img2);
  vertex(10, 10, 0, 0);
  vertex(width-10, 10, img1.width, 0);
  vertex(width-10, height-10, img1.width, img1.height);
  vertex(10, height-10, 0, img1.height);
  endShape();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How do I make the tint decrease after mouseX reaches a certain point ?</title>
      <link>https://forum.processing.org/two/discussion/23933/how-do-i-make-the-tint-decrease-after-mousex-reaches-a-certain-point</link>
      <pubDate>Sat, 26 Aug 2017 12:27:33 +0000</pubDate>
      <dc:creator>GreenTea</dc:creator>
      <guid isPermaLink="false">23933@/two/discussions</guid>
      <description><![CDATA[<p>so I did this drawing of an eclipse and I added a tint that increases with mouseX but I would like it to decrease after mouseX reaches width/2. I tried my best with loops and stuff but I can't seam to figure out how I can make it to decrease. Any help is appreciated :)</p>

<pre><code> Sun ziSun;
Moon ziMoon;
PGraphics pg;
void setup(){
  size(200,200);
  ziSun = new Sun(width/2, height/2, 100);
  ziMoon = new Moon(90,20,100);
  pg = createGraphics(200,200);
}

void draw(){
  background(135,206,235);
  cloud();
  ziSun.hiu(color(184,134,11),1);
  ziSun.hiu(color(244,175,44),2);
  ziSun.hiu(color(255,215,0),1.5);
  ziSun.display();
  ziMoon.display();

  pg.beginDraw();
  pg.background(0,255);
  pg.endDraw();
  image(pg,0,0);

                  //HERE IS THE TINT PROBLEM
                  // lol just this line
  tint(0,mouseX);
}







void cloud(){
  float leftX = 45;
  float rightX = 200;
  fill(255);
    ellipse(rightX, 50, 126, 97);
    ellipse(rightX+50, 50, 70, 60);
    ellipse(rightX-50, 50, 70, 60);
    ellipse(leftX, 150, 126, 97);
    ellipse(leftX+62, 150, 70, 60);
    ellipse(leftX-62, 150, 70, 60);
}

class Moon{
  float size;
  float posx;
  float posy;

  Moon(float saz, float xpos, float ypos){
    size=saz;
    posx = xpos;
    posy = ypos;
  }

  void display(){
    fill(0);
    ellipse(mouseX,posy,size,size);
  }

}

class Sun{
  float posx;
  float posy;
  float size;
  color c;
  float thickness;
  Sun(float xpos, float ypos, float saz){
    posx = xpos;
    posy = ypos;
    size = saz;
  }

  void display(){
    noStroke();
    fill(244,175,44);
    ellipseMode(CENTER);
    ellipse(posx,posy,size,size);
  }

  void hiu(color cola, float strokewzn){
    c = cola;
    thickness = strokewzn;
    float[] lights = new float[10];
    for (int i=0; i&lt;lights.length; i++){
    stroke(cola);
    strokeWeight(strokewzn);
    line(posx,posy,random(width),random(height));
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Live video delay effect, where from here?</title>
      <link>https://forum.processing.org/two/discussion/23861/live-video-delay-effect-where-from-here</link>
      <pubDate>Sat, 19 Aug 2017 14:12:25 +0000</pubDate>
      <dc:creator>ekind</dc:creator>
      <guid isPermaLink="false">23861@/two/discussions</guid>
      <description><![CDATA[<p>Hi! I've just started my studies on live video manipulation in processing. Today I created this simple delay effect, which feels like a good starting points for more advanced stuff. Any ideas on how to develop this further? I've been experimenting with translation and rotation which renders pretty interesting results. I've tried some stuff with colors but no luck there yet.</p>

<p><em>press and hold any key to start sampling and effect</em></p>

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

Capture camera;
int scale = 1;
void setup()
{
  size(640, 480, P3D);
  colorMode(HSB, 255);

  String[] cameras = Capture.list();

  camera = new Capture(this, width/scale, height/scale, cameras[0]);
  camera.start();

  // init feedback loop
  frames = new PImage[frame_count];
  for(int i = 0; i &lt; frame_count; i++)
  {
      frames[i] = createImage(0, 0, 0);
  }
}

int frame_count = 10;
PImage[] frames;
boolean feedback = false;
void draw()
{
  background(255);

  if(keyPressed)
  {
    image(frames[index], 0, 0);
    for(int i = 0; i &lt; frame_count; i++)
    {
      pushMatrix();
      pushStyle();

      tint(255, 255 / frame_count);
      //translate(0, 0, i * 80 / frame_count);
      image(frames[(index + i) % frame_count], 0, 0);

      popStyle();
      popMatrix();
    }
  }
  else
  {
    image(camera, 0, 0);
  }

  text(frameRate, 20, 20);
}


int index = 0;
void captureEvent(Capture camera)
{
  camera.read();
  PImage p = camera;

  if(keyPressed)
  {
    frames[index] = p.copy();
  }

  index += 1;
  if(index == frame_count)
  {
    index = 0;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Fade tint() value based on avgBPM</title>
      <link>https://forum.processing.org/two/discussion/23828/fade-tint-value-based-on-avgbpm</link>
      <pubDate>Wed, 16 Aug 2017 03:48:42 +0000</pubDate>
      <dc:creator>blabberbytes</dc:creator>
      <guid isPermaLink="false">23828@/two/discussions</guid>
      <description><![CDATA[<p>So I'm trying to change the tint value based on certain BPM. When it hits a new value I want the tint to fade from the old value to the new. I am  very beginner with coding and would like to be help as if I were a baby!  goo goo gag gag. Here's the code I'm struggling with. Thanks</p>

<pre><code>`if (avgBPM &gt; 75) {
          if (fillColor &lt; 215) {
             fillColor+=colorIncrement;
             tint(fillColor, 0, 0, 200);
            } else 

            fillColor-=colorIncrement;
            tint(fillColor, 0, 0, 200);



              if (avgBPM &lt; 75){
                 if ((fillColor &lt; 215)&amp;&amp;(fillColor &gt; 175)) {
                     fillColor+=colorIncrement;
                     tint(fillColor, 0, 0, 200);
                  } else 

                      fillColor-=colorIncrement;
                      tint(fillColor, 0, 0, 200);
            }`
</code></pre>

<p>What am I doing wrong?</p>
]]></description>
   </item>
   <item>
      <title>Gradually change color</title>
      <link>https://forum.processing.org/two/discussion/23620/gradually-change-color</link>
      <pubDate>Sat, 29 Jul 2017 01:17:00 +0000</pubDate>
      <dc:creator>blabberbytes</dc:creator>
      <guid isPermaLink="false">23620@/two/discussions</guid>
      <description><![CDATA[<p>So I have a Heart Pulse sensor, and I want the color to gradually change after each 5 BPM Increments. So far I have it changing abruptly. How do I change it gradually, like a fade?</p>

<p><code>if (avgBPM &lt; 55){
      tint(255, 255, 255, 200);  
      }
    } else if ((avgBPM &gt; 55) &amp;&amp; (avgBPM &lt; 60)){ 
      tint(215, 255, 255, 200);
      }
       } else if ((avgBPM &gt; 60) &amp;&amp; (avgBPM &lt; 65)){
      tint(175, 255, 255, 200);
      }
       } else if ((avgBPM &gt; 65) &amp;&amp; (avgBPM &lt; 70)){
      tint(135, 255, 255, 200);
      } else if ((avgBPM &gt; 70) &amp;&amp; (avgBPM &lt; 75)){
      tint(95, 255, 255, 200);
      } else if ((avgBPM &gt; 75) &amp;&amp; (avgBPM &lt; 80)){
      tint(55, 255, 0, 200);
}</code></p>
]]></description>
   </item>
   <item>
      <title>[video] Play random video sequence</title>
      <link>https://forum.processing.org/two/discussion/23419/video-play-random-video-sequence</link>
      <pubDate>Wed, 12 Jul 2017 21:41:14 +0000</pubDate>
      <dc:creator>andreminei</dc:creator>
      <guid isPermaLink="false">23419@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone,
I'm new to Processing and I've been working on this video-art / installation project for my graduation.</p>

<p>My question is:
How can I set a random video to be played next?</p>

<p>I managed to get the videos playing, but I can't set another random video to follow.
My intention is to have a sequence of videos (maybe 10 or more) that will play in a shuffled order.
I have looked around this and some other forums but couldn't find a specific answer.
Hope you guys can help me out. Thanks!</p>

<p>ps. if something doesn't make sense in my code please tell me :)</p>

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

AudioIn input;
Amplitude analyzer;
int scale=4;

Movie mov1, mov2;
Capture cam;

int n = 5; //total number of videos

float vidN = random(1, n+1);
int x = int (vidN);

float vidN2 = random(1, n+1);
int x2 = int (vidN2);

void setup() {
  //frameRate (30);
  size(1280, 720);
  colorMode (HSB);
  //fullScreen();
  //background(0);

  mov1 = new Movie(this, nf(x, 2)+".mp4");
  mov1.loop();
  mov1.volume(100);

  mov2 = new Movie(this, nf(x2, 2)+".mp4");
  mov2.loop();
  mov2.volume(00);

  cam = new Capture(this, width, height);
  cam.start();  

  blendMode(DIFFERENCE);

  imageMode(CENTER);

  //Create an Audio input and grab the 1st channel
  input = new AudioIn(this, 0);

  // start the Audio Input
  input.start();

  // create a new Amplitude analyzer
  analyzer = new Amplitude(this);

  // Patch the input to an volume analyzer
  analyzer.input(input);
}

void movieEvent(Movie m) {
  if (m == mov1) {
    mov1.read();
  } else if (m == mov2) {
    mov2.read();
  }
}

void draw() {    
  float vol = analyzer.analyze();

  noStroke ();

  tint (255, 80);
  if (cam.available()) {
    cam.read();
    image(cam, width/2, height/2, width, height); // Draw the webcam cam onto the screen

    vol = vol*scale;

    tint (255, 100-vol*100);
    image(mov1, width/2, height/2, width, height);

    tint (255, 100-vol*100);
    image(mov2, width/2, height/2, width, height);
  }
}  
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to sincronize the audio in a way that fade out the image?</title>
      <link>https://forum.processing.org/two/discussion/23399/how-to-sincronize-the-audio-in-a-way-that-fade-out-the-image</link>
      <pubDate>Tue, 11 Jul 2017 00:26:50 +0000</pubDate>
      <dc:creator>valent_000</dc:creator>
      <guid isPermaLink="false">23399@/two/discussions</guid>
      <description><![CDATA[<p>hi everyone! Im new using processing, and i find myself stuck with this doubt, im looking for something that helps me to sincronize the audio and the image and fade out the image, all of that part is in the keyPressed part, i hope i make myself clear</p>

<pre><code>import ddf.minim.*;

PImage img1, img2;
int trans ;
int vol = 1;
float transparency = 255;
AudioPlayer latido;
AudioPlayer pip;
Minim minim;


void setup() {

  size(500, 500);
  background(0);
  trans = 255;
  vol = 1;
  pipi = 3;
  img1 = loadImage("cora.jpg");
  minim = new Minim(this);
  pip = minim.loadFile("pip.mp3");
  latido = minim.loadFile("latido.mp3");
  // the audio "latido" in loop
  latido.loop();
}

void draw() {
  //i combine the audio with the transparency of the image
  int vol = int(latido.mix.level()*500);
  println(vol);
  int trans = int(map(vol,-100,200,80,200));
  tint(trans,100);
  image(img1, -30, -300); 

  if (transparency &gt; 0) { transparency -= 10; }
  tint(0, transparency);
  image(img1, -30, -300);
}
_
**        void keyPressed(){
          //when you press any key the audio "latido" stop, and another audio(pip) starts and the image fade out with tthe last audio(here is my doubt)

          latido.pause();

          pip.setGain(-15);
          pip.play();
          pip.loop();

        }**_
</code></pre>
]]></description>
   </item>
   <item>
      <title>Changing svg opacity without .disableStyle()</title>
      <link>https://forum.processing.org/two/discussion/23280/changing-svg-opacity-without-disablestyle</link>
      <pubDate>Sun, 02 Jul 2017 09:48:20 +0000</pubDate>
      <dc:creator>felixwochnik</dc:creator>
      <guid isPermaLink="false">23280@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys!</p>

<p>I'm facing another problem, this time concerning a PShape that loads an svg.
I want to display this svg "as is", but want to fade it in. I used disableStyle on simple svgs before, but now I'm importing some pretty complex svgs with multiple colors and I'd love to hear if any of you have a solution to <strong>keep the style enabled and only change the alpha/opacity/transparency</strong>.</p>

<p>The relevant parts of the code:</p>

<pre><code>PShape[] svgs = new PShape[2];

...

svgs[i] = loadShape("test/svg" + (i + 1) + ".svg");

...

currentSvg = svgs[int(random(svgs.length))];

...

//I used the following line on the simple svg, because the lifespan variable increases and then decreases again, creating a nice fade.
//fill(0, lifespan*255);
shapeMode(CENTER);
shape(currentSvg, position.x, position.y, currentSvg.width/ratio, currentSvg.height/ratio);
</code></pre>

<p>I also tried using <code>tint(255, lifespan*255);</code> but this only seems to work on images?</p>

<p>Thanks for taking the time to read this, have an amazing day!</p>
]]></description>
   </item>
   <item>
      <title>Need to loop my Video so 100 small videos appear on the screen at the same time.</title>
      <link>https://forum.processing.org/two/discussion/22422/need-to-loop-my-video-so-100-small-videos-appear-on-the-screen-at-the-same-time</link>
      <pubDate>Sat, 06 May 2017 19:12:21 +0000</pubDate>
      <dc:creator>muhammad7319</dc:creator>
      <guid isPermaLink="false">22422@/two/discussions</guid>
      <description><![CDATA[<p><a href="/two/profile/muhammad7319">@muhammad7319</a></p>

<p>You have deliberately vandalised this discussion.</p>

<p>Please read the discussion <a rel="nofollow" href="https://forum.processing.org/two/discussion/21148/do-not-delete-your-posts#latest">DO NOT DELETE YOUR POSTS</a>.</p>

<p>koogs has restored your original posting below.</p>
]]></description>
   </item>
   <item>
      <title>tint() bug ?</title>
      <link>https://forum.processing.org/two/discussion/21132/tint-bug</link>
      <pubDate>Fri, 03 Mar 2017 17:44:51 +0000</pubDate>
      <dc:creator>cameyo</dc:creator>
      <guid isPermaLink="false">21132@/two/discussions</guid>
      <description><![CDATA[<p>I think <code>tint(255,255)</code> should apply a transparency of 100%.<br />
But i have problem with the following sketch:</p>

<pre><code>PGraphics pg;
color c, cp;
boolean t;
void setup()
{
  size(200,200);
  background(80);
  c = color(166,130,180);
  t = false;
  pg = createGraphics(200,200);
  pg.beginDraw();
  pg.noStroke();
  pg.fill(c);
  pg.rect(10,10,180,180);
  pg.endDraw();
}
void draw()
{
  background(80);
  if (t) { tint(255,255); }
  else { noTint(); }
  image(pg,0,0);
  fill(0);
  text("rect rgb: " + red(c) + ", " + green(c) + ", " +  blue(c), 16, 26);
  text("pick rgb: " + red(cp) + ", " + green(cp) + ", " +  blue(cp), 16, 46);    
  text("tint: " + t, 60, 80);
}  
void mousePressed()
{
  cp = get(mouseX,mouseY);
  println(cp);
}
void keyPressed()
{
  t = !t;
}  
</code></pre>

<p>Click rect to pick color --&gt; Correct color<br />
Press a key --&gt; apply <code>tint(255,255);</code><br />
Click rect to pick color --&gt; Wrong color<br />
More, changing tint to off (pressing a key again) does not restore the original color.<br />
I have tested the color change with a color picker program too.<br />
Where am I doing wrong?</p>
]]></description>
   </item>
   <item>
      <title>How can I make copies of the canvas? Original + copy next to it, with same contents.</title>
      <link>https://forum.processing.org/two/discussion/19551/how-can-i-make-copies-of-the-canvas-original-copy-next-to-it-with-same-contents</link>
      <pubDate>Tue, 06 Dec 2016 08:11:18 +0000</pubDate>
      <dc:creator>kristianp89</dc:creator>
      <guid isPermaLink="false">19551@/two/discussions</guid>
      <description><![CDATA[<p>I have the following code in setup():</p>

<pre><code>originalCanvas = createCanvas(windowWidth/2, windowHeight);
originalCanvas.position(0, 0);
originalCanvas.background(0);

copiedCanvas = originalCanvas;
copiedCanvas.position(windowWidth/2, 0);
</code></pre>

<p>However, only the right half of the screen is black. The left part is white, which I find weird. If my approach didn't work, shouldn't at least the left part be black and the right part white?</p>

<p>When I put an ellipse with mouseX and mouseY in draw(), it only shows in the black/right canvas. The left canvas seems inactive.</p>

<p>I know about createGraphics, but then I would have to always draw things twice, right? For example "original.ellipse(...) and copy.ellipse(...)" - or am I missing something?</p>
]]></description>
   </item>
   <item>
      <title>Image transparency (alpha) via tint() is very slow.</title>
      <link>https://forum.processing.org/two/discussion/19438/image-transparency-alpha-via-tint-is-very-slow</link>
      <pubDate>Wed, 30 Nov 2016 23:45:59 +0000</pubDate>
      <dc:creator>brig</dc:creator>
      <guid isPermaLink="false">19438@/two/discussions</guid>
      <description><![CDATA[<p>Hi. I'm trying to adjust the alpha channel for images loaded using loadImage(). However, when I do so, FPS drops from 60FPS to 3FPS with just 4 images on screen.</p>

<p>Code I'm using is approximately: 
var path = "assets/video_placeholder.jpg"
var imgHandler = loadImage(path);
tint(255, 126);
image(imgHandler, 200, 200, 450, 450);</p>

<p>Is this expected? Other than using DOM to load images and applying CSS to control opacity, is there any better way to give transparency to images?</p>

<p>thx!</p>
]]></description>
   </item>
   <item>
      <title>composition/mix videos</title>
      <link>https://forum.processing.org/two/discussion/19071/composition-mix-videos</link>
      <pubDate>Wed, 16 Nov 2016 17:27:45 +0000</pubDate>
      <dc:creator>diramazioni</dc:creator>
      <guid isPermaLink="false">19071@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I'm wondering if is possible to make a player that is able to mix/fade from one video to another.</p>
]]></description>
   </item>
   <item>
      <title>processing.js performance on different devices</title>
      <link>https://forum.processing.org/two/discussion/18498/processing-js-performance-on-different-devices</link>
      <pubDate>Tue, 11 Oct 2016 10:49:29 +0000</pubDate>
      <dc:creator>michelb</dc:creator>
      <guid isPermaLink="false">18498@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I am quite new to processing and I have been playing with it the last couple of weeks. I am working on a tiny project. The idea is to make a simple sequential animation. it is basically a few images, shapes, and text that appear in sequence. I have written the pde code (see below) and all works fine using the IDE. Now I want to port this on a website using processing.js (simply using processing.min.js and a canvas element).</p>

<p>It all works fine in the browser (chrome), but here is the problem the animation looks fine on a desktop, but on a tablet (a lenovo quad core) or Smasung Galaxy S3, the animation is all jerky (looks like the frame rate is dropping to unacceptable levels).
So my question is: Is this a normal behavior, is my animation simply too complex, or may be I am doing something wrong in my code that is making the animation so heavy for non-desktop devices (although for example I don't think I have too long for loops )?</p>

<p>Also, does anyone has any best practice and tips when trying to set up simple sequential animation like below?</p>

<p>In btw, the images are each around 20-30KB. may be this is also slowing down things !!</p>

<p>I will appreciate any help, thank you.</p>

<p>Michel.</p>

<p>PS: I could not find a place (such as jsfiddle) to put the code along with the images somewhere for people to visualize the animation :(.</p>

<hr />

<pre><code>PImage main,cloud,phone,send,hand,alert;

PFont f;
String message1 = "Hello there, this";
String message2 = "is a message.";
String message3 = "See you.";
int c;

float typeSpeed = 12;
float speedDot = 3.0;

float x;
float y;

float xCloud,yCloud,xPhone,yPhone;

int fr = 24;

float angle,anglePhone,scaleCloud,scaleSend,angleSend,scaleAlert,angleAlert;

float xDot,xDot2,yDot; // Dot2 is used on the right side of the cloud

float cloudWidth = 150;

int ringingDuration,sendDuration,clickDuration,alertDuration,inBtwLoops;

int diam=50;

boolean finishedTextDisplay;

int myFrameCount;

void setup() {  
  size(1000,400);  
  frameRate(fr);  
  /* <a href="/two/profile/pjs">@pjs</a> preload="data/main.png"; */
  /* <a href="/two/profile/pjs">@pjs</a> preload="data/cloud.png"; */
  /* <a href="/two/profile/pjs">@pjs</a> preload="data/phone.png"; */
  /* <a href="/two/profile/pjs">@pjs</a> preload="data/send.png"; */
  /* <a href="/two/profile/pjs">@pjs</a> preload="data/hand.png"; */
  /* <a href="/two/profile/pjs">@pjs</a> preload="data/alert.png"; */

  main = loadImage("data/main.png");
  cloud = loadImage("data/cloud.png"); 
  phone = loadImage("data/phone.png");
  send = loadImage("data/send.png");
  hand = loadImage("data/hand.png");
  alert = loadImage("data/alert.png");  

  f = createFont("Arial",14,true); textFont(f);  
  resetValues();  
}

void draw() {
  myFrameCount++; // each trip thry draw is 1 frame count
  imageMode(CORNERS);image(main,0,0);  
  displayCloud(0); 
  displayPhone(0);
  if (alertDuration == 0 || alertDuration &gt; fr) {displayAlert(0,false);} // displayAlert(scale,tinted) 

  if (finishedTextDisplay == false) {

        x = 195;
        y = 170;
        for (int i = 0; i &lt; message1.length(); i++) { // show letters 1 sec interval 
          //println("for loop");
          if (fr*i/typeSpeed &lt;= myFrameCount) {  
            c = 0; // show
          } 
          else {
            c = 255; // don't show
          }    
          fill(c);
          text(message1.charAt(i),x,y);    
          x += textWidth(message1.charAt(i));
          // println(textWidth(message3.charAt(i)));
        }

        x = 190;
        y = 170 + textAscent()+textDescent();        
        for (int i = 0; i &lt; message2.length(); i++) { // show letters 1 sec interval 
          //println("for loop");
          if (fr*i/typeSpeed &lt;= myFrameCount - ((fr/typeSpeed)*(message1.length()))) {
            c = 0; // show
          } 
          else {
            c = 255; // don't show
          }    
          fill(c);
          text(message2.charAt(i),x,y);    
          x += textWidth(message2.charAt(i)); 
        }

        x = 185;
        y = 170 + 2*(textAscent()+textDescent());

        for (int i = 0; i &lt; message3.length(); i++) { // show letters 1 sec interval 
          // println("for loop");
          if (fr*i/typeSpeed &lt;= myFrameCount - ((fr/typeSpeed)*(message1.length()+message2.length()))) {
            c = 0; // show
            if (i == message3.length()-1) { // last character shown --&gt; click button
                      finishedTextDisplay = true;
            }
          } 
          else {
            c = 255; // don't show
          }    
          fill(c);
          text(message3.charAt(i),x,y);    
          x += textWidth(message3.charAt(i)); 
        } // end for loop 
    } // if finishedTextDisplay

    else // characters are all dislayed 
    {
      // display strings
      // println("NO for loop");
      fill(0);
      x = 195;y = 170; text(message1,x,y);    
      x = 190;y = 170+textAscent()+textDescent(); text(message2,x,y);
      x = 185;y = 170+2*(textAscent()+textDescent()); text(message3,x,y);

      // display hand
      if (clickDuration &lt;= 0.5*fr) {
        // display bigger send button
        /*
        if (angle &lt;= PI) { 
          scaleSend = map(sin(angleSend), 0, 1, 0, 0.15); 
          displaySend(scaleSend);
          angleSend += 5*PI/100;       
        }
        */
        if (clickDuration &lt; 0.5*0.5*fr ) {scaleSend = clickDuration;}
        else {scaleSend = 0.5*fr - clickDuration;}
        // println(scaleSend);        
        scaleSend = map(scaleSend, 0, 0.5*0.5*fr, 0, 0.15); 
        displaySend(scaleSend);
        clickDuration++;

        tint(255,180);imageMode(CORNERS);image(hand,265,205);tint(255,255); 


      }
      else 
      {
                      displaySend(0);
                      // move on with simualtion
                      if (xDot &lt; xCloud - cloudWidth/2) { // not reached cloud yet
                        displayDot();
                        // println("dot");
                      }
                      else 
                      { // dot reached the cloud --&gt; no dot and grow cloud
                        // put the dot on the other side of the cloud
                        if (angle &lt;= PI) { // once inflate and deflates once, cloud stops moving
                          // println(scaleCloud);
                          scaleCloud = map(sin(angle), 0, 1, 0, 0.15); 
                          displayCloud(scaleCloud);
                          angle += 5*PI/100;
                          // println("cloud");
                        }                  
                        else 
                        { // dot on the other side                    
                          if (xDot2 &lt; xCloud + 165) { // not reached the arrow
                            displayDot2();
                            // println("dot 2");
                        }
                        else { // dot reached the phone --&gt; no dot , phone shakes
                             if (ringingDuration &lt; 4.5*fr) {
                               // println("ringing");
                               // displayPhone(random(-0.06,0.06)); // phone shakes
                               displayPhone(map(sin(anglePhone), -1, 1, -(PI/50), +(PI/50)));
                               anglePhone += (PI/2);

                               // rings
                               if ( (0 &lt; ringingDuration &amp;&amp; ringingDuration &lt;= 0.5*fr) || (ringingDuration &gt; 2.5*fr &amp;&amp; ringingDuration &lt;= 3*fr)) {                     
                                 displayRing(0);
                               }
                               if ( (0.5*fr &lt; ringingDuration &amp;&amp; ringingDuration &lt;= fr) || (ringingDuration &gt; 3*fr &amp;&amp; ringingDuration &lt;= 3.5*fr) ) {
                                 displayRing(0);
                                 displayRing(20);
                               }                         
                               if ( (fr &lt; ringingDuration &amp;&amp; ringingDuration &lt;= 1.5*fr) || (ringingDuration &gt; 3.5*fr &amp;&amp; ringingDuration &lt;= 4*fr)) {  
                                 displayRing(0);
                                 displayRing(20);
                                 displayRing(40);
                               }
                               if ( (ringingDuration &gt; 1.5*fr &amp;&amp; ringingDuration &lt;= 2.0*fr) || (ringingDuration &gt; 4*fr &amp;&amp; ringingDuration &lt;= 4.5*fr)) {  
                                 displayRing(0);
                                 displayRing(20);
                                 displayRing(40);
                                 // displayRing(60);
                               }
                               ringingDuration++;
                             }
                             else {
                                if (alertDuration &lt;= fr) {
                                    // alert beeps 2 times  
                                    if (alertDuration &gt;= 0 &amp;&amp; alertDuration &lt; fr/4 ) {scaleAlert = alertDuration;}
                                    if (alertDuration &gt;= fr/4 &amp;&amp; alertDuration &lt; 2*fr/4) {scaleAlert = 2*fr/4 - alertDuration;}
                                    if (alertDuration &gt;= 2*fr/4 &amp;&amp; alertDuration &lt; 3*fr/4) {scaleAlert = alertDuration - 2*fr/4;}
                                    if (alertDuration &gt;= 3*fr/4 &amp;&amp; alertDuration &lt;= fr) {scaleAlert = fr - alertDuration;}
                                    // else {scaleAlert = 0.5*fr - alertDuration;}
                                    // println(scaleAlert);        
                                    scaleAlert = map(scaleAlert, 0, 0.5*0.5*fr, 0, 0.15); 
                                    displayAlert(scaleAlert,true);
                                    alertDuration=alertDuration+1;                                
                                }    
                                else 
                                {
                                  // alertDuration = 0;
                                  // wait for a second a so before starting the animation again
                                  if (inBtwLoops &lt;= 2*fr) {
                                    inBtwLoops ++;
                                  }
                                  else {
                                    resetValues();
                                  }  
                                }
                             }
                          }  
                        }
                      }
      }

    }

}

void displayAlert(float scaleAlert, boolean tinted){
    pushMatrix();
    translate(222,386);
    imageMode(CENTER);
    scale(1+scaleAlert);
    if (tinted) {tint(217, 83, 79);} 
    image(alert,0,0); 
    tint(255,255);
    popMatrix();
}

void resetValues(){  
  angle=anglePhone=scaleCloud=scaleSend=angleSend=scaleAlert=angleAlert=0;  
  xCloud = width/2+85;
  yCloud = height/2-10;  
  xDot = xCloud - 170; 
  yDot = height/2;  
  xDot2 = xCloud + cloudWidth/2;  
  xPhone = xDot2 + 170 + 50;
  yPhone = height/2;  
  ringingDuration = sendDuration = clickDuration = alertDuration = inBtwLoops = 0;  
  finishedTextDisplay = false; 
  myFrameCount = 0;
}

void displayRing(int diamExtra){
  int alpha = round(map(diamExtra,0,40,255,50));
  strokeWeight(5.5);
  strokeCap(ROUND); 
  noFill();
  stroke(24, 188, 156, alpha);
  // arc(xPhone+10, yPhone - 69, diam+diamExtra, diam+diamExtra, -HALF_PI,0);
  arc(xPhone+10, yPhone - 69, diam+diamExtra, diam+diamExtra, -HALF_PI+(HALF_PI/7),0-(HALF_PI/7));
}

void displayCloud(float scaleCloud){
    pushMatrix();
    translate(xCloud,yCloud);
    imageMode(CENTER);
    scale(1+scaleCloud);
    image(cloud,0,0,150,150);
    popMatrix();
}

void displayPhone(float anglePhone){
    pushMatrix();
    translate(xPhone,yPhone);
    rotate(anglePhone);
    imageMode(CENTER);
    // scale(1+scaleCloud);
    image(phone,0,0,55,161);
    popMatrix();
}

void displayDot(){
    xDot+=speedDot;
    fill(21, 158, 130);
    stroke(21, 158, 130);
    ellipse(xDot,yDot,15,15);
}
void displayDot2(){
    xDot2+=speedDot;
    fill(21, 158, 130);
    stroke(21, 158, 130);
    ellipse(xDot2,yDot,15,15);
}

void displaySend(float scaleSend){
    pushMatrix();
    translate(275,215);
    imageMode(CENTER);
    scale(1+scaleSend);
    image(send,0,0,48,26);
    popMatrix();  
  /*
    pushMatrix();
    imageMode(CORNERS);
    tint(255,alpha);  // alpha=0: tranparent  
    image(send,250,205);
    tint(255,255); // 255: normal
    popMatrix();
  */  
} 
</code></pre>

<hr />
]]></description>
   </item>
   <item>
      <title>Colored Rectangle + Mask</title>
      <link>https://forum.processing.org/two/discussion/18491/colored-rectangle-mask</link>
      <pubDate>Mon, 10 Oct 2016 21:58:00 +0000</pubDate>
      <dc:creator>djevazi</dc:creator>
      <guid isPermaLink="false">18491@/two/discussions</guid>
      <description><![CDATA[<p>I want to create something like textured brush, so I use PImage with mask() to get textured stroke effect. But is there a possibility to somehow use a mask for simple colored rectangle? Because I want my brush contain both texture and picked color. So, it would be great if both PImage texture and colored rectangle have the same mask. Maybe there is some trick?</p>
]]></description>
   </item>
   </channel>
</rss>