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
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.
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
Check out the resources (tutorials, references. examples) available here:
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.
You are a champ, may peace be upon you
This is an example to try:
int x = mouseX;
int y = mouseY;
//Text to console
//Text on screen
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.
Thanks champ. I really appreciate your benevolence. Thanks again