<?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=pushmatrix%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:43:20 +0000</pubDate>
         <description>Tagged with pushmatrix() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedpushmatrix%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>can anyone help with pushmatrix?</title>
      <link>https://forum.processing.org/two/discussion/28131/can-anyone-help-with-pushmatrix</link>
      <pubDate>Tue, 02 Oct 2018 21:50:25 +0000</pubDate>
      <dc:creator>laptophead</dc:creator>
      <guid isPermaLink="false">28131@/two/discussions</guid>
      <description><![CDATA[<p>I am modeling this robotic arm and it looks great.</p>

<p>I am also trying to display each angle next to each point of inflexion. 
In the case of the elbow, I am trying to move the text with the elbow position along with the inflexion point. 
That works, but I cant find a method to keep the writing horisontal.
It rotates with the first segment angle...</p>

<p>here is my function</p>

<p>thanks</p>

<p>void ArmDepiction()</p>

<p>{  ///////////////////////////Base orientation</p>

<p>fill(201, 0, 211); // magenta
  //text("Y:", LS, spaceDown*3 ); 
  text( (nf(degrees(BaseAngRad), 0, 1)), 630, 1050);
  //text( "0", 85, 0);</p>

<p>strokeWeight(10);
stroke(238,242, 0);
noFill ();</p>

<p>// Form: arc(x, y, width, height, start, stop, type);
arc(550, 1000, 100, 100, (PI/2), (BaseAngRad+(PI/2)), PIE);
//stroke(#71B28F);
//arc(100, 1000, 175, 175, 0, 2*PI, 0);</p>

<p>//drawArrow(100,160,50,130);</p>

<p>///////////////////////Arm Depiction
  strokeWeight(40);
  stroke(255, 160);
  strokeCap(ROUND);</p>

<p>float x, y;</p>

<p>x = 550;
  y = 800;</p>

<p>pushMatrix();
  strokeWeight(40);
  segment(x, y, PI+ShoAngRad); 
  strokeWeight(30);
  segment1(segLength, 0, PI+ElbowAngRad); // 120 is the starting point
  segment3(segLength, 0, (2*PI)+ElbowAngRad-0.58); // 100 is the segment length
  popMatrix();</p>

<p>translate(x, y);
strokeWeight(10);
strokeJoin(ROUND);
   beginShape();
  vertex(-40, 0);</p>

<p>vertex(-65, segLength);
  vertex(65, segLength);</p>

<p>vertex(40, 0);
  endShape(CLOSE);</p>

<p>DisplayElAngle(x, y);</p>

<p>}</p>

<p>void segment(float x, float y, float a) {
  translate(x, y);
  fill(201, 0, 211); // magenta
  //text("Y:", LS, spaceDown*3 ); 
  text( (nf(degrees(ShoAngRad), 0, 1)), 30, 0);
  //text( "0", 85, 0);
  noFill ();</p>

<p>rotate(a);
  line(0, 0, segLength, 0); // 100 is the segment length</p>

<p>}</p>

<p>void DisplayElAngle(float x, float y) {
  translate(x, y);
  rotate(2<em>PI);
    fill(201, 0, 211); // magenta
  //text("Y:", LS, spaceDown</em>3 ); 
 text( (nf(degrees(ElbowAngRad), 0, 1)), 20, -10);
  noFill ();
 //</p>

<p>}
void segment1(float x, float y, float a) {
  translate(x, y);
    fill(201, 0, 211); // magenta
  //text("Y:", LS, spaceDown*3 ); 
 text( (nf(degrees(ElbowAngRad), 0, 1)), 20, -10);
  noFill ();
  rotate(a);
  line(0, 0, segLength, 0); // 100 is the segment length
   // rotate(a);</p>

<p>}</p>

<p>void segment3(float x, float y, float a) {
  translate(x, y);
  rotate(a);
  line(0, 0, (segLength/5), 0); // 100 is the segment length</p>

<p>}</p>
]]></description>
   </item>
   <item>
      <title>How to progressively draw a fractal tree</title>
      <link>https://forum.processing.org/two/discussion/28105/how-to-progressively-draw-a-fractal-tree</link>
      <pubDate>Mon, 27 Aug 2018 09:35:39 +0000</pubDate>
      <dc:creator>Emanuele</dc:creator>
      <guid isPermaLink="false">28105@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone, I need to do a school project and I want to build a fractal tree that progressively "grows" using the mouse. how can I do it? this is the code I built:</p>

