<?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 scale() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=scale%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:03:14 +0000</pubDate>
         <description>Tagged with scale() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedscale%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Mouse click position when I resize fullscreen with command scale</title>
      <link>https://forum.processing.org/two/discussion/25991/mouse-click-position-when-i-resize-fullscreen-with-command-scale</link>
      <pubDate>Tue, 16 Jan 2018 10:40:19 +0000</pubDate>
      <dc:creator>dfnogueira</dc:creator>
      <guid isPermaLink="false">25991@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone. I resized a draw section using command "scale". It's work well. However, the local where I have press a button doesn't move. It stays in the "fullscreen" position. Could someone help me?</p>
]]></description>
   </item>
   <item>
      <title>How can I see the entire processing frame/surface if it is larger than the resolution of my monitor?</title>
      <link>https://forum.processing.org/two/discussion/25793/how-can-i-see-the-entire-processing-frame-surface-if-it-is-larger-than-the-resolution-of-my-monitor</link>
      <pubDate>Wed, 03 Jan 2018 00:08:48 +0000</pubDate>
      <dc:creator>lpasqualis</dc:creator>
      <guid isPermaLink="false">25793@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I like to generate and save large images using processing, much larger than the resolution of my monitor.  However, that means that while my sketch is drawing, I can only see part of it.</p>

<p>For example, let's say that my sketch needs to render an image at 4000x4000.  When it is done, it saves the image using save(). However, I want to be able to see what's going on as the sketch is being generated, but my screen is only 2560 x 1600.</p>

<p>Is there a way to zoom out so that I can see the entire image while it is been generated, but retain the high resolution I need as a final result?</p>

<p>I realize that I could pre-generate a smaller version, and then let it work on the larger version once I "approve it." However, that does not work for me for various reasons, one of them being that I don't want to do the work twice, even if the first time is at low-resolution.</p>

<p>Any ideas?</p>
]]></description>
   </item>
   <item>
      <title>Zooming into where mouse pointer is</title>
      <link>https://forum.processing.org/two/discussion/25735/zooming-into-where-mouse-pointer-is</link>
      <pubDate>Wed, 27 Dec 2017 23:49:24 +0000</pubDate>
      <dc:creator>glennmarshall</dc:creator>
      <guid isPermaLink="false">25735@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to work out how the user can use the mouse wheel to zoom in and out of the screen with the mouse pointer being the centre of zooming.  I nearly have it working, except that after zooming, the screen content follows the pointer around as you move it.  I can't work out the math / code to offset this.  I need to use the translate / scale functions for my project.
Thanks!</p>

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

float zoom=1;

void draw(){
  background(200);

  translate(mouseX,mouseY);

  scale(zoom);

  translate(-(mouseX),-(mouseY));

  ellipse(20,200,500,300);
  rect(200,400,300,300);
  ellipse(400,200,100,100);

}

