Primitive Graphics
Primitive Graphics
PRESENTED BY
NAME TULIKA BHARDWAJ SHARVARI KAPDI MANOJ SHRIWASTAVA ROHIT KOUL ROLL NO 04 19 48 22
PRIMITIVE OPERATIONS
Graphics system offer a similar set of graphics primitive commands. The first primitive command we shall consider is that for drawing s line segment.
COMMANDS:
LINE-ABS-2(X,Y)
LINE-REL-2(DX,DY) MOVE-ABS-2(X,Y) MOVE-REL-2(DX,DY)
It contain the information necessary to construct the picture. The information will be in the form of instructions such as draw a line or move a line. Each instructions indicates a MOVE or a LINE, action for the display device.
We use display file interpreter to convert these instructions into actual images.
USER PROGRAM
DISPLAY FILE
INTERPRETE R
DISPLAY
FEATURES:
Portability Interpreter converts standard display instructions to the actions of the particular device. Such files of imaging instructions are called as metafiles
UNIVERSITY QUESTIONS:
Create a display file for the following images display device having dimensions Xmin=10,Ymin=7,Xmax=35,Ymax=42
(5,10) (22,10) (16,15) (15,18) (5,18) (13,31) (29,31) Xmax,Ymax (32,15)
Xmin,Ymin
Different display devices may have different screen sizes as measured in pixel.
The device independent units are called normalized device coordinates. In these units the screen measures 1 unit wide and 1 unit height.
(0,1)
(1,1)
(0,0)
(1,0)
CONTD:
Suppose that for the actual display the index of the leftmost pixel is WIDTH-START and there are WIDTH pixels in the horizontal direction.
Suppose also that the bottommost pixel is HEIGHTSTART and the number of pixels in the vertical direction is HEIGHT
For horizontal dirction: Xs=WIDTH* Xn +WIDTH -START For vertical direction: Ys =HEIGHT*Yn+HEIGHT- START
UNIVERSITY QUESTION:
Represent the given image in normalized coordinates. Consider the current boundary parameters of the screen be Xmin=10,Ymin=10,Xmax=250,Ymax=250
(100,80)
(50,100) (70,100)
(130,100)
(150,100)
(70,200)
(130,200)
Operation code (opcode) :- It indicates what type of command it is (e.g. LINE or MOVE). Operand :- They represent the coordinates of a point (x,y).
One for the operation code (DF-OP). One for the X- coordinate (DF-X). One for the Y- coordinate (DF-Y).
The Display must be large enough to hold all the commands needed to create our image.
DF-OP[FREE]<- OP; DF-X[FREE]<-X; DF-Y[FREE]<-Y; FREE<-FREE+1; RETURN; END This algorithm stores the operation code and the coordinates of the specified position in the display file. The pointer FREE to the next free cell is incremented so that it will be in the correct position for the next entry.
This algorithm is for our display file interpreter. The interpreter will read the instructions from the portion of the display file and carry out the appropriate LINE or MOVE commands. ALGORITHM DOMOVE(X,Y):
Arguments Global X,Y ( Point to which to move ). FRAME-PEN-X , FRAME-PEN-Y. (Actual screen coordinates). WIDTH,HEIGHT . (the screen dimensions) WIDTH-START,HEIGHT-START. (coordinates of the lower-left corner). WIDTH-END,HEIGHT-END. (Coordinates of the upper right corner).
BEGIN
FRAME-PEN-X <- MAX(WIDTH-START, MIN(WIDTH-END, X*WIDTH+WIDTH-START)); FRAME-PEN-Y <- MAX(HEIGHT-START, MIN(HEIGHT-END, Y*HEIGHT+HEIGHT-START)); RETURN; END;
In this algorithm we see the formula for converting the normalised coordinates values of arguments into actual screen coordinates. The MAX,MIN functions have been added to formula because they prevent it from ever generating a value outside the bonds of the actual display.
DISPLAY CONTROL
In order to show the picture describe in the display file, we might have to do three things
To clear the current display. To interpret the display file. On some devices an explicit action is requierd to show the content of the frame buffer on some devices(eg. Line printer and standard CRT terminals). It is not necessary to clear the display everytime we interpret the display file . Sometimes we just have to make some additions in the image so there is no need to clear the image and redraw it again.
CONTD:
We handle clearing of the frame by using a flag. We use a true value to indicate that the screen should be cleared and false value to mean that the display file instruction may be drawn on top of the old image.
THANK YOU