<?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 #popmatrix - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23popmatrix</link>
      <pubDate>Sun, 08 Aug 2021 19:09:54 +0000</pubDate>
         <description>Tagged with #popmatrix - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23popmatrix/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Array problem (cube grid)</title>
      <link>https://forum.processing.org/two/discussion/14932/array-problem-cube-grid</link>
      <pubDate>Mon, 15 Feb 2016 19:05:57 +0000</pubDate>
      <dc:creator>PoYo</dc:creator>
      <guid isPermaLink="false">14932@/two/discussions</guid>
      <description><![CDATA[<p>I've been trying to put the boxes in an order like the way in the picture but so far all the attempts failed.
I can use some help from here ^^. It works when i just use random position but I need them as a grid.</p>

<p><a rel="nofollow" href="https://www.dropbox.com/s/o4uqt074bx8mjo9/saved.png?dl=0">https://dropbox.com/s/o4uqt074bx8mjo9/saved.png?dl=0</a></p>

<pre><code>ArrayList&lt;Cube&gt; myCubes = new ArrayList&lt;Cube&gt;();

void setup() {
  size(800, 800, P3D);
  frameRate(60);
  for (int i = 0; i &lt; 30; i++){
    myCubes.add(new Cube());
  }

}

void draw() {
  background(0);
  for (Cube myCube : myCubes) {
    myCube.display();
  }
}

class Cube {
  PImage tex, tex1, tex2, tex3, tex4, tex5;
  float x;
  float y;
  float scale;

  public Cube() {
    this.x = random(width);
    this.y = random(height);
    this. scale = 30;

    tex = loadImage("image0.jpg");
    tex1 = loadImage("image1.jpg");
    tex2 = loadImage("image2.jpg");
    tex3 = loadImage("image3.jpg");
    tex4 = loadImage("image4.jpg");
    tex5 = loadImage("image5.jpg");
  }

  void display() {
    noStroke();
    pushMatrix();
    translate(x, y, 0);
    rotateY(map(mouseX, 0, width, 0, PI));
    rotateX(map(mouseY, 0, height, 0, PI));
    scale(scale);


    textureMode(NORMAL);

    beginShape(QUADS);
    texture(tex);

    // +Z "front" face
    vertex(-1, -1, 1, 0, 0);
    vertex( 1, -1, 1, 1, 0);
    vertex( 1, 1, 1, 1, 1);
    vertex(-1, 1, 1, 0, 1);
    endShape();
    beginShape(QUADS);
    // -Z "back" face
    texture(tex1);
    vertex( 1, -1, -1, 0, 0);
    vertex(-1, -1, -1, 1, 0);
    vertex(-1, 1, -1, 1, 1);
    vertex( 1, 1, -1, 0, 1);

    endShape();
    beginShape(QUADS);
    // +Y "bottom" face
    texture(tex2);
    vertex(-1, 1, 1, 0, 0);
    vertex( 1, 1, 1, 1, 0);
    vertex( 1, 1, -1, 1, 1);
    vertex(-1, 1, -1, 0, 1);

    endShape();
    beginShape(QUADS);
    // -Y "top" face
    texture(tex3);
    vertex(-1, -1, -1, 0, 0);
    vertex( 1, -1, -1, 1, 0);
    vertex( 1, -1, 1, 1, 1);
    vertex(-1, -1, 1, 0, 1);

    endShape();
    beginShape(QUADS);
    // +X "right" face
    texture(tex4);
    vertex( 1, -1, 1, 0, 0);
    vertex( 1, -1, -1, 1, 0);
    vertex( 1, 1, -1, 1, 1);
    vertex( 1, 1, 1, 0, 1);

    endShape();
    beginShape(QUADS);
    // -X "left" face
    texture(tex5);
    vertex(-1, -1, -1, 0, 0);
    vertex(-1, -1, 1, 1, 0);
    vertex(-1, 1, 1, 1, 1);
    vertex(-1, 1, -1, 0, 1);
    endShape();
    popMatrix();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>PMatrices Broken in Processing 2.1.1 on Windows?</title>
      <link>https://forum.processing.org/two/discussion/4533/pmatrices-broken-in-processing-2-1-1-on-windows</link>
      <pubDate>Sat, 19 Apr 2014 13:48:16 +0000</pubDate>
      <dc:creator>benvancitters</dc:creator>
      <guid isPermaLink="false">4533@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to build a sketch that involves a lot re-orientation of points; I need to move and rotate some points and then measure those points against un-rotated, un-translated and un-scaled points.  The most sensible and straightforward-seeming approach to me would be to do something like rotate/translate/scale to my destination, record the current matrix, and then multiply my points in my data structure to get in place 3D relationships.  This, however, doesn't appear to work as advertised.</p>

<p>In theory, if I manipulate the matrix stack (with translations, rotations, and scaling), draw something, say an ellipse, record the current matrix, pop out of the stack (or otherwise reset the current matrix), and then apply my recorded matrix and draw an identical ellipse, they should draw on top of one another.  This isn't what happens on my machine.  Why?</p>

<p>Here is an example sketch that, using the above algorithm, should draw two ellipses on top of one another.</p>

<pre><code>void setup(){
  size(100,100,P3D);  
}

void draw(){
  background(0);
  //draw first ellipse
  noFill();  stroke(255);
  pushMatrix();
    translate(width/2,height/2);
    rotateX(millis()/2000.f);
    PMatrix3D pMat = new PMatrix3D();
    getMatrix(pMat); //record current matrix
    ellipse(0,0,50,50);
  popMatrix();

  //draw second ellipse
  fill(255,0,0);  noStroke();
  pushMatrix();
    applyMatrix(pMat);
    ellipse(0,0,50,50);
  popMatrix();
}
</code></pre>

<p>This simple test fails on windows in the 64bit Processing 2.1.1, why?</p>
]]></description>
   </item>
   <item>
      <title>Image matching</title>
      <link>https://forum.processing.org/two/discussion/9322/image-matching</link>
      <pubDate>Fri, 06 Feb 2015 22:39:24 +0000</pubDate>
      <dc:creator>Quiznos92</dc:creator>
      <guid isPermaLink="false">9322@/two/discussions</guid>
      <description><![CDATA[<p>Hi there. I'm a little new to processing, only been using it for two months now and I got this basic code running and all. But there's one thing I want to do that I'm not sure of how to do.</p>

<p>I want to create a delay of some sort for the images. It's supposed to be like a memory game with cards and right now it's only one click one card but I want to keep one image open and have a second one revealed and then disappear (with redraw). Even if it's an artificial delay, anything will do. Here's my code that does run successfully with one card revealed at a time. 
The goal: Two cards revealed and then back to hiding. 
Thank you all so much.</p>

<pre><code>PImage[] images = new PImage[8];
PFont f;

void setup() {
  size(1000, 600);
  noFill();
  smooth();
  f = createFont("Arial", 20, true);
  for (int i=0; i &lt; images.length; i++) {
    images[0] = loadImage("Art.png");
    images[1] = loadImage("Brain.png");
    images[2] = loadImage("Cat.png");
    images[3] = loadImage("Dog.jpg");
    images[4] = loadImage("Movie.png");
    images[5] = loadImage("Music.png");
    images[6] = loadImage("Phone.png");
    images[7] = loadImage("Psych.gif");
    noLoop();
  }
}
void draw() {
  background(0);
  fill(255);
  rect(25, 10, 200, 250); //rectangle at 25
  pushMatrix();
  translate(200, 0);
  rect(50, 10, 200, 250); //rectangle at 250
  translate(200, 0);
  rect(75, 10, 200, 250); // rectangle at 475
  translate(200, 0);
  rect(100, 10, 200, 250); //rectangle at 700
  popMatrix();
  rect(25, 280, 200, 250); //rectangle at 25
  pushMatrix();
  translate(200, 0);
  rect(50, 280, 200, 250);
  translate(200, 0);
  rect(75, 280, 200, 250);
  translate(200, 0);
  rect(100, 280, 200, 250);
  popMatrix();
  if (mousePressed == mouseX &lt; 225 &amp;&amp; mouseX &gt; 0 &amp;&amp; mouseY &gt; 0 &amp;&amp; mouseY &lt; 250) {
    image(images[(int)random(8)], 25, 10);
  }
  if (mousePressed == mouseX &lt; 450 &amp;&amp; mouseX &gt; 250 &amp;&amp; mouseY &gt; 0 &amp;&amp; mouseY &lt; 250) {
    image(images[(int)random(8)], 250, 10);
  }
  if (mousePressed == mouseX &lt; 675 &amp;&amp; mouseX &gt; 475 &amp;&amp; mouseY &gt; 0 &amp;&amp; mouseY &lt; 250) {
    image(images[(int)random(8)], 475, 10);
  }
  if (mousePressed == mouseX &lt; 1000 &amp;&amp; mouseX &gt; 700 &amp;&amp; mouseY &gt; 0 &amp;&amp; mouseY &lt; 250) {
    image(images[(int)random(8)], 700, 10);
  }
  if (mousePressed == mouseX &lt; 225 &amp;&amp; mouseX &gt; 0 &amp;&amp; mouseY &gt; 280 &amp;&amp; mouseY &lt; 500) {
    image(images[(int)random(8)], 25, 280);
  }
  if (mousePressed == mouseX &lt; 450 &amp;&amp; mouseX &gt; 250 &amp;&amp; mouseY &gt; 280 &amp;&amp; mouseY &lt; 500) {
    image(images[(int)random(8)], 250, 280);
  }
  if (mousePressed == mouseX &lt; 675 &amp;&amp; mouseX &gt; 475 &amp;&amp; mouseY &gt; 280 &amp;&amp; mouseY &lt; 500) {
    image(images[(int)random(8)], 475, 280);
  }
  if (mousePressed == mouseX &lt; 1000 &amp;&amp; mouseX &gt; 700 &amp;&amp; mouseY &gt; 280 &amp;&amp; mouseY &lt; 500) {
    image(images[(int)random(8)], 700, 280);
  }
  textFont(f, 32);
  fill(255);
  text("Match The Pictures",325, 575); 
}
void mousePressed() {
  redraw();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Scaled (mirrored) PImage isn't rendering?</title>
      <link>https://forum.processing.org/two/discussion/7457/scaled-mirrored-pimage-isn-t-rendering</link>
      <pubDate>Sun, 05 Oct 2014 22:52:34 +0000</pubDate>
      <dc:creator>marghost</dc:creator>
      <guid isPermaLink="false">7457@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to mirror a PImage using pop/push matrix and scale in order to create a pattern, but the only scale that renders is scale(1,1) - the other three don't show up or are transparent or something. Here is what it looks like:</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/750/ULXYLGG21W7U.png" alt="Screen Shot 2014-10-05 at 7.42.10 PM" title="Screen Shot 2014-10-05 at 7.42.10 PM" /></p>

<p>There shouldn't be gray there? I have no idea what the issue is and I can't find anyone else who's already posted this problem on the internet, but apologies if the answer is out there and I've been searching by the wrong terms or something. Here is my code, relevant bit is at the bottom:</p>

<pre><code>    PImage img; 
    PImage destination;
    FloatList sBlob;

    void setup() {
      img = loadImage("prince-street-bike-lane.jpg");
      destination = createImage(150,150, HSB);
      size(1000, 1000);
      colorMode(HSB, 360, 100, 100);
      sBlob = new FloatList();

      img.loadPixels();
      float highestAverage = 0;
      int highestLocStart = 0;
      float blobAverage = 0;
      float satch = 0;
      int loc = 0;
      int sloc = 0;

      for (int x = 0; x &lt; img.width - destination.width; x++) {
        for (int y = 0; y &lt; img.height - destination.height; y++ ) {
          blobAverage = 0;
          loc = x + y*img.width;
          sBlob.clear();

          for (int sx = 0; sx &lt; destination.width; sx++) {
            for (int sy = 0; sy &lt; destination.height; sy++ ) {
              sloc = loc + sx + sy*img.width;
              satch = saturation(img.pixels[sloc]);
              sBlob.append(satch);
            }
          }
          for (int i = 0; i &lt; sBlob.size(); i++) {
            blobAverage += sBlob.get(i);
          }
          blobAverage = blobAverage/sBlob.size();
          if (blobAverage &gt; highestAverage){
            highestAverage = blobAverage;
            highestLocStart = loc;
          }
          print(x + " ");
        }
      }

      for (int x = 0; x &lt; destination.width; x++) {
        for (int y = 0; y &lt; destination.height; y++ ) {
          int dloc = x + y*destination.width;
          int iloc = (x + y*img.width) + highestLocStart;
          float h = hue(img.pixels[iloc]);
          float s = saturation(img.pixels[iloc]);
          float b = brightness(img.pixels[iloc]);
          destination.pixels[dloc]  = color(h,s,b);
        }
      }

      destination.updatePixels();

      int sx = -1;
      int sy = -1;
      for (int x = 0; x &lt; width; x += destination.width) {
        sx *= -1;
        for (int y = 0; y &lt; height; y += destination.height) {
          sy *= -1;
          pushMatrix();
          scale(sx, sy);
          image(destination,x,y);
          popMatrix();
        }
      }
    }
</code></pre>

<p>I'm not super experienced so if you think I'm going about this code in completely the wrong way, feel free to make suggestions. I'm on a mac with current OS and using processing 2.2.1.</p>
]]></description>
   </item>
   </channel>
</rss>