A quick question about the 1st chapter of Processing

Can anybody also please help me with my following query ? In the page 6 of the Processing textbook, a line has been drawn ( as can be seen in the attached picture Figure 1-6) on a graph paper and I can’t understand how the writer got the line numbers ( 1,3 , 8, 3 ) from Point A to Point B ? Neither do I understand how did the writer got those numbers in Figure 1-7 of the page 6.

It’s been a while I studied grap and as result can’t remember anything about graph !!!

Any help will be greatly appreciated. Thanks heaps :slightly_smiling_face:

1 Like

Yeah pretty much the columns are numbered in x direction and the rows/lines are numbered in y direction.

Similar to a Chess board you can therefore define a point by its column and row. Where those two meet is your point.

LINE

Two points x,y make a line

x1,y1 TO x2,y2

For a rectangle we specify the point upper left corner again as column number , row number.

The next two parameters specify width and height of the rectangle in pixels

1 Like

Hello,

Check out the resources (tutorials, references. examples) available here:
https://processing.org/

There is a good tutorial here:
Coordinate System and Shapes \ Processing.org

There is also the Coding Train on YouTube… there may be a good tutorial there.

:)

1 Like

You are a champ, may peace be upon you :revolving_hearts:

1 Like

Hello,

This is an example to try:

void setup()
  {
  size(300, 300);
  }

void draw()
  {
  background(0);
  int x = mouseX;
  int y = mouseY;
  
  //Text to console
  println(x, y);
  
  //Text on screen
  textSize(16);
  textAlign(CENTER);
  text(str(x) + ", " + str(y), x, y);
  }    

As you move the mouse around it displays the (x,y) co-ordinate on the screen and on the console.

:)

1 Like

Thanks champ. I really appreciate your benevolence. Thanks again :revolving_hearts:

1 Like