For some reason... (y axis)

For some reason processing having it's Y part of a general cartesian system upside down, has got me thinking all the time that my left is right, and right is left. My pong game paddles didn't help either.

Has this by chance happened to anyone else?

Answers

  • You can use translate(width>>1, height>>1) place the (0,0) coordinates at the center of canvas! ;))

  • And if you want to flip the Y axis, you can use scale(1, -1). You should probably read the reference for translate() and scale() first, though...

  • edited February 2014

    you wrote:

    it's Y part of a general cartesian system upside down, has got me thinking all the time that my left is right, and right is left.

    err... Y is for top and bottom, not for left / right - so your remark seems a little weired...

    you should really read the tutorials :

    http://www.processing.org/tutorials/drawing/

    I wouldn't also recommend the ideas of gotoloop and calsign

    just use the coordinate system as it is and get used to it... ;-)

  • I know that it is weird precisely because it is top/bottom left/right :P

    And yeah I'm just gonna be getting used to it! =D

    One of these I'm just gonna have to go through the entire reference... And all the tutorials ;)

  • Answer ✓

    ;-)

  • edited February 2014

    Well... Theres goes another ~24 hours straight of just sitting in my chair, and for the most part that I can remember... Coding.

    Since this topic has something to do with ups and downs, the blue wave was supposed to be going the other direction :P

    This is one of the things I worked on:

    psst! Press 'm'! psst again! Click and drag with the mouse!

    void setup()
    {
      size(640, 640);
    }
    
    int res = 640;
    int strokeWeight = 1;
    
    float[] lineCOS = new float[res];
    float[] lineSIN = new float[res];
    float[] lineCIRCLE = new float[res];
    float time = 0;
    boolean mode = true;
    
    
    void draw()
    {
      background(255);
      rectMode(CORNERS);
      ellipseMode(CENTER);
      strokeWeight(strokeWeight);
    
      //Getting the mouse pos
      time += .025;
      if (mousePressed)
        {
           lineCOS[res-1] = mouseY; 
           lineSIN[res-1] = mouseX;
        }
        else
        {
          lineCOS[res-1] = int(height/2 + cos(time)*height/2);
          lineSIN[res-1] = int(height/2 + sin(time)*height/2);
        }
    
    
      // Drawing the lines
    
    
       // Red
      stroke(255, 0, 0);
      for (int i = 1; i < res; i++)
      {
        line(i-1, lineCOS[i-1], i, lineCOS[i]);
      }
    
      if (mode)
      {
      line(0, lineCOS[320], width, lineCOS[320]);
      ellipse(height/2, lineCOS[320], 25, 25);
      }
      else
      {
    
      }
    
      if (mode == false)
      {
        line(width, lineCOS[639], lineSIN[639], lineCOS[639]);
      }
    
    
    
      // Blue
      stroke(0, 0, 255);
      for (int i = 1; i < res; i++)
      {
        line(lineSIN[i-1], i-1, lineSIN[i], i);
      }
    
      if (mode)
      {
      line(lineSIN[320], 0, lineSIN[320], height);
      ellipse(lineSIN[320], width/2, 25, 25);
      }
      else
      {
    
      }
    
      if (mode == false)
      {
        line(lineSIN[639], height, lineSIN[639], lineCOS[639]);
      }
    
    
    
      // Green
      stroke(0, 255, 0);
    
      if (mode)
      {
      line(width/2, height/2, lineSIN[320], lineCOS[320]);
      for (int c = 1; c < 320; c++)
      {
        line(lineSIN[c-1], lineCOS[c-1], lineSIN[c], lineCOS[c]);
      }
      ellipse(lineSIN[320], lineCOS[320], 25, 25);
      }
      else
      {
        line(width/2, height/2, lineSIN[639], lineCOS[639]);
        for (int c = 1; c < 639; c++)
        {
          line(lineSIN[c-1], lineCOS[c-1], lineSIN[c], lineCOS[c]);
        }
        ellipse(lineSIN[639], lineCOS[639], 25, 25);
      }  
    
      // Setting the variables
      for (int b = 1; b < res; b++)
      {
        lineCOS[b-1] = lineCOS[b];
      }
    
      for (int b = 1; b < res; b++)
      {
        lineSIN[b-1] = lineSIN[b];
      }
    
        for (int b = 1; b < res; b++)
      {
        lineCIRCLE[b-1] = lineCIRCLE[b];
      }
    
      println(frameRate);
    
    }
    
    void keyPressed()
    {
      if (key == 'm')
      {
        mode = !mode; 
      }
    }
    
Sign In or Register to comment.