<?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 #pushmatrix - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23pushmatrix</link>
      <pubDate>Sun, 08 Aug 2021 19:09:53 +0000</pubDate>
         <description>Tagged with #pushmatrix - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23pushmatrix/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>push();</title>
      <link>https://forum.processing.org/two/discussion/10611/push</link>
      <pubDate>Fri, 01 May 2015 17:25:38 +0000</pubDate>
      <dc:creator>Byrie</dc:creator>
      <guid isPermaLink="false">10611@/two/discussions</guid>
      <description><![CDATA[<p>Sometimes I have a hard time using this function</p>
]]></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>
   <item>
      <title>Understanding the concept of a matrix stack</title>
      <link>https://forum.processing.org/two/discussion/5022/understanding-the-concept-of-a-matrix-stack</link>
      <pubDate>Sat, 10 May 2014 10:22:25 +0000</pubDate>
      <dc:creator>hellocatfood</dc:creator>
      <guid isPermaLink="false">5022@/two/discussions</guid>
      <description><![CDATA[<p>The reference page for pushMatrix() states</p>

<blockquote class="Quote">
  <p>that Understanding pushMatrix() and popMatrix() requires understanding the concept of a matrix stack.</p>
</blockquote>

<p>Where can I learn more about matrix stacks?</p>
]]></description>
   </item>
   </channel>
</rss>