<pre><code>void setup() 
{

        fullScreen();

 }

int levelsMin = 0;
    int levelsMax = 6;
    float initialLength = 235;

    float angleMin = PI/17;
    float angleMax = PI/10;

    int pointColor = color(27, 25, 9);

   void draw() {


        background(color(245,247,232));
        stroke(88, 50, 0);
        strokeWeight(7);

        float currentAngle = map (mouseX, 0, width, angleMin, angleMax); //mouse control of the branch angle
        int currentLevels = (int)map (mouseY, height,0, levelsMin, levelsMax); //mouse control of the generations count

        pushMatrix(); //save the world transformation matrix
        translate (width/2, height); //move the origin to the middle / bottom
       albero (currentLevels, initialLength, currentAngle); //draw first two branches - stems
        popMatrix(); //return to the world coordinate system
    }

    void albero (int levels, float length, float angle){
        if (levels&gt;0){  //check if there are any levels left to render
            //destra
            pushMatrix();           //save current transformation matrix
            rotate (angle);         //rotate new matrix to make it point to the right
            line (0,0,0,-length);   //draw line "upwards"
            pushMatrix();           //save current (e.g. new) matrix
            translate(0,-length);   //move the origin to the branch end
            scale (0.85f);          //scale down. fun fact - it scales down also the stroke weight!
           albero (levels-1, length, angle);  //call the recursive function again
            popMatrix();            //return to the matrix of the current line
            popMatrix();            //return to the original matrix
            //second branch - the same story
            pushMatrix();
            rotate (-angle/1.7);
            line (0,0,0,-length);
            pushMatrix();
            translate(0,-length);
            scale (0.85f);
            albero (levels-1, length, angle);
            popMatrix();
            popMatrix();


        }

    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Rotating objects in a class</title>
      <link>https://forum.processing.org/two/discussion/26998/rotating-objects-in-a-class</link>
      <pubDate>Thu, 22 Mar 2018 19:52:34 +0000</pubDate>
      <dc:creator>AndrijanaK</dc:creator>
      <guid isPermaLink="false">26998@/two/discussions</guid>
      <description><![CDATA[<p>Hello everybody,
I am relatively new to Processing and have come up against a problem that I don't know how to solve. Can anyone please tell me what is the best way to code multiple objects, array of objects, where that object is constructed as a class a manipulate with them through rotation. I wish that every entity individually can be rotated depending on movements of the mouse. Thank you in advance for any help.</p>
]]></description>
   </item>
   <item>
      <title>How to "build" a triangle shape in the source code and paste a copy of it at sketch position (x,y)</title>
      <link>https://forum.processing.org/two/discussion/26245/how-to-build-a-triangle-shape-in-the-source-code-and-paste-a-copy-of-it-at-sketch-position-x-y</link>
      <pubDate>Mon, 05 Feb 2018 18:18:05 +0000</pubDate>
      <dc:creator>KleinerBrandy</dc:creator>
      <guid isPermaLink="false">26245@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone,</p>

<p>I am looking for a way to "build" a triangle shape (isosceles triangle) where I can specify the start point a (a1,a2), the length of the vertical direction towards the hypotenuse, and the length of the hypotenuse.</p>

<p>I then want to paste multiple triangles from that master shape into the sketch at positions I specify just with a point and the rotation of the triangle. For example 4 triangles in the middle of each side with the hypotenuse facing towards the middle of the sketch.</p>

<pre><code>position1(  0 , height/2 ) with 90° rotation
position2( width/2 , 0 ) with 0° rotation
position3( width , height/2 ) with 180° rotation
position4( width/2 , height ) with 270° rotation
</code></pre>

<p>Any help is strongly appreciated.</p>

<p>Thanks a lot.</p>
]]></description>
   </item>
   <item>
      <title>Why did this happen? (grid, cumulative rotations)</title>
      <link>https://forum.processing.org/two/discussion/23161/why-did-this-happen-grid-cumulative-rotations</link>
      <pubDate>Wed, 21 Jun 2017 21:42:35 +0000</pubDate>
      <dc:creator>gdsouza</dc:creator>
      <guid isPermaLink="false">23161@/two/discussions</guid>
      <description><![CDATA[<p>I was making a simple grid, but I did something wrong, I found the result interesting, so I changed some things and ended up with this,</p>

<p>I wonder if this is a bug, if not why does this happen?</p>

<pre><code>float rate;

void setup(){
   size(screen.width, screen.height, P2D);
}

void draw(){
   background(0);
   translate(width/2, height/2);
   for (int i = 0; i &lt; 270; i += 1) {
     for (int j = 0; j &lt; 270; j += 1) {
       rotate(rate);    
       stroke(255);  
       point(i, j);
     }
   } 
   //rate += 100;   
   //Nice patterns
   rate += 0.001;   
   //Ever increasing spiral
   //rate += 0.0001;  
   //Weird thing
   //rate += 0.0000001;
}
</code></pre>
]]></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>how to make only *one* image rotate?</title>
      <link>https://forum.processing.org/two/discussion/21418/how-to-make-only-one-image-rotate</link>
      <pubDate>Wed, 15 Mar 2017 17:46:47 +0000</pubDate>
      <dc:creator>mdobbe</dc:creator>
      <guid isPermaLink="false">21418@/two/discussions</guid>
      <description><![CDATA[<p>Hey there! I'm writing some pretty simple code as the basis for a small interactive game. So far I'm just working on getting the background to function properly. What I am trying to do is have the "wheel" image (the color wheel) rotate every time the mouse is clicked. HOWEVER the way it is written right now the wheel does not rotate at all, and instead the "bg" image above it, which I want to remain static, is the one the rotates. Here are some pictures of what that looks like, with questions and code below:
<img src="https://forum.processing.org/two/uploads/imageupload/099/XO5GNNTXC6H0.JPG" alt="calendar1" title="calendar1" />
<img src="https://forum.processing.org/two/uploads/imageupload/781/741I6Q8AHT7L.JPG" alt="calendar2" title="calendar2" /> <br /></p>

<p>So I have a few questions:<br />
1) How do I write it so that the wheel image is the one that rotates?<br />
2) Why does the bg image that is incorrectly rotating rotating from the (0,0) position instead of the center, when I specified imageMode(CENTER)?<br />
3) How would you recommend making the image rotate once per click, instead of whenever the mouse is pressed?<br /></p>

