Computer Science, asked by bahugunapoo, 3 months ago

the graphics output area has X and Y coordinates from​

Answers

Answered by khushisuriya
0

Answer: Graphics Coordinates

Three coordinate systems describe the location of pixels on the screen:

Physical coordinates

Viewport coordinates

Window coordinates

This topic provides information on each of these coordinate systems.

In all three coordinate systems, the x-coordinate is listed before the y-coordinate.

Physical Coordinates

Physical coordinates are integers that refer to pixels in a window's client area. By default, numbering starts at 0, not 1. If there are 640 pixels, they are numbered 0-639.

Suppose your program calls SETWINDOWCONFIG to set up a client area containing 640 horizontal pixels and 480 vertical pixels. Each individual pixel is referred to by its location relative to the x-axis and y-axis, as shown in the following figure:

Physical Coordinates

The upper-left corner is the origin. The x- and y-coordinates for the origin are always (0, 0).

Physical coordinates refer to each pixel directly and are therefore integers (that is, the window's client area cannot display a fractional pixel). If you use variables to refer to pixel locations, declare them as integers or use type-conversion routines when passing them to graphics functions. For example:

ISTATUS = LINETO( INT2(REAL_x), INT2(REAL_y))

If a program uses the default dimension of a window, the viewport (drawing area) is equal to 640x480. SETVIEWORG changes the location of the viewport's origin. You pass it two integers, which represent the x and y physical screen coordinates for the new origin. You also pass it an xycoord type that the routine fills with the physical coordinates of the previous origin. For example, the following line moves the viewport origin to the physical screen location (50, 100):

TYPE (xycoord) origin

 CALL SETVIEWORG(INT2(50), INT2(100), origin)

The effect on the screen is illustrated in the following figure:

Origin Coordinates Changed by SETVIEWORG

The number of pixels hasn't changed, but the coordinates used to refer to the points have changed. The x-axis now ranges from -50 to +589 instead of 0 to 639. The y-axis now covers the values -100 to +379.

All graphics routines that use viewport coordinates are affected by the new origin, including MOVETO, LINETO, RECTANGLE, ELLIPSE, POLYGON, ARC, and PIE. For example, if you call RECTANGLE after relocating the viewport origin and pass it the values (0, 0) and (40, 40), the upper-left corner of the rectangle would appear 50 pixels from the left edge of the screen and 100 pixels from the top. It would not appear in the upper-left corner of the screen.

SETCLIPRGN creates an invisible rectangular area on the screen called a clipping region. You can draw inside the clipping region, but attempts to draw outside the region fail (nothing appears outside the clipping region).

Similar questions