void mouseWheel(MouseEvent event) {
  float e = event.getCount();
  //println(e);
  zoom-=e/10;

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How can I scale an triangle with an animation?</title>
      <link>https://forum.processing.org/two/discussion/25140/how-can-i-scale-an-triangle-with-an-animation</link>
      <pubDate>Wed, 22 Nov 2017 08:18:01 +0000</pubDate>
      <dc:creator>jkr137</dc:creator>
      <guid isPermaLink="false">25140@/two/discussions</guid>
      <description><![CDATA[<p>It works with a rect or a ellipse but it doesn't with a triangle. Why?</p>

<pre><code>float shapeScale=1;
float speedScale=1.1;
void setup() {
  size(500, 500);
  frameRate(60);
}
void draw() {
  shapeScale = shapeScale + speedScale;
  background(0);
  pushMatrix();
  //translate(width/2, height/2);
  scale(shapeScale);
  triangle(700, 700, 850, 430, 1000, 700);
  popMatrix();

  if (shapeScale&gt;=50.0 || shapeScale&lt;=0) {
    speedScale= speedScale*-1;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Draw a parabola with point() and a custom function parabola()?</title>
      <link>https://forum.processing.org/two/discussion/23364/draw-a-parabola-with-point-and-a-custom-function-parabola</link>
      <pubDate>Sat, 08 Jul 2017 13:39:19 +0000</pubDate>
      <dc:creator>Nuss</dc:creator>
      <guid isPermaLink="false">23364@/two/discussions</guid>
      <description><![CDATA[<p>Hi Guys,</p>

<p>I'm just trying to draw a parabola. 
I have now tried it over several days but it doesn't work. 
Here is the basic code I have to use.</p>

<pre><code>    void setup() {
      size(301, 301);
      noLoop();
      background(0);
    }

    void draw() {

      strokeWeight(3);
      stroke(#66C1FC);
      line(0, 300, 300, 300);
      stroke(#F55719);
      line(150, 0, 150, 300);

      stroke(255);
      strokeWeight(1);

      // My problems begin, I have to rescale the x axis, so only values between -4
      // and 4 used for calculation  without map(). 
      for (int i = 0; i &lt; 301; i ++) {  
       point(i,parabola(?));                    
      }
    }

    float parabola(float xValue) {
      float r;
      r = xValue * xValue;
      return r;
    }
</code></pre>

<p>I dont get it and believe me I tried everything.</p>
]]></description>
   </item>
   <item>
      <title>Stroke not visible through png</title>
      <link>https://forum.processing.org/two/discussion/23212/stroke-not-visible-through-png</link>
      <pubDate>Mon, 26 Jun 2017 11:56:48 +0000</pubDate>
      <dc:creator>frankbass</dc:creator>
      <guid isPermaLink="false">23212@/two/discussions</guid>
      <description><![CDATA[<p>I can't see the stroke of the box() when the png image is in front.
What am I doing wrong?</p>

<pre><code>PImage body1;
int w = 400;    
int h = 200;

void setup() {    
  size(1000, 700, P3D);   
  body1 = loadImage("Basketball.png");    
}

void draw() {    
  background(200);   
  translate(width/2, height/2);   
  float x = map(mouseX, 0, width, -PI/2, PI/2);   
  rotateY(x);

  noFill();   
  box(w, h, w);

  pushMatrix();
  translate(-100, 15);
  scale(.25);    
  image(body1, 0, 0);    
  popMatrix();    
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Inconsistent dragging speed when zoomed in</title>
      <link>https://forum.processing.org/two/discussion/23057/inconsistent-dragging-speed-when-zoomed-in</link>
      <pubDate>Tue, 13 Jun 2017 16:09:04 +0000</pubDate>
      <dc:creator>BadDesignException</dc:creator>
      <guid isPermaLink="false">23057@/two/discussions</guid>
      <description><![CDATA[<p>I have created a Processing sketch which supports dragging the whole display as well as zooming it in. Here are the methods I use to drag and zoom:</p>

<pre><code>public void mousePressed(){
    dragBeginX = (mouseX - offsetX);
    dragBeginY = (mouseY - offsetY);
}

public void mouseDragged(){
    if (mousePressed) {
    offsetX = (mouseX - dragBeginX);
    offsetY = (mouseY - dragBeginY);
}

public void zoomTo(float sc){
    translate(width/2, height/2);
    scale(sc);
    translate(-width/2, -height/2);
    //actual zooming handled in separate thread for smoothness
};
</code></pre>

<p>and in before doing the graphic stuff:</p>

<pre><code>translate(offsetX, offsetY);
zoomTo(currentZoom);
</code></pre>

<p>There is no actual bug in that code, but it doesn't quite work the way I want - when the application is zoomed in, the dragging speed remains the same which means that the graphics move much faster than the cursor. Opposite applies when application is zoomed out.
I have tried inserting the zoom value in the dragging math so that the drag speed would depend on the zoom, but I can't find where exactly it needs to be.</p>

<p>To sum it up, I need to make it so that when zoomed in, the object moving speed matches with the cursor dragging speed.</p>

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

<p>EDIT: If it was unclear, offsetX/Y is the current dragged position of the screen;</p>
]]></description>
   </item>
   <item>
      <title>brightness and contrast of the webcam</title>
      <link>https://forum.processing.org/two/discussion/22012/brightness-and-contrast-of-the-webcam</link>
      <pubDate>Sat, 15 Apr 2017 16:58:26 +0000</pubDate>
      <dc:creator>gius</dc:creator>
      <guid isPermaLink="false">22012@/two/discussions</guid>
      <description><![CDATA[<p>Hello everybody,
I want that while there is a live webcam it is possible to adjust the brightness and contrast of color and gray images.
This is my code:</p>

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


OpenCV opencv;

PFont f;     

boolean filterT=false;


Capture cam;

GButton btnFilterT;

int n = 1;

void setup() {
  size(1024, 768); 

  f = createFont("Arial", 48, true);

  btnFilterT = new GButton(this, 740, 50, 140, 20);
  btnFilterT.setText("On");
  btnFilterT.setLocalColorScheme(GCScheme.GREEN_SCHEME);

  cam = new Capture(this, 640, 480);
  cam.start();
}


void draw() {

  if (cam.available() == true) {
    cam.read();
  }


  pushMatrix();
  scale(-1, 1);
  image(cam.get(), -width, 0, width, height);
  popMatrix();  

  opencv = new OpenCV(this, cam);
  opencv.loadImage(cam);


  if (filterT==true) {
    opencv.brightness((int)map(mouseX, 0, width, -255, 255));
    image(opencv.getOutput(),0, 0, width, height);
  }
}

public void handleButtonEvents(GButton button, GEvent event) {

  if (button == btnFilterT) {
    filterT=true;
  }
}
</code></pre>

<p>I have two problems:</p>

<p>if I press the T button to start  the brightness and contrast in gray, the screen flips over and becomes no mirror.</p>

<p>how can I have brightness and contrast  with the mirror video?</p>

<p>how can I have the brightness and contrast of the webcam color?</p>

<p>thank you</p>
]]></description>
   </item>
   <item>
      <title>Rotating images</title>
      <link>https://forum.processing.org/two/discussion/21857/rotating-images</link>
      <pubDate>Thu, 06 Apr 2017 12:17:07 +0000</pubDate>
      <dc:creator>OrOrg</dc:creator>
      <guid isPermaLink="false">21857@/two/discussions</guid>
      <description><![CDATA[<p>Hi, it's me with a displaying question again...</p>

<p>I tried using rotate(-angle) and then drawing an image, but it won't display the image. (I also put resetMatrix() behind)</p>

<p>I guess displaying an image rotated is one of those things that's impossible to do as well?
(I was only trying to rotate the image multiples of PI/2)</p>

<p>Kind regards,
OrOrg</p>
]]></description>
   </item>
   <item>
      <title>Print Example 6: Scale and segment an image translate() problem</title>
      <link>https://forum.processing.org/two/discussion/21795/print-example-6-scale-and-segment-an-image-translate-problem</link>
      <pubDate>Tue, 04 Apr 2017 12:01:19 +0000</pubDate>
      <dc:creator>jairo_asecas</dc:creator>
      <guid isPermaLink="false">21795@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm having problems with this technique.</p>

<p><a rel="nofollow" href="https://processing.org/tutorials/print/">https://processing.org/tutorials/print/</a></p>

<pre><code> /* 
     * Example 6: Scale and segment an image
     * 
     * Draws an image larger than the screen by tiling it into small sections.
     * The scaleValue variable sets amount of scaling: 1 is 100%, 2 is 200%, etc.
     */

    int scaleValue = 3;  // Multiplication factor
    int xoffset = 0;     // x-axis offset 
    int yoffset = 0;     // y-axis offset

    void setup() {
      size(600, 600);
      stroke(0, 100);
    }

    void draw() {
      scale(scaleValue);
      translate(xoffset * (-width/scaleValue), yoffset * (-height/scaleValue));
      line(10, 150, 500, 50);
      line(0, 600, 600, 0); 
      setOffset();
    }

    void setOffset() {
      save("lines-" + xoffset + "-" + yoffset + ".jpg");
      xoffset++;
      if (xoffset == scaleValue) {
        xoffset = 0;
        yoffset++;
        if (yoffset == scaleValue) {
          exit();
        } 
      }
      background(204);
    }
</code></pre>

<p>the problem is that I have to use translate() several times after this and it makes impossible exporting the image correctly. Example:</p>

<pre><code>void draw() {
  scale(scaleValue);
  translate(xoffset * (-width/scaleValue), yoffset * (-height/scaleValue));
  line(10, 150, 500, 50);
 translate(0,height/2);
  line(0, 600, 600, 0); 
  setOffset();
}
</code></pre>

<p>I've tried another ways like:
Example 4: accumulate many frames into one pdf
Example 5: high-resolution off-screen buffer</p>

<p>The problem is that I must use  "aa" &lt; fft.specSize() in my sketch and I can't enlarge it. Also there is a lot of transparency what makes it difficult to use a pdf/svg vector mode for exporting.</p>

<p>Thanks, sorry for my spanglish.</p>
]]></description>
   </item>
   <item>
      <title>Scale Translate AB comparission</title>
      <link>https://forum.processing.org/two/discussion/20853/scale-translate-ab-comparission</link>
      <pubDate>Fri, 17 Feb 2017 16:24:37 +0000</pubDate>
      <dc:creator>prince_polka</dc:creator>
      <guid isPermaLink="false">20853@/two/discussions</guid>
      <description><![CDATA[<p>This is probably pointless but oh well...<br />
I had a pan and zoom problem and solved it using scale and translate functions.<br />
I got curious if there was any reason to use those functions other than convenience.<br />
So I set up this this A B comparison, one with and one without them.<br />
Turns out it makes no visual difference whether you use them or not.<br />
left-click    = pan<br />
scrollwheel = zoom<br />
right-click  = switch mode</p>

<pre><code>// scaletranslate A B comparission
float mx,my,ratio,xpt,ypt,xzt,yzt,cx,cy,swt,zoom;
boolean mode=false;
void setup() {
 size(600,600);
  zoom=1.0;
  mx=width/60;
  my=mx*height/width;
  ratio=mx/my;
}
void draw() {

  if(!mode){cxcy(60,60);}
  else if(mode){scaletranslate(60,60);}
}
void mouseClicked(){
  if(mouseButton == RIGHT){
    if(mode){mode=false;}else{mode=true;}

  }
}
void mouseDragged(){
  xpt-=(pmouseX-mouseX)/zoom;
  ypt-=(pmouseY-mouseY)/zoom;
}
void mouseWheel(MouseEvent event) {
  swt-=event.getCount();
  if (swt==0) {
    zoom=1.0;
  } else if (swt&gt;=1 &amp;&amp; swt&lt;=10) {
    zoom=pow(2, swt);
  } else if (swt&lt;=-1 &amp;&amp; swt&gt;=-10) {
    zoom=1/pow(2, abs(swt));
  }
  xzt=((zoom-1)*width/2)/zoom;
  yzt=((zoom-1)*height/2)/zoom;
  if(event.getCount()&lt;=-1){
  xpt-=(mouseX-width/2)/zoom;
  ypt-=(mouseY-height/2)/zoom;
  } else {
  xpt+=(mouseX-width/2)/(pow(2, swt+1));
  ypt+=(mouseY-height/2)/(pow(2, swt+1));
  }
}
void cxcy(float x, float y) {
  cx=(xpt-xzt); cy=(ypt-yzt);
  background(128);
  stroke(0);
  strokeWeight(zoom);
  for(int i = 0; i &lt; x; i++){line(((i*width/x)+cx)*zoom,cy*zoom,((i*width/x)+cx)*zoom,(height+cy)*zoom);}
  for(int i = 0; i &lt; y; i++){line(cx*zoom,((i*height/y)+cy)*zoom,(width+cx)*zoom,((i*height/y)+cy)*zoom);}
  fill(#ff0000);rect((cx+mx*10)*zoom,(cy+mx*10)*zoom,mx*zoom,mx*zoom);
  fill(#ffff00);rect((cx+mx*49)*zoom,(cy+mx*10)*zoom,mx*zoom,mx*zoom);
  fill(#00ff00);rect((cx+mx*10)*zoom,(cy+mx*49)*zoom,mx*zoom,mx*zoom);
  fill(#0000ff);rect((cx+mx*49)*zoom,(cy+mx*49)*zoom,mx*zoom,mx*zoom);
  fill(#abcdef);ellipse((cx+width/2)*zoom,(cy+height/2)*zoom,width/8*zoom,height/8*zoom);
  textSize(4*mx*zoom);
  fill(0);
  textAlign(CENTER);
  text("CX CY Floats",(cx+width/2)*zoom,(cy+height/2)*zoom);
}

void scaletranslate(float x, float y) {
  scale(zoom);
  translate(xpt-xzt,ypt-yzt);
  background(128);
  stroke(0);
  strokeWeight(1.0);
  for(int i = 0; i &lt; x; i++){line(i*width/x,0,i*width/x,height);}
  for(int i = 0; i &lt; y; i++){line(0,i*height/y,width,i*height/y);}
  fill(#ff0000);rect(mx*10,mx*10,mx,mx);
  fill(#ffff00);rect(mx*49,mx*10,mx,mx);
  fill(#00ff00);rect(mx*10,mx*49,mx,mx);
  fill(#0000ff);rect(mx*49,mx*49,mx,mx);
  fill(#abcdef);ellipse(width/2,height/2,width/8,height/8);
  textSize(4*mx);
  fill(0);
  textAlign(CENTER);
  text("Scale Translate",width/2,height/2);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Scale + noFill not working ?</title>
      <link>https://forum.processing.org/two/discussion/20537/scale-nofill-not-working</link>
      <pubDate>Sun, 29 Jan 2017 16:43:04 +0000</pubDate>
      <dc:creator>marc_nostromo</dc:creator>
      <guid isPermaLink="false">20537@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to use scale and I'm puzzle by the result of the following code:</p>

<pre><code>void setup()
{
  size(1000, 600);
  noLoop();
}

void draw()
{
  scale(width/2, height/4);
  noFill();
  rect(0,0,1,1);
}
</code></pre>

<p>I'm expecting a unfilled rectange taking half the width and quarter the height but I'm seeing a filled rectange with strange boundaries.</p>

<p>Is there any reason or is this a bug ? The same happens with shapes.</p>
]]></description>
   </item>
   <item>
      <title>Repititive pattern out of anchor points</title>
      <link>https://forum.processing.org/two/discussion/20413/repititive-pattern-out-of-anchor-points</link>
      <pubDate>Sun, 22 Jan 2017 16:13:59 +0000</pubDate>
      <dc:creator>kr1schiii</dc:creator>
      <guid isPermaLink="false">20413@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys,</p>

<p>I try to realize some pattern out of the logo of my University. This is a small project for a programming class we have in our design degree. But since I'm a designer I encounter some problems to realize the idea. 
So I got the anchor points from our logo and made it to draw it out of an array with all the coordinates. That works quite well.</p>

<p>My next step now should be to draw the shape again but in smaller size inside the first one. That step I want to repeat several times. My professor suggested me something with the scale command and a variable to do this, but I can't figure out how to do it properly. Always I put the code in the resizing works, but I can't get it do display in the shape in smaller.</p>

<p>I would appreciate any help with code or idea what to do! :)</p>

<pre><code>float[] rightshape = {111.8, 5.9, 111.8, 5.9, 62.8, 70.80000000000001, 62.8, 70.80000000000001, 62.8, 70.80000000000001, 62.8, 70.80000000000001, 62.599999999999994, 171.20000000000002, 62.599999999999994, 171.20000000000002, 62.599999999999994, 171.20000000000002, 62.599999999999994, 177.50000000000003, 67.6, 182.50000000000003, 73.89999999999999, 182.50000000000003, 73.89999999999999, 182.50000000000003, 73.89999999999999, 182.50000000000003, 73.89999999999999, 182.50000000000003, 73.89999999999999, 182.50000000000003, 73.89999999999999, 182.50000000000003, 80.1, 182.50000000000003, 85.19999999999999, 177.50000000000003, 85.19999999999999, 171.20000000000002, 85.19999999999999, 171.20000000000002, 85.19999999999999, 171.20000000000002, 85.39999999999999, 78.40000000000002, 85.39999999999999, 78.40000000000002, 85.39999999999999, 78.40000000000002, 85.39999999999999, 78.40000000000002, 111.79999999999998, 43.40000000000002, 111.79999999999998, 43.40000000000002, 111.79999999999998, 43.40000000000002, 111.79999999999998, 43.40000000000002, 111.79999999999998, 5.9, 111.79999999999998, 5.9, 111.79999999999998, 5.9, 111.79999999999998, 5.9, 111.8, 5.9, 111.8, 5.9};
float[] leftshape = {34.685, 136.132, 34.685, 136.132, 34.685, 59.888, 34.685, 59.888, 34.685, 59.888, 34.685, 59.888, 8.371, 27.128, 8.371, 27.128, 8.371, 27.128, 4.465, 22.253, 5.239000000000001, 15.152, 10.114, 11.239, 10.114, 11.239, 14.978, 7.329, 22.087, 8.111, 26, 12.97, 26, 12.97, 26, 12.97, 57.292, 51.942, 57.292, 51.942, 57.292, 51.942, 57.292, 51.942, 57.292, 136.132, 57.292, 136.132, 57.292, 136.132, 57.292, 142.36700000000002, 52.222, 147.434, 45.986000000000004, 147.434, 45.986000000000004, 147.434, 39.743, 147.433, 34.685, 142.367, 34.685, 136.132};

void setup() {
  size(800, 600);
  background(255);

  println(rightshape);
  //println(leftshape);
}

int size = 10;
float s = 1;

void draw() {

  scale(s);
  //s = s-0.3;
  strokeWeight(2);

  //translate(-50, -60);
  translate(width/2, height/2);
  //Draw the left part of the logo
  //
  for (int countleft = 0; countleft &lt; 63; countleft = countleft+8) {

    stroke(53, 37, 92);
    bezier(leftshape[countleft], leftshape[countleft+1], leftshape[countleft+2], leftshape[countleft+3], leftshape[countleft+4], leftshape[countleft+5], leftshape[countleft+6], leftshape[countleft+7]);

  }

  //Draw the right part of the logo
  for (int countright = 0; countright &lt; 71; countright = countright+8) {

    stroke(29, 112, 183);
    bezier(rightshape[countright], rightshape[countright+1], rightshape[countright+2], rightshape[countright+3], rightshape[countright+4], rightshape[countright+5], rightshape[countright+6], rightshape[countright+7]);
  }
}
</code></pre>

<p>Here is a small scribble how it should go together, in case you don't get from my description what I mean.
<a href="http://www.dropbox.com/s/k78wv5s3lkqddkg/Foto%2022.01.17%2C%2014%2004%2017.jpg" target="_blank" rel="nofollow">http://www.dropbox.com/s/k78wv5s3lkqddkg/Foto 22.01.17, 14 04 17.jpg</a></p>
]]></description>
   </item>
   <item>
      <title>Rotating and Scaling Multiple Stars</title>
      <link>https://forum.processing.org/two/discussion/19120/rotating-and-scaling-multiple-stars</link>
      <pubDate>Fri, 18 Nov 2016 11:13:36 +0000</pubDate>
      <dc:creator>tillemetry</dc:creator>
      <guid isPermaLink="false">19120@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to write a piece of code that rotates a group of 25 stars, and scales them randomly too.</p>

<p>Found good code for rotating PShapes, but scale doesn't seem to work for me.  I always end up with scale somehow in the draw loop, which to my understanding means it is going to be run over and over (See results).  I know this is a very basic question, but I'm still learning.</p>

<p>Thanks,</p>

<p>// A list of objects
ArrayList polygons;</p>

<p>void setup() {
  size(640, 360, P3D);</p>

<p>// Make a PShape
  PShape star = createShape();
  star.beginShape();
  star.noStroke();
  star.fill(0, 127);
  star.vertex(0, -50);
  star.vertex(14, -20);
  star.vertex(47, -15);
  star.vertex(23, 7);
  star.vertex(29, 40);
  star.vertex(0, 25);
  star.vertex(-29, 40);
  star.vertex(-23, 7);
  star.vertex(-47, -15);
  star.vertex(-14, -20);
  star.endShape(CLOSE);</p>

<p>// Make an ArrayList
  polygons = new ArrayList();</p>

<p>// Add a bunch of objects to the ArrayList
  // Pass in reference to the PShape
  // We coud make polygons with different PShapes
  for (int i = 0; i &lt; 25; i++) {
    polygons.add(new Polygon(star));
  }
}</p>

<p>void draw() {
  background(255);</p>

<p>// Display and move them all
  for (Polygon poly : polygons) {
    scale(0.9);
    poly.display();
    poly.move();
  }
}
// A class to describe a Polygon (with a PShape)</p>

<p>class Polygon {
  // The PShape object
  PShape s;
  // The location where we will draw the shape
  float x, y;
  // Variable for simple motion
  float speed;
  float theta1 = 0;</p>

<p>Polygon(PShape s_) {
    x = random(width);
//    y = random(-500, -100); 
    y = random(height);
    s = s_;
//    speed = random(2, 6);
    speed = 0;
  }</p>

<p>// Simple motion
  void move() {
    y += speed;
    if (y &gt; height+100) {
      y = -100;
    }
  }
  //</p>

<p>// Draw the object
  void display() {
    pushMatrix();
    translate(x, y);
    rotateZ(theta1);
//    scale(0.5);
    shape(s);
    theta1+=0.02;
    popMatrix();
  }
}</p>
]]></description>
   </item>
   <item>
      <title>Mirroring Capture help</title>
      <link>https://forum.processing.org/two/discussion/18525/mirroring-capture-help</link>
      <pubDate>Thu, 13 Oct 2016 04:52:59 +0000</pubDate>
      <dc:creator>kksd</dc:creator>
      <guid isPermaLink="false">18525@/two/discussions</guid>
      <description><![CDATA[<p>How do you flip/mirror a video?
Below is my code, where I am trying to get the video to play a mirrored image on processing using
"int loc = (cam.width - i - 1) + j*cam.width;"
Where I translate the x-axis to flip, subtracting the x-location of the particular pixel (where brightness is above 253) from the width of the screen, but somehow it is not working.
What is the issue here?</p>

<p>import processing.video.*;
int cols, rows;
Capture cam;</p>

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

<p>//displays it full screen
  size (displayWidth, displayHeight);</p>

<p>cols = width;<br />
  rows = height;
  //30 fps is default so bellow won't change anything
  cam = new Capture(this, width, height, 30);</p>

<p>// Start capturing the images from the camera
  cam.start();</p>

<p>frameRate(30);
  background(0);
}</p>

<p>void draw() { 
  if(cam.available()) {
    //reads fresh-est  pixels from camera
    cam.read();
    cam.loadPixels();
    loadPixels();
    // Loop through every pixel. ++i is equivalent to i = i + 1.
    //for (int i=0; i&lt;cam.pixels.length; i++) {</p>

<pre><code>// Begin loop for columns(using width)
for (int i = 0; i &lt; cols;i++) {
  // Begin loop for rows(using length)
  for (int j = 0; j &lt; rows;j++) {

    // Where are we, pixel-wise? (cam.width - i - 1) means x-coordinate of the pixel mirrored
    int loc = (cam.width - i - 1) + j*cam.width;  // Reversing x to mirror the image

    if (brightness(cam.pixels[loc]) &gt; 253) {
      pixels[loc] = color(255);       
    }

 float red = red(pixels[loc]);
 float green = green(pixels[loc]);
 float blue = blue(pixels[loc]);

 blue = blue - 5;
 if(blue &lt; 0) blue = 0;

 red = red - 5;
 if(red &lt; 0) red = 0;

 green = green - 5;
 if(green &lt; 0) green = 0;

 pixels[loc] = color(red, green, blue);

} 
</code></pre>

<p>}</p>

<p>updatePixels();</p>

<p>}
}</p>
]]></description>
   </item>
   <item>
      <title>Again, the Y Flip Conundrum</title>
      <link>https://forum.processing.org/two/discussion/17697/again-the-y-flip-conundrum</link>
      <pubDate>Fri, 29 Jul 2016 22:10:09 +0000</pubDate>
      <dc:creator>brooklev</dc:creator>
      <guid isPermaLink="false">17697@/two/discussions</guid>
      <description><![CDATA[<p>Okay, I know flipping the Y axis has been addressed before (<a href="https://forum.processing.org/one/topic/invert-coordinates.html" target="_blank" rel="nofollow">https://forum.processing.org/one/topic/invert-coordinates.html</a>) and I can make shapes just where I want them when I use<br />
<strong>scale(1, -1);<br />
translate(0, -height);</strong><br />
in draw(), but I can't figure out how to make the coordinates match in the mousePressed() function so that I can click on areas specified by mathematical rather than "computer" coordinates.</p>

<p>This is, of course, part of the continual conundrum we intro level teachers face as we try to show learners without great math skills that programming is do-able and even fun: <strong>is the code to invert the Y axis unobtrusive enough so that we can use the coordinate system my students (kind of) already know or must I teach them "computer coordinates" which are the undoing of half of what my math colleagues have labored to teach them?</strong></p>

<p>[Apologies: frustrated rant to follow]</p>

<p>In creating his brilliant Python Graphics module, John Zelle included a function which transforms coordinates (any way you want) for an entire program with just a single, short line of code you put in at the start. Now I know Python is not a great language for writing video games, but this graphics module nonetheless demands consideration by all teachers of "diverse learners" because you don't have to work against what students have already struggled to learn, i.e. - that Y 'moves' upwards positively and downwards negatively. At the start of every class you don't have to remind them how computers do it differently. You don't have to double the number of vectors students are storing in memory. You don't have to send them off to their math classes or state exams with inverted directions rattling around in their brains. (With graduations now pinned to ever more finicky standardized exams, this is not a small thing.) IF PROCESSING IS SUCH A WONDROUS TEACHING LANGUAGE, HOW ON EARTH COULD SOMEONE NEGLECT TO INCLUDE A SIMILAR COORDINATE SETTING FUNCTION?</p>

<p>[Apologies once more; question resumes]</p>

<p>So, I've seen that perhaps a solution exists using pushMatrix() and popMatrix(), but I haven't been able to make that work. Additionally, I can probably leave my students unconfused by a couple of instances of scale() and translate(), but adding pushMatrix() and popMatrix() with indented code nested between them probably adds more distraction than teaching them the inverted Y concept.</p>

<p>Can anyone share code for aligning inverted Y coordinates across draw() and mousePressed()? With much respect and hope that the misunderstanding is mine, Brooklev</p>
]]></description>
   </item>
   <item>
      <title>PGraphics::scale() not exporting in P3D</title>
      <link>https://forum.processing.org/two/discussion/17200/pgraphics-scale-not-exporting-in-p3d</link>
      <pubDate>Sat, 18 Jun 2016 15:09:03 +0000</pubDate>
      <dc:creator>chrisb78</dc:creator>
      <guid isPermaLink="false">17200@/two/discussions</guid>
      <description><![CDATA[<p>When exporting a PGraphicss P3D object, save() doesn't reflect calls to scale().
Consider the example, taken from <a href="https://forum.processing.org/two/discussion/3227/high-resolution-export-p3d" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/3227/high-resolution-export-p3d</a>:
(note that endRecord() and PGpx.scale() had to be changed in order for the original example to work):</p>

<pre><code>boolean record;
int scalePG = 2;

void setup() {
    size(600, 600, P3D);
    smooth();
}

void draw() {
    if(!record)
        background(#ffffff);
    translate(width/2, height/2);
    fill(#ff0000);
    rotateX(60);
    rotateZ(60);
    box(100);
}
void keyPressed() {
    save("lowres.png");

    if(keyCode == ENTER) {
        PGraphics PGpx = createGraphics(width * scalePG, height * scalePG, P3D);
        record = true;
        beginRecord(PGpx);
        PGpx.background(#ffffff, 0); // Clear the offscreen canvas (make it transparent)
        PGpx.scale(scalePG);
        draw();
        endRecord(); // originally was AFTER call to save() in next line - but didn't save anything.
        PGpx.save("highres.png"); // Save image as PNG (JPGs can't have an alpha channel) and save it before endRecord()

        record = false;
    }
}
</code></pre>

<p>I posted some pictures about this in this post: <a href="https://forum.processing.org/two/discussion/17162/high-resolution-output-for-p3d" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/17162/high-resolution-output-for-p3d</a></p>

<p>Does anyone know how to fix this?</p>
]]></description>
   </item>
   <item>
      <title>applying a mask flips or rotate the image!</title>
      <link>https://forum.processing.org/two/discussion/14885/applying-a-mask-flips-or-rotate-the-image</link>
      <pubDate>Sat, 13 Feb 2016 02:23:26 +0000</pubDate>
      <dc:creator>gperez</dc:creator>
      <guid isPermaLink="false">14885@/two/discussions</guid>
      <description><![CDATA[<p>Hi. I'm developing in Eclipse. With a kinect (depth sensor).</p>

<p>Currently, I'm trying to mask images. But for some reason as soon I apply a filter, the image flips (or rotates 180º). And I just can't get them back to the current position.</p>

<p>This happens not only with mask() method, but also with other filters (with filter method itself or the blend() one)</p>

<p>I'm giving you an example code:</p>

<p>PGraphics mappingZone;<br />
..
mappingZone = applet.createGraphics(kinect.width, kinect.height, PApplet.P2D);<br />
..
filteredImg = applet.createImage(kinect.width, kinect.height, PApplet.P2D);
...</p>

<pre><code>  mappingZone.beginDraw();
  mappingZone.background(0);            
  mappingZone.image(mappingTexture, 0, 0);
  mappingZone.mask(filteredImg);    
  mappingZone.endDraw();        

  applet.image(mappingZone, 0, 0, applet.width, applet.height);
</code></pre>

<p>I tried several things to flip the image to the correct position, like: 
<code>mappingZone.scale(-1, -1);</code></p>

<p>But nothing works. However, applying a second filter usually return the image to the correct position. Any clue?</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/901/KLXBH3CSZDSK.jpg" alt="_pic-7016" title="_pic-7016" /></p>
]]></description>
   </item>
   <item>
      <title>get actual width of scaled shape??</title>
      <link>https://forum.processing.org/two/discussion/16881/get-actual-width-of-scaled-shape</link>
      <pubDate>Sun, 29 May 2016 20:14:21 +0000</pubDate>
      <dc:creator>FFD8</dc:creator>
      <guid isPermaLink="false">16881@/two/discussions</guid>
      <description><![CDATA[<p>I'm building a small set of functions that mirror primitive shapes (rect, ellipse, line), however normalize their pixel values for sending via OSC to openFrameworks. I've set this up, so that one just puts an 'x' in front of the existing shape. Everything is going great and screenX, screenY are my best friends in making this possible.. but I'm running into strange bugs if using scale() before drawing one of these shapes... the x,y coords get corrected, but not my width/height. 
a sample from basic setup looks like this:</p>

<p><code>pushMatrix(); // only adjusts translate/scale within matrix
  translate(width/2, height/2); // suggestion to draw from center out 
  scale(.65);
  xrect(0,0,250,250);
  popMatrix();</code></p>

<p><code>void xrect(float x1, float y1, float w1, float h1) {
  rect(x1, y1, w1, h1);
  String shape = "rect";
  float x1out = map(screenX(x1, y1), 0, width, 0, 1);
  float y1out = map(screenY(x1, y1), 0, height, 0, 1);
  float w1out = map(w1, 0, width, 0, 1);
  float h1out = map(h1, 0, height, 0, 1);
  // .. OSC message w/ these values sent after this
}</code></p>

<p>perhaps i should just be grabbing the screenX of (x1+w1) to know where that xpoint is then check the distance between those points? Wondering if there's a better way to check for transformations and know if anything's being scaled.</p>
]]></description>
   </item>
   <item>
      <title>Scaling/flipping PGraphics</title>
      <link>https://forum.processing.org/two/discussion/16382/scaling-flipping-pgraphics</link>
      <pubDate>Mon, 02 May 2016 07:54:15 +0000</pubDate>
      <dc:creator>G_D</dc:creator>
      <guid isPermaLink="false">16382@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to get two copies of a PGraphics - one displayed normally, the other flipped. I then want to convert my PGraphics to a PImage. I've got the following, but the second image isn't flipped...</p>

<pre><code>  PGraphics g;
  g = createGraphics(width, height, P3D);
  g.beginDraw();
  g.image(srcImg, 0, 0);
  g.endDraw();
  PImage output = g.get();

  PGraphics g2; 
  g2 = createGraphics(width, height, P3D);
  g2.beginDraw();
  g2.image(srcImg, 0, 0);
  g2.scale(-1,1);
  g2.endDraw();
  PImage output2 = g2.get();
</code></pre>
]]></description>
   </item>
   <item>
      <title>fix problems with setting cursor to an image; image pixely, contains colors that it shouldn't</title>
      <link>https://forum.processing.org/two/discussion/14498/fix-problems-with-setting-cursor-to-an-image-image-pixely-contains-colors-that-it-shouldn-t</link>
      <pubDate>Sat, 16 Jan 2016 16:29:19 +0000</pubDate>
      <dc:creator>Bodhidharma482</dc:creator>
      <guid isPermaLink="false">14498@/two/discussions</guid>
      <description><![CDATA[<p>Heey guys,</p>

<p>My program shows the picture I set the cursor to be, but the picture is pixely, contains colors that aren't in the original picture and gets distorted at times. Since, apparantly the mouse isn't visible when you take a screenshot I don't know how to show you. I thought I would just show you most of the code, since I'm a beginner and might leave stuff out that actually causes the problem.</p>

<pre><code>//Intialize picture aimingpoint
PImage aimingpoint;

//define class object
hare one;

//define boolean for pulling gun
boolean pull;

int width = 600;
int height = 600;

float middleX = width/2;
float middleY = height/2;

//Define values for position and size hunters
float xPosHunter1 = 0;
float yPosHunter1 = 0;
float xPosHunter2 = -200;
float yPosHunter2 = 0;
int radHunter = 10;

int deadlyDistance = 150;

//Define animalspeed
int animalSize = 10;
float hareSpeed = 1;

void setup() {
  size(width, height);
  smooth();
  //Define hare one
  one = new hare(100, 1);
  aimingpoint = loadImage("aimingpoint.png");
}

void draw() {
  //calculate angle between the line that goes fromthe origin to the mouse and postive x-axis
  //I posted a question about this on forum.processing.org: <a href="https://forum.processing.org/two/discussion/14433/rotate-line-in-such-a-way-that-one-point-is-in-the-middle-of-the-canvas-and-other-follows-the-mouse#latest" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/14433/rotate-line-in-such-a-way-that-one-point-is-in-the-middle-of-the-canvas-and-other-follows-the-mouse#latest</a>

  background(255);

  //Move origing to the middle of the canvas.
  translate(0.5 * width, 0.5 * height);

  //Flip the canvas in the x-axis so that the axis system is like a 'normal' one.
  scale(1, -1);

  //draw mouse as aimingpoint
  //<a href="http://stackoverflow.com/questions/12539840/change-mouse-cursor-in-processing" target="_blank" rel="nofollow">http://stackoverflow.com/questions/12539840/change-mouse-cursor-in-processing</a>
  cursor(aimingpoint, 16, 16);
  //  ellipseMode(CENTER);
  //  ellipse(mouseX, mouseY, 5, 5);
  //  noFill();
  //  ellipse(mouseX, mouseY, 30, 30);

     if ((keyPressed == true &amp;&amp; key == 'p' || key == 'P') &amp;&amp; mousePressed == true &amp;&amp; distanceOriginMouse() &lt;= deadlyDistance){
     background(0, 255, 0);
  } 
    else if ((keyPressed == true &amp;&amp; key == 'p' || key == 'P') &amp;&amp; mousePressed == true &amp;&amp; distanceOriginMouse() &gt; 0.5 * deadlyDistance){
      background(255,0,0);
  }

  //draw gun when p is pressed
  if (keyPressed == true &amp;&amp; key == 'p' || key == 'P') {
    pushMatrix();
    rotate(-angleMouse());
    line(0, 0, 40, 0);
    popMatrix();
  }

  ellipseMode(RADIUS);
  //draw deadly
  noFill();
  ellipse(0,0,deadlyDistance, deadlyDistance); 

  fill(255);
  //Draw Hare1
  one.show();
  one.move();

  pushMatrix();
  rotate(radians(135));
  line(0,0,500,0);
  popMatrix();

  stroke(0);
  //Hunter1
  ellipse(xPosHunter1, yPosHunter1, radHunter, radHunter);
  //Hunter2
  ellipse(xPosHunter2, yPosHunter2, radHunter, radHunter);
  //if (mousePressed == true &amp;&amp; mouseButton == LEFT &amp;&amp; mouseX &gt;=) {
}
</code></pre>

<p>The picture is 16 x 16 pixels, so that probably causes the pixelyness, but if I take a larger picture, processing won't show the entire picture anymore.</p>

<p>Hope you guys can help out!</p>

<p>-Bodhidharma482</p>
]]></description>
   </item>
   <item>
      <title>detecting color</title>
      <link>https://forum.processing.org/two/discussion/16226/detecting-color</link>
      <pubDate>Sun, 24 Apr 2016 16:00:30 +0000</pubDate>
      <dc:creator>Jai</dc:creator>
      <guid isPermaLink="false">16226@/two/discussions</guid>
      <description><![CDATA[<p>ok so in this photo i have rectangles all over the place, now my question is</p>

<p>how do we determine if a color is behind any of those rectangles ?</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/309/SG778KVM3EFP.JPG" alt="WIN_20160229_134722" title="WIN_20160229_134722" /></p>

<p>for example lets say i have my video screen from my webcam open right, and lets say im pointing at a white wall "absolute white" and lets say i bounce a red or black ball across the webcams view so now you should see a white background with a color ball in it right, now  how can i detect that ball ?</p>

<p>by detecting i mean detect &amp; track it.</p>

<pre><code>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</code></pre>

<p>now i dont just want to track the ball but i want to guide the cursor of my mouse across the screen.</p>

<pre><code>void draw()
{
    image(video, 0, 0 );
    noFill();
    stroke(255, 0, 0);
    ellipse(300, 300, 20, 20);
}
</code></pre>

<p>using this color tracker and incorporating the mouseMove functions i think i can get what im looking for, the Q is where do i get a example of mouse move? i forgot where i seen it.</p>

<pre><code>  float worldRecord = 100.0;//500 Before we begin searching, the "world record" for closest color is set to a high number that is easy for the first pixel to beat.
  // XY coordinate of closest color
  int closestX = 0;
  int closestY = 0;

  // Begin loop to walk through every pixel
  for (int x = 0; x &lt; video.width; x ++ ) {
    for (int y = 0; y &lt; video.height; y ++ ) {
      int loc = x + y*video.width;
      // What is current color
      color currentColor = video.pixels[loc];
      float r1 = red(currentColor);
      float g1 = green(currentColor);
      float b1 = blue(currentColor);
      float r2 = red(trackColor);
      float g2 = green(trackColor);
      float b2 = blue(trackColor);

      // Using euclidean distance to compare colors
      float d = dist(r1, g1, b1, r2, g2, b2); // We are using the dist( ) function to compare the current color with the color we are tracking.

      // If current color is more similar to tracked color than
      // closest color, save current location and current difference
      if (d &lt; worldRecord) {
        worldRecord = d;
        closestX = x;
        closestY = y;
      }
    }
  }

  // We only consider the color found if its color distance is less than 10. 
  // This threshold of 10 is arbitrary and you can adjust this number depending on how accurate you require the tracking to be.
  if (worldRecord &lt; 95.73401)//10 
  { 
    // Draw a circle at the tracked pixel
    fill(trackColor);
    strokeWeight(4.0);
    stroke(0);
    ellipse(closestX, closestY, 16, 16);
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to make blurs run independently in custom functions?</title>
      <link>https://forum.processing.org/two/discussion/15068/how-to-make-blurs-run-independently-in-custom-functions</link>
      <pubDate>Tue, 23 Feb 2016 04:56:54 +0000</pubDate>
      <dc:creator>pchin14</dc:creator>
      <guid isPermaLink="false">15068@/two/discussions</guid>
      <description><![CDATA[<p>I'm fairly new to processing, and I am trying to make a space scene in which the stars in the background are blurred, and there is another very blurred large star. and it leaves the planet untouched. My problem is that when I apply a blur, it applies to all parts of the sketch. Is there a way to get around this?</p>

<p>Code:</p>

<pre><code>void setup () {
  size (900, 506);
  background (0, 0, 12);
  drawStars ();
  drawPlanets ();
  drawLargeStar ();
}

void draw () {
}

void drawPlanets () {
  drawPlanet (300, 110, 50);
  pushMatrix ();
  scale (.1);
  drawPlanet (1000, 1000, 100);
  popMatrix ();
}

void drawPlanet (int x, int y, int grey) {
  translate (x, y);
  stroke (0);
  fill (150, 150, 255);
  ellipse (0, 0, 708, 698);
  fill (255);
  ellipse (0, 0, 697, 687);
  fill (grey);
  ellipse (0, 0, 680, 680);
}

void drawStars () {
  for (int num = 0; num &lt; 400; num++) {
    fill (255);
    stroke (random (0, 255), random (0, 255), random (0, 255));
    ellipse (random (0, 900), random (0, 506), random (1, 8), random (1, 8));
  }
  filter(BLUR, 4);
}

void drawLargeStar () {
  fill (255);
  stroke (255);
  ellipse (450, 200, 150, 150);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Translate/Rotate/Scale</title>
      <link>https://forum.processing.org/two/discussion/14343/translate-rotate-scale</link>
      <pubDate>Fri, 08 Jan 2016 15:45:25 +0000</pubDate>
      <dc:creator>Razvan</dc:creator>
      <guid isPermaLink="false">14343@/two/discussions</guid>
      <description><![CDATA[<p>Hello! I did for the school a project in processing so that I can view the 3D different figures.I used the keyboard for scaling (zoom in/zoom out) and the mouse to rotate and translate. I succeeded to make all of things,but after I gave a zoom in or zoom out to figure,I can not to translate or rotate this figure until I refresh it.  I have an impression that the process of scale is in a contradiction with the process of translate and rotate. Why? How can I make these processes immediately,without refresh?!</p>
]]></description>
   </item>
   <item>
      <title>Stop Recursion When Out of Boundary</title>
      <link>https://forum.processing.org/two/discussion/14671/stop-recursion-when-out-of-boundary</link>
      <pubDate>Fri, 29 Jan 2016 18:43:30 +0000</pubDate>
      <dc:creator>CharlesDesign</dc:creator>
      <guid isPermaLink="false">14671@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I created a simple recursive tree using a proto-L-System and I'd like for the recursion to stop if it goes out of the box I've drawn.
However, because of all the translations, I'm confused as to how this can be achieved.</p>

<p>I'd be very grateful if someone can point me in the right direction.</p>

<p>Many Thanks,
Charles</p>

<pre><code>// A simple recursive tree using a proto-L-System

import processing.opengl.*;
Branch axiom;
PVector cameraPos = new PVector(600, -100, 600);

void setup()
{
  size(800, 800, OPENGL);
  axiom = new Branch();
}
void draw()
{

  background(0);
  stroke(192);
  fill(255);
  translate(width/2, height);
  rotateY(frameCount*0.01);
  axiom.draw();
  if (frameCount % 50 == 0) {
    axiom.replace(0);
  }
  translate(0, height*-0.5);
  noFill();
  box(400, 600, 400);

  camera(cameraPos.x, cameraPos.y, cameraPos.z, width/2, height*0.5, 0, 0, 1, 0);
}
void mousePressed()
{
  axiom = new Branch();
}

class Branch
{
  PMatrix3D joint;
  Branch child_a;
  Branch child_b;
  Branch()
  {
    joint = new PMatrix3D();
    child_a = null;
    child_b = null;
  }
  void replace(int depth)
  {
    // still need to prevent infinite recursion:
    if (depth &gt; 16) {
      return;
    }
    // note: grow children before yourself
    if (child_a != null) {
      child_a.replace(depth+1);
    }
    if (child_b != null) {
      child_b.replace(depth+1);
    }
    // now I grow myself
    rule();
  }
  void rule()
  {
    // rule: grow offshoot branches
    // B -&gt; B (+B) (-B)
    if (child_a == null) {
      // main stem -- almost straight
      child_a = new Branch();
      child_a.joint.rotateY(random(0, PI));
      child_a.joint.rotateX(random(-PI/16, PI/16));
    }
    if (child_b == null) {
      // branching off
      child_b = new Branch();
      child_b.joint.rotateY(random(0, PI));
      child_b.joint.rotateX(random(-PI/4, PI/4));
    }
  }
  void draw()
  {
    applyMatrix(joint);
    pushMatrix();
    {
      translate(0, -height/8, 0);
      box(10, height/4, 10);
    }
    popMatrix();
    pushMatrix();
    {
      translate(0, -height/4, 0);
      scale(0.7);
      if (child_a != null) {
        child_a.draw();
      }
    }
    popMatrix();
    pushMatrix();
    {
      translate(0, -height/4, 0);
      scale(0.7);
      if (child_b != null) {
        child_b.draw();
      }
    }
    popMatrix();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Problem with 2D transformation..</title>
      <link>https://forum.processing.org/two/discussion/14621/problem-with-2d-transformation</link>
      <pubDate>Tue, 26 Jan 2016 07:47:10 +0000</pubDate>
      <dc:creator>somyungoh</dc:creator>
      <guid isPermaLink="false">14621@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I'm trying to implement screen zooming in/out by axis from mouse position.
My very first idea was this:</p>

<pre><code>    translate(-mouseX,-mouseY);
    scale(scaling);
    translate(mouseX,mouseY);
</code></pre>

<p>Here is my code:</p>

<pre><code>//Code Starts
void settings(){
  size(600,400,OPENGL);
}

void setup(){
  background(0);

  scaleLevel=1;
  xAxis=0;
  yAxis=0;
}

void draw(){
  background(0);
  transform();
  drawRects();
}

void drawRects(){
  for(int i=0; i&lt;24;i++){
    for(int j=0; j&lt;15; j++){
      fill(255);
      rectMode(LEFT);
      rect(i*25,j*25,i*25+20,j*25+20);
    }
  }
}

void mouseWheel(MouseEvent event) {

    //Update Scale Axis
    xAxis = mouseX;
    yAxis = mouseY;

    //This method controls scaleLevel variable
    if(event.getCount()==-1)
      scaleLevel += 0.2;
    else if(event.getCount()==1)
      if(scaleLevel&gt;=1.2)
        scaleLevel -= 0.2;
      else
        scaleLevel = 1;

    System.out.println("Heatmap&gt;&gt; Scale Level: "+scaleLevel);
}

void transform(){
   translate(-1*xAxis,-1*yAxis);
   scale(scaleLevel);
}


float scaleLevel;
int xAxis;
int yAxis;
</code></pre>

<p>However, when I tested this, the axis seemed to move little bit more forward, which mouseX,Y wasn't the axis.
sperate transformation worked fine, but when I come all three together, the result goes unpredictable.
<img src="https://forum.processing.org/two/uploads/imageupload/645/5AME1455YKTP.jpg" alt="Untitled-1" title="Untitled-1" />
<img src="https://forum.processing.org/two/uploads/imageupload/453/CDTFM8YPPHI0.jpg" alt="Untitled-2" title="Untitled-2" /></p>
]]></description>
   </item>
   <item>
      <title>How to scale/translate a picture ?</title>
      <link>https://forum.processing.org/two/discussion/14490/how-to-scale-translate-a-picture</link>
      <pubDate>Sat, 16 Jan 2016 01:22:42 +0000</pubDate>
      <dc:creator>PingouinMazo</dc:creator>
      <guid isPermaLink="false">14490@/two/discussions</guid>
      <description><![CDATA[<p>Hi there ! Just new on Processing, i was wondering about how can i do to translate a picture, but on the Z-axis !! I can move it on X and Y, but it can't find out for the Z-axis :(</p>

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

<p>PImage img3;
float i = 1;</p>

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

<p>size(1000,1000,P3D);
background(0,0,0);
img3 = loadImage("logo.png");</p>

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

<p>scale(1,1,i);
  imageMode(CENTER);<br />
  image(img3,width/2,height/2);
  i = i/2;</p>

<p>}</p>

<p>I'm sorry if it's an easy question, but i've tried a lot of things, like scale and translate : i just succeeded with some text, but i can't find out for a picture !</p>

<p>Thanks for your replies !!</p>
]]></description>
   </item>
   <item>
      <title>Filtering on image resize</title>
      <link>https://forum.processing.org/two/discussion/12902/filtering-on-image-resize</link>
      <pubDate>Fri, 09 Oct 2015 02:34:48 +0000</pubDate>
      <dc:creator>ch3</dc:creator>
      <guid isPermaLink="false">12902@/two/discussions</guid>
      <description><![CDATA[<p>I want to scale up a PImage or a PGraphics ten times or more, but rather than a smooth interpolation, I want none so the pixels appear likes big blocks.
I tried to run the noSmooth() function before the image() or scale()/.resize(), but I didn't see any difference in the result.</p>

<p>Any ideas?</p>
]]></description>
   </item>
   <item>
      <title>deleted</title>
      <link>https://forum.processing.org/two/discussion/13636/deleted</link>
      <pubDate>Tue, 24 Nov 2015 23:48:54 +0000</pubDate>
      <dc:creator>FrankOcean</dc:creator>
      <guid isPermaLink="false">13636@/two/discussions</guid>
      <description><![CDATA[<p>i have several OBJ files from my 3D CAD Design and i will like to bring it in to processing for interactive gui for arduino project</p>
]]></description>
   </item>
   <item>
      <title>Line Chart</title>
      <link>https://forum.processing.org/two/discussion/13703/line-chart</link>
      <pubDate>Mon, 30 Nov 2015 06:50:40 +0000</pubDate>
      <dc:creator>roshani</dc:creator>
      <guid isPermaLink="false">13703@/two/discussions</guid>
      <description><![CDATA[<p>Hi !</p>

<p>I saw many library available for line chart.</p>

<p>I also want zoom in &amp; zoom out function in line chart.</p>

<p>Any library which provide zoom in &amp; zoom out feature.</p>

<p>Thanks</p>
]]></description>
   </item>
   </channel>
</rss>