<p>Here's my code:</p>

<blockquote class="Quote">
  <p>PImage bg; <br />
  PImage wheel;<br />
  float x = width;<br />
  float y = height;<br />
  int a = 0;<br />
  <br />
  void setup() {<br />
    background(255);<br />
    size(750, 500);<br />
    imageMode(CENTER);<br />
    bg = loadImage("bg1.png");<br />
    wheel = loadImage("colorwheel.png");<br />
  }<br />
  void draw() {<br />
    background(255);<br />
     if(mousePressed){<br />
      a = (a+1);<br />
    }<br />
    wheel(750,0,a);<br />
    image(bg, 375, 250);<br />
  }<br />
  void wheel(int xloc, int yloc, int angle){<br />
      image(wheel, xloc, yloc);<br />
      rotate(angle);<br />
  }<br />
  <br />
  Thank you!</p>
</blockquote>
]]></description>
   </item>
   <item>
      <title>too many calls to popMatrix and issues generating text (Eclipse IDE)</title>
      <link>https://forum.processing.org/two/discussion/19701/too-many-calls-to-popmatrix-and-issues-generating-text-eclipse-ide</link>
      <pubDate>Mon, 12 Dec 2016 16:38:11 +0000</pubDate>
      <dc:creator>JDev</dc:creator>
      <guid isPermaLink="false">19701@/two/discussions</guid>
      <description><![CDATA[<p>I'm developing a Processing view (with v2.2.1 that still extends Applet). I use some pushMatrix()/popMatrix() to do transformations and to represent composite objects (I'm aware of the 32 depth matrix stack limit and relatively sure I don't reach that depth in composition and/or successive transformations or dont pair push and pops properly).</p>

<p>So far I didn't have any unexpected issue, but after introducing yet another component(not the first text enabled component at all), I'm starting to occasionally get errors like these:</p>

<p>The font size is too large to be properly displayed with OpenGL</p>

<p>Exception in thread "Animation Thread" java.lang.RuntimeException: Image width and height cannot be larger than 0 with this graphics card. at processing.opengl.Texture.setSize(Texture.java:1148) at processing.opengl.Texture.init(Texture.java:213) at processing.opengl.Texture.(Texture.java:160) at processing.opengl.FontTexture.addTexture(FontTexture.java:134) at processing.opengl.FontTexture.initTexture(FontTexture.java:103) at processing.opengl.FontTexture.(FontTexture.java:71) at processing.opengl.PGraphicsOpenGL.textLineImpl(PGraphicsOpenGL.java:3602) at processing.core.PGraphics.textLineAlignImpl(PGraphics.java:4659) at processing.core.PGraphics.text(PGraphics.java:4356) at processing.core.PGraphics.text(PGraphics.java:4307) at processing.core.PApplet.text(PApplet.java:13183) at ygg.desktop.vm.extVM.MetadataProcessingVM.render(MetadataProcessingVM.java:81) at ygg.desktop.vm.extVM.MetadataProcessingVM.render(MetadataProcessingVM.java:88) at ygg.desktop.vm.groups.TreeLayout.render(TreeLayout.java:43) at ygg.desktop.vm.groups.RenderArea.render(RenderArea.java:167) at ygg.desktop.view.MainView.draw(MainView.java:179) at processing.core.PApplet.handleDraw(PApplet.java:2386) at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240) at processing.core.PApplet.run(PApplet.java:2256) at java.lang.Thread.run(Thread.java:745)
which refers to (note that I get it both on first and second text on different runs) *father is the PApplet instance</p>

<pre><code>      father.pushMatrix();
      father.translate(posX, posY+8);

      father.rotate(-father.HALF_PI);

      father.fill(father.color(30,30,30));
      father.textAlign(father.CENTER);
      father.textSize(16);
      **father.text(md.getId()!=null?md.getId():"NONE",-(finalY-posY)/2,width/2);**
      father.fill(father.color(220,220,50));
      father.textSize(12);
      **father.text(md.getId()!=null?md.getId():"NONE",-(finalY-posY)/2,width/2);**

      father.popMatrix();
</code></pre>

<p>or</p>

<p>Exception in thread "Animation Thread" java.lang.RuntimeException: Too many calls to popMatrix(), and not enough to pushMatrix(). at processing.opengl.PGraphicsOpenGL.popMatrix(PGraphicsOpenGL.java:3811) at processing.core.PApplet.popMatrix(PApplet.java:13322) at ygg.desktop.vm.extVM.MetadataProcessingVM.render(MetadataProcessingVM.java:72) at ygg.desktop.vm.groups.TreeLayout.render(TreeLayout.java:43) at ygg.desktop.vm.groups.TreeLayout.render(TreeLayout.java:46) at ygg.desktop.vm.groups.TreeLayout.render(TreeLayout.java:46) at ygg.desktop.vm.groups.RenderArea.render(RenderArea.java:167) at ygg.desktop.view.MainView.draw(MainView.java:180) at processing.core.PApplet.handleDraw(PApplet.java:2386) at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240) at processing.core.PApplet.run(PApplet.java:2256) at java.lang.Thread.run(Thread.java:745)
on</p>

