<?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 screenx() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=screenx%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:03:47 +0000</pubDate>
         <description>Tagged with screenx() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedscreenx%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Use a shape as a button</title>
      <link>https://forum.processing.org/two/discussion/26649/use-a-shape-as-a-button</link>
      <pubDate>Sun, 04 Mar 2018 23:01:05 +0000</pubDate>
      <dc:creator>Peridactite</dc:creator>
      <guid isPermaLink="false">26649@/two/discussions</guid>
      <description><![CDATA[<p>Here I have a box that is supposed to open when the door is clicked. Right now I have it so that when the user clicks the cube it opens. This works, except it doesn't account for the cube having been rotated. How would I set it up so it listens to the actual object not some area of the screen?</p>

<pre><code>angle = 0;
open = false;
closed = false;
var door;

function setup() {
  createCanvas(500,500, WEBGL);
}
function openSesame(){
    if(open){
        if(angle &gt; (PI/4)){
            running = false;
            rotateZ(PI/4);
        } else{
        rotateZ(angle);
        }
    } else {
        // rotateZ(PI/4);
    }
}



function draw() {
    // print(mouseX + ' ' + mouseY);
    background(175);
    rectMode(CENTER);
    fill(0, 255,255);
    //rect(0,0,150,200);
    rotateX(PI/6);
    rotateY(-PI/4);
    box(100);

    fill(0,0,0);
    translate(0,50,50);
    rotateY(PI/2);

    openSesame();
    translate(-5,-50,0);
    door = box(10,100,100);
    angle += .01;


}
function mousePressed() {

    if ((mouseX &gt; (width/2 - 50) &amp;&amp; mouseY &gt; (height/2 - 50))
    &amp;&amp; (mouseX &lt; (width/2 + 50) &amp;&amp; mouseY &lt; (height/2 + 50))){
        print("ok");
        if(open){
            open = false;
            closed = true;
        }else{
            open = true;
            closed = false;
        }
    }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Moving grid to position where mouse is clicked</title>
      <link>https://forum.processing.org/two/discussion/25846/moving-grid-to-position-where-mouse-is-clicked</link>
      <pubDate>Sat, 06 Jan 2018 13:38:11 +0000</pubDate>
      <dc:creator>processing_newbie123</dc:creator>
      <guid isPermaLink="false">25846@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I have been trying to solve this problem for hours. What I am aiming for is that I move the grid that is underlying the Processing screen to where my mouse is clicked, so that I can draw something from here that grows as I move the mouse.</p>

<p>Could you guys help me with this? Thank you so much!</p>

<p>Cheers~</p>
]]></description>
   </item>
   <item>
      <title>3D Mouse click in a box</title>
      <link>https://forum.processing.org/two/discussion/25329/3d-mouse-click-in-a-box</link>
      <pubDate>Sat, 02 Dec 2017 05:14:56 +0000</pubDate>
      <dc:creator>yanivasaf</dc:creator>
      <guid isPermaLink="false">25329@/two/discussions</guid>
      <description><![CDATA[<p>Hi, 
I created a box beginShape, endShape and vertex. I want to be able to click on each one of the sides of the box. I was able to do it by using the picking library, but because i  want to use it in an html file i want to find a way to do it with no library using screenX and screen Y. Thanks</p>
]]></description>
   </item>
   <item>
      <title>BeginRaw() - Exclude objects outside camera view</title>
      <link>https://forum.processing.org/two/discussion/25639/beginraw-exclude-objects-outside-camera-view</link>
      <pubDate>Tue, 19 Dec 2017 12:50:10 +0000</pubDate>
      <dc:creator>ukmikeb</dc:creator>
      <guid isPermaLink="false">25639@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I'm exporting my 3D scene to PDF/DXF, but EVERYTHING in that scene is included in the output, including everything that is not visible to the camera. This makes sense I guess, but is there anyway of excluding shapes that are not visible to the camera view?</p>

<p>I could simply not draw certain shapes if I knew if something was in camera view or not I guess, so is there a way to test if a PVector is in view?</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>detect collision betw circles when 1 is rotated around exterior point?</title>
      <link>https://forum.processing.org/two/discussion/25558/detect-collision-betw-circles-when-1-is-rotated-around-exterior-point</link>
      <pubDate>Thu, 14 Dec 2017 00:06:26 +0000</pubDate>
      <dc:creator>brooklev</dc:creator>
      <guid isPermaLink="false">25558@/two/discussions</guid>
      <description><![CDATA[<p>Hey Sages,</p>

<p>I'm trying to make a game in which an image (a humanoid figure) can be flown through space to grab a circular gem. The figure can be accelerated and rotated as it moves. The figure's hand includes a "hit circle" centered on the hand with a given diameter. When the hit circle collides with the gem, the gem should disappear.</p>

<p>The following code gives me a hit circle which positions correctly as the figure moves and rotates. (The hand is to the right and below the center of the image at setup.)</p>

<pre>
  imageMode(CENTER); 
  pushMatrix(); 
  translate(figX, figY); 
  rotate(radians(figAng)); 
  image (figViz, 0, 0); 
  ellipse(handX, handY, handDia, handDia); 
  popMatrix(); 
</pre>

<p>I was doing fine until I tried to use <em>dist()</em> to check for a collision:</p>

<pre>
    if (dist(figX + handX, figY + handY, gemX, gemY) &lt; gemDia/2 + handDia/2 ) {
        gotGem = true;
        println("Huzzah!");
    }
</pre>

<p>This does not produce a collision whether I check within the push/popMatrix() code or outside of that code. Can anyone suggest what I am doing incorrectly or direct me to some resource that explains how to detect collisions between circles when one is being rotated around an exterior point?</p>

<p>Thanks much, L</p>
]]></description>
   </item>
   <item>
      <title>Translate mouse coordinates</title>
      <link>https://forum.processing.org/two/discussion/22247/translate-mouse-coordinates</link>
      <pubDate>Thu, 27 Apr 2017 15:12:58 +0000</pubDate>
      <dc:creator>Alex_Pr</dc:creator>
      <guid isPermaLink="false">22247@/two/discussions</guid>
      <description><![CDATA[<p>Is there a way to translate mouse coordinates when the canvas is also translated? In objects where mouse coordinates are used for control, this translation is useful if the object was set at position x,y of a translated canvas.</p>
]]></description>
   </item>
   <item>
      <title>Find new coordinates after translate &amp; rotation</title>
      <link>https://forum.processing.org/two/discussion/21833/find-new-coordinates-after-translate-rotation</link>
      <pubDate>Wed, 05 Apr 2017 18:10:33 +0000</pubDate>
      <dc:creator>adurante95</dc:creator>
      <guid isPermaLink="false">21833@/two/discussions</guid>
      <description><![CDATA[<p>I decided to make a simulation of a traditional boardgame spinner, that lands on one of four colors and then tells the user what color they landed on. Here is my source code thus far:</p>

<pre><code>float rotation = 1;
stepSize = 10;

void setup() { 
  size(800, 800);
  textSize(60);
}

void draw() { 
  background(255);
  strokeWeight(2);
  fill(255, 0, 0);
  rect(100, 100, 300, 300);
  fill(0, 96, 255);
  rect(100, 400, 300, 300);
  fill(255, 240, 0);
  rect(400, 100, 300, 300);
  fill(0, 255, 0);
  rect(400, 400, 300, 300);
  strokeWeight(20);

  pushMatrix();
  translate(400, 400);
  rotate(radians(rotation));
  line(0, 0, 100, 100);
  popMatrix();
  if (stepSize &gt; 0) {
    rotation += stepSize;
    stepSize -= 0.05;
  }

}

void mousePressed() {
  stepSize = random(5, 15);
}
</code></pre>

<p>However, I want to be able to determine what color the user landed on after the spinner is done and print that to the screen. For example: the spinner lands on the red box, so the screen prints out "You have landed on Red!". I have been reading about matrices and affine transformations, but I'm confused how they would pertain to this code.</p>
]]></description>
   </item>
   <item>
      <title>using modelX and screenX for 3D picking - but how?</title>
      <link>https://forum.processing.org/two/discussion/14680/using-modelx-and-screenx-for-3d-picking-but-how</link>
      <pubDate>Sat, 30 Jan 2016 10:30:30 +0000</pubDate>
      <dc:creator>Chrisir</dc:creator>
      <guid isPermaLink="false">14680@/two/discussions</guid>
      <description><![CDATA[<p>hello all,</p>

<p>I am trying to be able to click on a sphere in a 3D sketch with the mouse to <strong>select a sphere</strong>.</p>

<p>Since I use rotate and translate when placing the sphere, I wanted to use <code>modelX,modelY</code> to get the model position. But to have a match with the mouse I need <code>ScreenX,ScreenY</code>. Or so I am guessing.</p>

<p>Not sure how to handle this though:</p>

<p>this is part of class that in turn is stored in ArrayList to hold all the spheres:</p>

<pre><code>    pushMatrix(); 
      translate(x, y, z); 

      fill(col); 
      noStroke(); 

      if (showBox||true) {     
        //box(55);
        //ellipse(0, 0, 7, 7);
        sphere(7);

        // the sphere / box was drawn at (0, 0, 0), store that location
        float x1 = modelX(0, 0, 0); // this takes care of translate and rotate 
        float y1 = modelY(0, 0, 0);
        float z1 = modelZ(0, 0, 0);

        scX = screenX(x1, y1, z1); // this takes care of the projection into 2D space for the mouse
        scY = screenX(x1, y1, z1);
      }
      popMatrix(); 
</code></pre>

<p>I now want to match scX and scY with mouseX and mouseY:</p>

<pre><code>void mousePressed() {

  PVectorInt result = new PVectorInt(0, 0, 0);

  for (int i = 0; i &lt; boxes.length; i++) {
    for (int j = 0; j &lt; boxes[i].length; j++) {
      for (int k = 0; k &lt; boxes[i][j].length; k++) {

        if (dist(mouseX, mouseY, boxes[i][j][k].scX, boxes[i][j][k].scY) &lt; 40) {
          result = new PVectorInt( i, j, k); 
          listShape.add ( new  PVectorInt( i, j, k)); 
          println(listShape.size());
          return;
        }
      }
    }
  }
}
</code></pre>

<p>but it doesn't work....</p>

<p>please tell me how I handle modelX and screenX</p>

<p>thank you...!</p>

<p>Chrisir</p>
]]></description>
   </item>
   <item>
      <title>how to map a 2D coordinate into 3D...</title>
      <link>https://forum.processing.org/two/discussion/20755/how-to-map-a-2d-coordinate-into-3d</link>
      <pubDate>Sun, 12 Feb 2017 00:05:16 +0000</pubDate>
      <dc:creator>vapeur</dc:creator>
      <guid isPermaLink="false">20755@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I have a set of points in 3D and want to use mouse to alter the position of those points.
I have got the equivalent position of these points in 2D using screenX &amp; screenY (mapping 3D into 2D), but have difficulty in mapping 2D back to 3D..</p>

<p>What I want is to use the mouse's position(mouseX mouseY) to determine the position of point's Z axis (height) to be visually in the same position as my mouse.</p>

<p>is there any function to counter-screenX &amp; screenY...? (sort of sine - arcsine..if it can explain it less confusing..)</p>

<p>Let's say the position I would like to alter is</p>

<p><code>PVector pos = point.x, point.y, point.z</code></p>

<p>and I want the point.z be altered by mouseX and mouseY..
so it should be something like</p>

<pre><code>if(mouseClicked)
{
point.z = counterScreen(mouseX, mouseY);.....
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Collision detection - why not working properly?</title>
      <link>https://forum.processing.org/two/discussion/20887/collision-detection-why-not-working-properly</link>
      <pubDate>Mon, 20 Feb 2017 01:39:12 +0000</pubDate>
      <dc:creator>djevazi</dc:creator>
      <guid isPermaLink="false">20887@/two/discussions</guid>
      <description><![CDATA[<p>PeasyCam library is required.</p>

<p>I'm trying to detect a point-triangle collision using this tutorial: <a href="http://www.jeffreythompson.org/collision-detection/tri-point.php" target="_blank" rel="nofollow">http://www.jeffreythompson.org/collision-detection/tri-point.php</a> . But my sketch is 3d, so I translating a 3d coorinates in 2d using screenX() and screenY(). The problem is that when my mouse is inside of triangle, sometimes the resulting "hit" color is blinking and I have "no hit" message. Can't understand why the collision is not working properly, it must be "hit" all the time my mouse is inside of thiangle. Any suggestions? Thanks.</p>

<pre><code>import peasy.*;
PeasyCam jcam;

ArrayList &lt;Point&gt; points = new ArrayList &lt;Point&gt;();
ArrayList &lt;Triangle&gt; triangles = new ArrayList &lt;Triangle&gt;();

void setup()
{
  size(800, 800, P3D);
  smooth();
  jcam = new PeasyCam(this, 200);

  color tempColore=color(255, 255, 255);

  PVector v1= new PVector(0, 0, 0);
  Point pt1 = new Point(v1, tempColore);
  points.add(pt1);

  PVector v2= new PVector(100, 0, 0);
  Point pt2 = new Point(v2, tempColore);
  points.add(pt2);

  PVector v3= new PVector(0, 100, 0);
  Point pt3 = new Point(v3, tempColore);
  points.add(pt3);

  PVector v4= new PVector(100, 0, 0);
  Point pt4 = new Point(v4, tempColore);
  points.add(pt4);  

  PVector v5= new PVector(100, 100, 0);
  Point pt5 = new Point(v5, tempColore);
  points.add(pt5);

  PVector v6= new PVector(0, 100, 0);
  Point pt6 = new Point(v6, tempColore);
  points.add(pt6);


  //triangles initialize
  for (int i=0; i&lt;points.size(); i=i+3)
  {
    Triangle tr = new Triangle(points.get(i).pos, points.get(i+1).pos, points.get(i+2).pos);
    triangles.add(tr);
  }

}

boolean triPoint(float x1, float y1, float x2, float y2, float x3, float y3,float mx, float my) 
  {
    // get the area of the triangle
    float areaOrig = abs( (x2-x1)*(y3-y1) - (x3-x1)*(y2-y1) );

    // get the area of 3 triangles made between the point
    // and the corners of the triangle
    float area1 =    abs( (x1-mx)*(y2-my) - (x2-mx)*(y1-my) );
    float area2 =    abs( (x2-mx)*(y3-my) - (x3-mx)*(y2-my) );
    float area3 =    abs( (x3-mx)*(y1-my) - (x1-mx)*(y3-my) );

    // if the sum of the three areas equals the original,
    // we're inside the triangle!
    if (area1 + area2 + area3 == areaOrig) 
    {
      return true;
    }
    return false;
  }


void draw()
{
  background(150);

  for (int i = triangles.size ()-1; i &gt;= 0; i--)
  { 
    color tempColore=0;

    float ax = screenX(triangles.get(i).A.x,triangles.get(i).A.y);
    float ay = screenY(triangles.get(i).A.x,triangles.get(i).A.y);
    float bx = screenX(triangles.get(i).B.x,triangles.get(i).B.y);
    float by = screenY(triangles.get(i).B.x,triangles.get(i).B.y);
    float cx = screenX(triangles.get(i).C.x,triangles.get(i).C.y);
    float cy = screenY(triangles.get(i).C.x,triangles.get(i).C.y);
    float mx = mouseX;
    float my = mouseY;

    boolean hit = triPoint(ax,ay,bx,by,cx,cy,mx,my);

    if(hit==true)
    {
      tempColore = #A57066;
      println("hit");
    }
    else
    {
      tempColore = #CEBE9A;
      println("no hit");
    }
    triangles.get(i).display(tempColore);
  }


  for (int i = points.size ()-1; i &gt;= 0; i--)
  { 
    points.get(i).display();
  }

}


class Point
{
  PVector pos;
  color colore;


  Point(PVector posIn, color coloreIn)
  {
    pos = posIn;
    colore=coloreIn;
  }

  void display()
  {
    colorMode(RGB);
    noStroke();
    fill(colore);
    pushMatrix();
    translate(pos.x,pos.y,pos.z);
    box(1);
    popMatrix(); 
  }
}


class Triangle
{
  PVector A, B, C;
  color colore;

  Triangle (PVector Ain, PVector Bin, PVector Cin)
  {
    A=Ain;
    B=Bin;
    C=Cin;
  }

  void display(color coloreIn)
  {
    colore = coloreIn;
    fill(colore);
    beginShape(TRIANGLE);
    stroke(255,20);
    strokeWeight(2);
    vertex(A.x,A.y,A.z);
    vertex(B.x,B.y,B.z);
    vertex(C.x,C.y,C.z);
    endShape();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Mouse position relative to transformations?</title>
      <link>https://forum.processing.org/two/discussion/20862/mouse-position-relative-to-transformations</link>
      <pubDate>Sat, 18 Feb 2017 13:27:55 +0000</pubDate>
      <dc:creator>EagleEye7777777</dc:creator>
      <guid isPermaLink="false">20862@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I have used rotate() and translate() to move around the canvas, however, the mouseX and mouseY properties are still relative to the top left of the canvas. Is there any way to get them relative to the translated and rotated position?</p>

<p>Thanks,
Joseph.</p>

<p>P.S. let me know if you need any code samples.</p>
]]></description>
   </item>
   <item>
      <title>Is mouse over sphere in 3D?</title>
      <link>https://forum.processing.org/two/discussion/20260/is-mouse-over-sphere-in-3d</link>
      <pubDate>Sat, 14 Jan 2017 16:07:23 +0000</pubDate>
      <dc:creator>Lord_of_the_Galaxy</dc:creator>
      <guid isPermaLink="false">20260@/two/discussions</guid>
      <description><![CDATA[<p>I have a sphere somewhere, and its location is known. However, I'm also using PeasyCam, so a problem remains - I don't know the camera vectors. So, how to check if the mouse (or any other vector for that) is over the sphere?</p>

<p>My code so far-</p>

<pre><code>import peasy.*;

PeasyCam cam;

float x = 0, y = 0,z = 0;

void setup(){
  size(720, 720, P3D);
  cam = new PeasyCam(this, 200);
}

void draw(){
  translate(x, y, z);
  sphere(100);//being minimalistic

  x += sin(y);//random methods, real code is different
  y += cos(z);
  z += random(1);

  println(mouseOverSphere(x, y, z, 100);
}

boolean mouseOverSphere(float posX, float posY, float posZ, float size){
  //What to do here??
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to get the current scale (or translation and rotation, or just the current matrix)</title>
      <link>https://forum.processing.org/two/discussion/20278/how-to-get-the-current-scale-or-translation-and-rotation-or-just-the-current-matrix</link>
      <pubDate>Sun, 15 Jan 2017 12:49:38 +0000</pubDate>
      <dc:creator>San</dc:creator>
      <guid isPermaLink="false">20278@/two/discussions</guid>
      <description><![CDATA[<p>Is there any way to get the current value?  Other than printing it out to the console.</p>
]]></description>
   </item>
   <item>
      <title>3d and 2d coordinates</title>
      <link>https://forum.processing.org/two/discussion/20186/3d-and-2d-coordinates</link>
      <pubDate>Wed, 11 Jan 2017 02:34:41 +0000</pubDate>
      <dc:creator>djevazi</dc:creator>
      <guid isPermaLink="false">20186@/two/discussions</guid>
      <description><![CDATA[<p><img src="https://forum.processing.org/two/uploads/imageupload/156/EOCEA50VM4PL.jpg" alt="coords" title="coords" /></p>

<p>In 3d sketches null of coordinares begins here (green number "1"), how to make it begin there (green number "2"), like in 2d sketches? I realize that mouseX and mouseY not working properly because beginning of coordinates is not in the upper left corner.</p>
]]></description>
   </item>
   <item>
      <title>How to find verticies after rotation?</title>
      <link>https://forum.processing.org/two/discussion/20011/how-to-find-verticies-after-rotation</link>
      <pubDate>Sat, 31 Dec 2016 15:53:48 +0000</pubDate>
      <dc:creator>dsa157</dc:creator>
      <guid isPermaLink="false">20011@/two/discussions</guid>
      <description><![CDATA[<p>Hi all!</p>

<p>I have a little square I want to rotate and position it inside a bigger square. I then want to connect verticies from the bigger square to the smaller one. I don't know how to get the position of the rotated vertices.</p>

<p>I found this article:
<a href="http://math.stackexchange.com/questions/270194/how-to-find-the-vertices-angle-after-rotation" target="_blank" rel="nofollow">http://math.stackexchange.com/questions/270194/how-to-find-the-vertices-angle-after-rotation</a></p>

<p>I will try this, but wondered if processing had any built in geometry methods to make it easier.</p>

<p>Thanks in advance.</p>

<p>Dave</p>
]]></description>
   </item>
   <item>
      <title>Transformation</title>
      <link>https://forum.processing.org/two/discussion/19595/transformation</link>
      <pubDate>Thu, 08 Dec 2016 00:54:01 +0000</pubDate>
      <dc:creator>kumushkangeo</dc:creator>
      <guid isPermaLink="false">19595@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,
my problem is on transforming real World coordinates to screen coordinates in Eclipse using Processing Library. How can I do this? Can anybody guide me some tutorial or give a help? Thanks in advance.</p>
]]></description>
   </item>
   <item>
      <title>Do screenX co-ordinates remain constant after rotate?</title>
      <link>https://forum.processing.org/two/discussion/17934/do-screenx-co-ordinates-remain-constant-after-rotate</link>
      <pubDate>Mon, 22 Aug 2016 01:07:44 +0000</pubDate>
      <dc:creator>DangerousClive</dc:creator>
      <guid isPermaLink="false">17934@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I was wondering, if I were to rotate a PShape then use screenX to check a point on the Pshape, should the same co-ordinate be returned - ie. should the co-ordinates be relative to the shape before and after the transformation?</p>

<p>For example, the shape below is drawn and the co-orinates of the red pixel noted (say, x=10 y=10).
<img src="" alt="" /><img src="https://forum.processing.org/two/uploads/imageupload/666/P1Q7BQ12UHC2.png" alt="sq1" title="sq1" /></p>

<p>A rotate is then performed on it
<img src="" alt="" /><img src="https://forum.processing.org/two/uploads/imageupload/670/3VY45PPDEL5P.png" alt="sq3" title="sq3" /></p>

<p>Then using screenX, should the red pixel still be at the same co-ordinates (x=10, y=10)?</p>

<p>I hope this makes some sense!</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Converting webgl 3d coordinates to 2d screen coordinates (p5.js)</title>
      <link>https://forum.processing.org/two/discussion/17715/converting-webgl-3d-coordinates-to-2d-screen-coordinates-p5-js</link>
      <pubDate>Mon, 01 Aug 2016 10:37:11 +0000</pubDate>
      <dc:creator>brendandawes</dc:creator>
      <guid isPermaLink="false">17715@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to map html text on top of a webgl p5.js sphere of nodes that is rotating. I know I have to do something with a projection matrix and a view matrix in order to convert from 3d space to 2d but not sure how to get the matrix of the camera, if that's what I'm supposed to do? I found this which looked promising <a href="http://webglfactory.blogspot.co.uk/2011/05/how-to-convert-world-to-screen.html" target="_blank" rel="nofollow">http://webglfactory.blogspot.co.uk/2011/05/how-to-convert-world-to-screen.html</a></p>

<p>You can see an Instagram vid example here: <a href="http://brendandawes.com/blog/07-31-471" target="_blank" rel="nofollow">http://brendandawes.com/blog/07-31-471</a></p>

<p>Any help would be great. Incidentally I did something similar when using Three.js but I could get the projection matrix, with he p5.js one I'm not sure how I get that.</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>Coordinates</title>
      <link>https://forum.processing.org/two/discussion/17459/coordinates</link>
      <pubDate>Fri, 08 Jul 2016 15:04:20 +0000</pubDate>
      <dc:creator>zero1973</dc:creator>
      <guid isPermaLink="false">17459@/two/discussions</guid>
      <description><![CDATA[<p>I am conducting a transform and a rotation on a piece of text.</p>

<pre><code>pushMatrix();
translate(width/2, height/2);
rotate(radians(270));
text("test",10,20);
popMatrix();
</code></pre>

<p>It is printing the text as I want, the question is how do I get the "real" location of the text? I want to check a mouse over and I don't know where it is :)</p>

<p>Thank you in advance.</p>
]]></description>
   </item>
   <item>
      <title>"Lock Pixels" function</title>
      <link>https://forum.processing.org/two/discussion/17445/lock-pixels-function</link>
      <pubDate>Thu, 07 Jul 2016 13:16:54 +0000</pubDate>
      <dc:creator>djevazi</dc:creator>
      <guid isPermaLink="false">17445@/two/discussions</guid>
      <description><![CDATA[<pre><code>int size;
color [] ccc;
float rotAngle = 0;
color colour;
color rand;



void setup()   
{
  size(1200, 900);
  background(0);
  frameRate (50);
  smooth();
  noStroke();

  size = 20;
  ccc = new color[size*size];
  colour = color(random(255), random(255), random(255));
  rand = color(random(-50, 50), random(-50, 50), random(-50, 50));

  for (int i = 0; i &lt; size*size; i++)
  {
    rand = rand+int(random(-10,10));
    ccc[i] = colour+rand;
  }
} 



void draw()
{
  if (mousePressed)
  {
    brush01();
  }
}



void brush01()
{

  int i;
  float brush_X = 0;
  float brush_Y = 0;

  for (i =1; i&lt;size*size; i++)
  {

    if (mouseX != pmouseX || mouseY != pmouseY)
    {
      rotAngle = atan2(mouseY - pmouseY, mouseX - pmouseX);
    }

    pushMatrix();
    rectMode(CENTER);
    translate(mouseX, mouseY);
    rotate(rotAngle);
    translate(0-size/2, 0-size/2);
    fill(ccc[i]);
    println("Brush X = " + brush_X);
    println("Brush Y = " + brush_Y);
    rect(brush_X, brush_Y, 1, 1);
    popMatrix();

    brush_X ++;
    if (brush_X &gt; size)
    {
      brush_X = 0;
      brush_Y ++;
    }
  }
}



void mouseReleased()
{
  colour = color(random(255), random(255), random(255));
  rand = color(random(-50, 50), random(-50, 50), random(-50, 50));

  for (int i = 0; i &lt; size*size; i++)
  {
    rand = rand+int(random(-10,10));
    ccc[i] = colour+rand;
  }
}
</code></pre>

<p>Here is my little drawing sketch. Please, run and draw something on a canvas. I want to add something like "lock pixels" function, so if this function is on, the brush have to draw strokes only on colorful pixels of a canvas, and do not draw on black pixels. I tried to compare the pixels using "get" function, but the problem is that processing thinks my brush pixels coordinates (brush_X and brush_Y) is in the top left corner, even after translation an rotation. So, I can't compare brush pixels with canvas pixels. Any suggestions of how to make "lock pixels" function?</p>
]]></description>
   </item>
   <item>
      <title>How to find a pixel after translate and rotation?</title>
      <link>https://forum.processing.org/two/discussion/17393/how-to-find-a-pixel-after-translate-and-rotation</link>
      <pubDate>Sat, 02 Jul 2016 22:21:36 +0000</pubDate>
      <dc:creator>djevazi</dc:creator>
      <guid isPermaLink="false">17393@/two/discussions</guid>
      <description><![CDATA[<p>For example I have a pixel with coordinates (0,0), and I translate it to (mouseX,mouseY), and rotate it to "rotAngle = atan2(mouseY - pmouseY, mouseX - pmouseX)".... So many transformations. How to find an actual coordinates of this pixel?</p>
]]></description>
   </item>
   <item>
      <title>Track a 3D point from an object to get 2D xy codnates</title>
      <link>https://forum.processing.org/two/discussion/17271/track-a-3d-point-from-an-object-to-get-2d-xy-codnates</link>
      <pubDate>Wed, 22 Jun 2016 18:46:46 +0000</pubDate>
      <dc:creator>kiwilead</dc:creator>
      <guid isPermaLink="false">17271@/two/discussions</guid>
      <description><![CDATA[<p>Hey team.</p>

<p>I have a sketch that creates a 3d object much like an arrow that is rotated from the middle of its axis driven by two sensors. I am trying to get the vertex data of the tip of the 3D arrow in order to drive another function within the script. Where the 3D arrow is pointing to on the screen, I want it to effect the color of the background. Is anyone able to help me find a way of getting the data of the moving 3D tip of the arrow so I can achieve the desired result?</p>
]]></description>
   </item>
   <item>
      <title>Mouse handling with matrix transformations</title>
      <link>https://forum.processing.org/two/discussion/15611/mouse-handling-with-matrix-transformations</link>
      <pubDate>Mon, 21 Mar 2016 20:55:29 +0000</pubDate>
      <dc:creator>valkyrie</dc:creator>
      <guid isPermaLink="false">15611@/two/discussions</guid>
      <description><![CDATA[<p>I'm looking to create a menu with different clickable buttons that will float on the right side of my window, sliding around nicely when it's resized.</p>

<p>Right now, I'm accomplishing this with a transformation matrix called before drawing all the buttons. However, this breaks all my mouse handling (as the buttons now don't know where they are located on the screen). What is the "right" way to deal with this? Should I just be updating each button's location internally every time the window is resized? Or is there some way to apply an inverse matrix transform to the mouse coordinates before passing them?</p>
]]></description>
   </item>
   <item>
      <title>Is it possible to find the mouseX and mouseY with relation to the current matrix?</title>
      <link>https://forum.processing.org/two/discussion/14998/is-it-possible-to-find-the-mousex-and-mousey-with-relation-to-the-current-matrix</link>
      <pubDate>Thu, 18 Feb 2016 19:25:09 +0000</pubDate>
      <dc:creator>jomizzy</dc:creator>
      <guid isPermaLink="false">14998@/two/discussions</guid>
      <description><![CDATA[<p>From what I can tell, mouseX and mouseY always are set off of the default matrix, with the origin at the top left.  I am rotating and translating the grid, is there any way to make the mouse locations be related to that?</p>
]]></description>
   </item>
   <item>
      <title>Is there a way to track/retrieve "global" position?</title>
      <link>https://forum.processing.org/two/discussion/12729/is-there-a-way-to-track-retrieve-global-position</link>
      <pubDate>Tue, 29 Sep 2015 17:15:52 +0000</pubDate>
      <dc:creator>marcusround</dc:creator>
      <guid isPermaLink="false">12729@/two/discussions</guid>
      <description><![CDATA[<p>I have something like this,</p>

<pre><code>push(); // Start head placement.
    translate( headPosition[0], headPosition[1] );
    rotate(headRotation);
    translate( -headPosition[0], -headPosition[1] );

    push(); // Start Eye1 placement.
      translate( eye1Position[0], eye1Position[1] );
      image(imgEye, 0, 0);
    pop(); // End Eye1 placement.

    push(); // Start Eye2 placement.
      translate( eye2Position[0], eye2Position[1] );
      image(imgEye, 0, 0);
    pop(); // End Eye2 placement.

    image(imgHead, 0, 0);
pop(); // End head placement.
</code></pre>

<p>So basically using a chain of push/pop matrix to place layers in relation to each other.
Is there an easy way to find my global position?</p>

<p>If you did something like this,</p>

<pre><code>push()
  translate(100, 100);
  a = retrieveGlobalPosition();
  push()
    translate(150, -66);
    push();
      translate(-27, 50);
      b = retrieveGlobalPosition();
    pop();
    c = retrieveGlobalPosition();
  pop();
pop();
</code></pre>

<p>then a should be [100, 100]. b should be [223, 84] and c should be [250, 34]. Or something along those lines. Hopefully that makes sense. So I want to be able to easily tell where an eye is located on the canvas and make calculations based on this position.</p>

<p>Is this possible? Or is there a better way to achieve this? Maybe using p5.Vector ?</p>

<p>This is fairly simple arithmetic when all you're doing is translating, and you could probably just keep track of your transforms via a variable. But once you start using rotate() as I did in my first example its going to get very complicated.</p>

<p>Eventually I think it would make sense to start parenting these objects to each other but my programming skills are not there yet.</p>
]]></description>
   </item>
   <item>
      <title>'snap to' pixel after applying transformations</title>
      <link>https://forum.processing.org/two/discussion/12469/snap-to-pixel-after-applying-transformations</link>
      <pubDate>Thu, 10 Sep 2015 22:34:32 +0000</pubDate>
      <dc:creator>jedierikb</dc:creator>
      <guid isPermaLink="false">12469@/two/discussions</guid>
      <description><![CDATA[<pre><code>//given these coordinates for a rectangle (which I will draw with rectmode CORNER)
float layerX = -50;
float layerY = -50;
float layerW = 100;
float layerH = 100;

//and these transformations
translate( 300, 0 );
scale( 12, 1.5 );
scale( .5, .5 );

//which project those coordinates here.
float sx = screenX( layerX, layerY );
float sy = screenY( layerX, layerY );
float sw = screenX( layerX+layerW, layerY+layerH );
float sh = screenY( layerX+layerW, layerY+layerH );

//(this spits out 0, -37.5, 600, 37.5)
println( sx, sy, sw, sh );

//how do I modify the transformation to 'snap' the transformed values to [0, -38, 600, 38], effectively snapping to the pixel (and widening the rectangle)?
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to get my 2D position on the screen from a 3D model</title>
      <link>https://forum.processing.org/two/discussion/6309/how-to-get-my-2d-position-on-the-screen-from-a-3d-model</link>
      <pubDate>Sun, 13 Jul 2014 15:40:06 +0000</pubDate>
      <dc:creator>zjin3</dc:creator>
      <guid isPermaLink="false">6309@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>Like what I said in the title. I create a 3D box in a 3D coordinate system, then I change the camera setting to see from different angels. On my screen (absolutely it's 2D), the box appears at different positions. I'd like to get it's center pointer position on the screen displayed by x and y just like a 2D drawing. Any ideas?</p>

<p>Thank you</p>
]]></description>
   </item>
   </channel>
</rss>