<pre><code>      father.pushMatrix();
      father.translate(posX, posY+8);
      father.rotate(-father.HALF_PI);
      father.fill(father.color(30,30,30));
      father.textAlign(father.CENTER);
      father.textSize(16);

      father.text(md.getId()!=null?md.getId():"NONE",-(finalY-posY)/2,width/2);
      father.fill(father.color(220,220,50));
      father.textSize(12);
      father.text(md.getId()!=null?md.getId():"NONE",-(finalY-posY)/2,width/2);      
      **father.popMatrix();**
}
</code></pre>

<p>I am no expert in OpenGl and/or Processing at all, so I was wondering how can successive executions (with no previous jvm left open) lead to different outcomes without any random element in my code (apparently if the application doesnt crash immediately it keeps working no matter how many objects I create), also I don't understand how can I get that exception on popMatrix right after a push given that all the calls are in the draw cycle and of course no thread (that I'm aware) there.</p>

<p>Before proceeding I would like to know what am I getting so wrong (if it as already transpired) and what could I do to achieve stability at each run, also I would like to know if multiple instances of PApplet clients will necessarly confict with each others.</p>
]]></description>
   </item>
   <item>
      <title>One-time translation for sketch setup?</title>
      <link>https://forum.processing.org/two/discussion/18056/one-time-translation-for-sketch-setup</link>
      <pubDate>Fri, 02 Sep 2016 23:25:31 +0000</pubDate>
      <dc:creator>jeremydouglass</dc:creator>
      <guid isPermaLink="false">18056@/two/discussions</guid>
      <description><![CDATA[<p>I want to set up a Processing sketch with a <strong>one-time</strong> translation. Is this possible?</p>

<p>To be clear, I already know how to achieve a sketch-wide translation effect (see below). What I want to know if there are ways to translate <strong>once</strong> efficiently (i.e. without constant push-pop-ing) and clearly (e.g. defining a setup translation in <code>setup()</code> or somewhere else outside the <code>draw()</code> loop.).</p>

<p>So, given this sketch of an upper-left rectangle:</p>

<pre><code>void draw(){
  rect(0,0,10,10);
}
</code></pre>

<p>...I want to shift everything once, then program the sketch within the translated frame of reference. The <a rel="nofollow" href="https://processing.org/reference/translate_.html">translate() documentation</a> says "If translate() is called within draw(), the transformation is reset when the loop begins again." -- which implied to me that calling <code>translate()</code> from before draw in <code>setup()</code> would not reset the translation. That approach does not appear to work, however:</p>

<pre><code>void setup(){
  //// THIS DOES NOT WORK
  translate(20,20);
}
void draw(){
  rect(0,0,10,10);
}
</code></pre>

<p>I'm not sure why it doesn't work. My best guess is that setup's translate is cleared at the end of the first draw loop. I also tried a <code>setup()</code> with <code>translate()</code> followed by a single <code>pushMatrix()</code> -- this doesn't work either, perhaps because the end of the draw loop clears the entire matrix stack.</p>

<p>The common working example I see is to push-and-pop every single draw loop, like this:</p>

<pre><code>void draw(){
 pushMatrix();
   translate(20,20);
   rect(0,0,10,10);
 popMatrix();
}
</code></pre>

<p>That creates the desired effect, but it pushes-and-pops n times a second to no purpose -- I just want to setup the translation once.</p>

<p>I've also seen some examples of using <code>pushMatrix()</code> from <code>setup()</code>, then using an inverted <code>popMatrix()</code>/<code>pushMatrix()</code> loop to retrieve it in the draw (e.g. for recording cumulative translations), like this:</p>

<pre><code>void setup(){
  translate(20,20);
  pushMatrix();
}
void draw(){
  popMatrix();
  rect(0,0,10,10);
  pushMatrix();
}
</code></pre>

<p>...and, like the previous example, that creates the desired effect, but again it pushes-and-pops n times a second for no reason.</p>

<p>Are there other ways to define a one-time translation? Any suggestions or feedback would be appreciated!</p>
]]></description>
   </item>
   <item>
      <title>Keepin 0,0 translate on Cp5-elements but not on the rest.</title>
      <link>https://forum.processing.org/two/discussion/17824/keepin-0-0-translate-on-cp5-elements-but-not-on-the-rest</link>
      <pubDate>Thu, 11 Aug 2016 15:17:14 +0000</pubDate>
      <dc:creator>albinchr</dc:creator>
      <guid isPermaLink="false">17824@/two/discussions</guid>
      <description><![CDATA[<p>I would like to pushMatrix before the translate statement and pop it after the text statement. But it's no possible. Is there another way to keep the cp5 elements from listening to the translate(400, 400) and make them (0,0)</p>

<blockquote class="Quote">
  <p>import controlP5.*;
  ControlP5 cp5;</p>
</blockquote>

<p>public float sliderBredd = 0;
public float sliderHojd = 0;</p>

<p>PFont myFont;</p>

<p>void setup() {
  size(800, 800);
  cp5 = new ControlP5(this);</p>

<p>cp5.addSlider("sliderBredd")
    .setRange(-255, 255)
    .setPosition(40, 40)
    .setSize(200, 29)
    ;</p>

<p>cp5.addSlider("sliderHojd")
    .setRange(-255, 255)
    .setPosition(40, 80)
    .setSize(200, 29)
    ;
}</p>

<p>void draw () {
  background(255, 255, 255);
  myFont = createFont("Times-Roman", 48);
  textFont(myFont, 272);
  translate(400, 400);</p>

<p>for (int i=0; i&lt;12; i=i+1) {</p>

<pre><code>fill(14, 105, 237);
textAlign(CENTER);
rotate(PI*1/3);
text("Q", sliderBredd, sliderHojd);
</code></pre>

<p>}
}</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>Moving scenes</title>
      <link>https://forum.processing.org/two/discussion/15634/moving-scenes</link>
      <pubDate>Tue, 22 Mar 2016 21:36:00 +0000</pubDate>
      <dc:creator>c_vzqz</dc:creator>
      <guid isPermaLink="false">15634@/two/discussions</guid>
      <description><![CDATA[<p>This is a homework assignment that I have. I have to create 4 different scenes, in all, they must have 2 animal objects and 4 other objects. I have to have the animals move in every scene and one object move in one scene. I am trying to get the seagull to fly straight across. Is there any way to group all the parts of the seagull to only have to code once or do i have to code every single part i've made?</p>

<pre><code>    PImage img;                    // Declare variable "img" of type PImage

    float xPosition = 100;                    
    float xSpeed = 2.9;             
    float object = 30;
    float top, bottom, left, right; 

    void setup() {
      fullScreen();                          // use fullScreen() instead of size()
      background( 0 );
      img = loadImage("http:" + "//eskipaper.com/images/beach-background-4.jpg");     // Load the image into the program
      imageMode( CENTER );                   // position the center, not upper right, of the image
      colorMode(HSB, 100);                        // hue, sat, brightness color system
    }

    void draw() {

      background( 0 );
      tint(0, 0, 360, 255);                             // Display full opacity no color tint
      image(img, width/2, height/2);                    // Display at full opacity
      xPosition = xPosition + xSpeed;

        if ( xPosition &lt; left ) {             
        xSpeed = xSpeed * -1;
      } else if ( xPosition &gt; right ) {
        xSpeed = xSpeed * -1;
      }

      //Turtle  
      noFill();
      stroke(33, 86, 32);
      strokeWeight(8);
      strokeCap(ROUND);
      strokeJoin(ROUND);
      line(300, 800, 350, 770 );                          //Create right top fin
      noFill();
      stroke(33, 86, 32);
      strokeWeight(8);
      strokeCap(ROUND);
      strokeJoin(ROUND);
      line(300, 800, 350, 830 );                          //Create right bottom fin
      noFill();
      stroke(33, 86, 32);
      strokeWeight(8);
      strokeCap(ROUND);
      strokeJoin(ROUND);
      line(300, 800, 250, 770 );                          //Create left top fin
      noFill();
      stroke(33, 86, 32);
      strokeWeight(8);
      strokeCap(ROUND);
      strokeJoin(ROUND);
      line(300, 800, 250, 830 );                          //Create left bottom fin
      fill(10, 86, 32);
      noStroke();
      ellipse(300, 800, 80, 60);                          //Create brown shell
      fill(33, 86, 32);
      noStroke();
      ellipse(350, 800, 40, 30);                          //Create head
      ellipseMode(RADIUS);
      noStroke();
      fill(100);
      ellipse(350, 807, 3, 3);
      ellipseMode(CENTER);
      stroke(0);
      strokeWeight(2);
      fill(100);
      ellipse(350, 807, 2, 2);                              //Create bottom eye
      ellipseMode(RADIUS);
      noStroke();
      fill(100);                                 
      ellipse(350, 793, 3, 3);
      ellipseMode(CENTER);  
      stroke(0);
      strokeWeight(2);
      fill(100);
      ellipse(350, 793, 2, 2);                              //Create top eye

     //Boat 1
     noStroke();
     fill(70, 50, 80);
     bezier(300, 630, 380, 675, 410, 675, 490, 630);        //Hull
     stroke(0);
     strokeWeight(2);
     fill(100);
     ellipse(370, 645, 8, 8);                               //Create left window
     stroke(0);
     strokeWeight(2);
     fill(100);
     ellipse(395, 645, 8, 8);                               //Create center window
     stroke(0);
     strokeWeight(2);
     fill(100);
     ellipse(420, 645, 8, 8);                               //Create right window
     stroke(0);
     strokeWeight(6);
     line(395, 630, 395, 500);                              //Pole
     noStroke();
     fill(100);
     triangle(400, 540, 400, 500, 455, 520);                //Flag

     //Crab
      stroke(0);
      strokeWeight(3);
      strokeCap(ROUND);
      strokeJoin(ROUND);
      line(460, 800, 450, 830 );                          //Create outter left leg
      stroke(0);
      strokeWeight(3);
      strokeCap(ROUND);
      strokeJoin(ROUND);
      line(470, 800, 460, 830 );                          //Create middle left leg
      stroke(0);
      strokeWeight(3);
      strokeCap(ROUND);
      strokeJoin(ROUND);
      line(480, 800, 470, 830 );                          //Create inner left  leg
      stroke(0);
      strokeWeight(3);
      strokeCap(ROUND);
      strokeJoin(ROUND);
      line(540, 800, 550, 830 );                          //Create outter right  leg
      stroke(0);
      strokeWeight(3);
      strokeCap(ROUND);
      strokeJoin(ROUND);
      line(530, 800, 540, 830 );                          //Create middle right leg
      stroke(0);
      strokeWeight(3);
      strokeCap(ROUND);
      strokeJoin(ROUND);
      line(520, 800, 530, 830 );                          //Create inner right  leg
      fill(0, 100 , 100);
      noStroke();
      ellipse(500, 800, 100, 60);                          //Create red body
      noFill();
      stroke(359, 100, 0);
      strokeWeight(6);
      strokeCap(SQUARE);
      strokeJoin(ROUND);
      bezier(470, 800,  440, 785,  440, 770, 470, 755);      //Create left arm
      fill(0, 100 , 100);
      noStroke();
      ellipse(470, 755, 20, 20);                               //Create left claw
      noFill();
      stroke(359, 100, 0);
      strokeWeight(6);
      strokeCap(SQUARE);
      strokeJoin(ROUND);
      bezier(530, 800,  560, 785,  560, 770, 530, 755);      //Create right arm
      fill(0, 100 , 100);
      noStroke();
      ellipse(530, 755, 20, 20);                               //Create left claw
      ellipseMode(RADIUS);
      noStroke();
      fill(100);
      ellipse(480, 800, 3, 3);
      ellipseMode(CENTER);
      stroke(0);
      strokeWeight(2);
      fill(100);
      ellipse(480, 800, 1, 1);                              //Create left eye
      ellipseMode(RADIUS);
      noStroke();
      fill(100);                                 
      ellipse(520, 800, 3, 3);
      ellipseMode(CENTER); 
      stroke(0);
      fill(100);
      ellipse(520, 800, 1, 1);                              //Create right eye

     //Boat 2
     noStroke();
     fill(90, 30, 30);
     bezier(800, 630, 880, 675, 910, 675, 990, 630);        //Hull
     stroke(0);
     strokeWeight(2);
     fill(100);
     ellipse(870, 645, 8, 8);                               //Create left window
     stroke(0);
     strokeWeight(2);
     fill(100);
     ellipse(895, 645, 8, 8);                               //Create center window
     stroke(0);
     strokeWeight(2);
     fill(100);
     ellipse(920, 645, 8, 8);                               //Create right window
     stroke(0);
     strokeWeight(6);
     line(895, 630, 895, 500);                              //Pole
     noStroke();
     fill(100);
     triangle(900, 540, 900, 500, 955, 520);                //Flag

     //Seagull
     noFill();
     strokeCap(ROUND);
     stroke(0);
     strokeWeight(8);
     line(300, 90, 280, 80);                            //Create top wing
     noStroke();
     fill(100);
     ellipse(300, 100, 50, 30);                            //Create body
     noStroke();
     fill(100);
     ellipse(330, 100, 25, 25);                            //Create head
     noFill();
     strokeCap(ROUND);
     stroke(10, 80, 100);
     line(338, 103, 355, 103);                             //Create beak
     noFill();
     strokeCap(ROUND);
     stroke(0);
     strokeWeight(8);
     line(300, 110, 280, 120);                            //Create bottom wing
     stroke(0);
     strokeWeight(2);
     fill(100);
     ellipse(330, 100, 1, 1);                              //Create eye

     //Dog
     fill(10, 86, 50);
     noStroke();
     ellipse(1000, 800, 175, 225);                          //Create brown head
     fill(0);
     stroke(0);
     strokeWeight(8);
     strokeJoin(ROUND);
     triangle(1000, 875, 970, 835, 1030, 835);              //Create nose
     ellipseMode(RADIUS);
     noStroke();
     fill(100);
     ellipse(975, 775, 15, 20);
     ellipseMode(CENTER);
     stroke(0);
     strokeWeight(2);
     fill(0);
     ellipse(975, 775, 10, 20);                              //Create left eye
     ellipseMode(RADIUS);
     noStroke();
     fill(100);
     ellipse(1025, 775, 15, 20);
     ellipseMode(CENTER);
     stroke(0);
     strokeWeight(2);
     fill(0);
     ellipse(1025, 775, 10, 20);                              //Create right eye
     fill(10, 86, 70);
     stroke(10, 86, 70);
     strokeWeight(8);
     strokeJoin(ROUND);
     triangle(1040, 695, 1092, 830, 1100, 768);              //Create right ear
     fill(10, 86, 70);
     stroke(10, 86, 70);
     strokeWeight(8);
     strokeJoin(ROUND);
     triangle(960, 695, 908, 830, 900, 768);              //Create left ear
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>any alternatives to Translate function ?</title>
      <link>https://forum.processing.org/two/discussion/13158/any-alternatives-to-translate-function</link>
      <pubDate>Wed, 21 Oct 2015 20:25:40 +0000</pubDate>
      <dc:creator>mod345</dc:creator>
      <guid isPermaLink="false">13158@/two/discussions</guid>
      <description><![CDATA[<p>after a previous question which was answered, translate is cumulative.</p>

<p>i have reached that point again in open processing that i reached years ago, translate is designed wrong.</p>

<p>if i use translate (4,0,0) in a loop it will increment x by  4 8 12 etc.
this is fine to translate(-4,0,0) to undo how this function works.</p>

<p>but if i use a complex equation such as</p>

<pre><code>translate(0,0,20*cos(radians(posx)*mod)*sin(radians(posy)*mod) );
</code></pre>

<p>this could be impossible to undo the translate.</p>

<p>so my real question is, why the hell is translate cumulative, this really is a stupid way to design a function ?</p>
]]></description>
   </item>
   <item>
      <title>relearning How to understand Vertex, Translate, Pushmatrix and Popmatrix ?</title>
      <link>https://forum.processing.org/two/discussion/13148/relearning-how-to-understand-vertex-translate-pushmatrix-and-popmatrix</link>
      <pubDate>Wed, 21 Oct 2015 12:40:06 +0000</pubDate>
      <dc:creator>mod345</dc:creator>
      <guid isPermaLink="false">13148@/two/discussions</guid>
      <description><![CDATA[<p>i am trying to relearn processing but i cant get my head around these functions.</p>

<p>im using 1.5.1 processing.</p>

<p>Vertex shape goes (0,0) (1,0) (1,1) (0,1)
but why? shouldnt it go
vertex (0,0) (1,0) (0,1) (1,1)
when creating a shape.
this seems like the logical way ?</p>

<p>Translate: if i translate to (0,0,0) in a loop its always (0,0,0)
but if i translate to (4,0,0) it pushes X so 4 8 12 16 etc
can anyone explain why this is?</p>

<p>Pushmatrix and popmatrix 
if i use these functions in a loop it effects the object.
i cant understand these functions, i know they have a stack.
where is the stack ? how big is the stack ?</p>

<p>how does translate and push and pop work together?
if i pushmatrix before translate it act differently.
is pushmatrix just a buffer stack which is similar to a loop?</p>

<p>its driving me nuts trying to understand these function again.</p>
]]></description>
   </item>
   <item>
      <title>I want to rotate each rect by 5° inside a for-loop</title>
      <link>https://forum.processing.org/two/discussion/12160/i-want-to-rotate-each-rect-by-5-inside-a-for-loop</link>
      <pubDate>Wed, 19 Aug 2015 17:31:37 +0000</pubDate>
      <dc:creator>injuvik</dc:creator>
      <guid isPermaLink="false">12160@/two/discussions</guid>
      <description><![CDATA[<p>dear coders,</p>

<p>i want to rotate each rectangle inside my for-loop. But with this code the programm rotates the whole sketch-matrix. What do i do wrong?</p>

<pre><code> for (int x = 0; x &lt; width; x=x+20) {
    for (int y = 0; y &lt; height; y=y+20) {

      pushMatrix();
     rotate(radians(5));
      rect(x,y,20,20);
      popMatrix();
    }
  }
</code></pre>
]]></description>
   </item>
   </channel>
</rss>