Posts

Showing posts from February, 2015

DDA circle drawing algorithm

ALGORITHM 1 .         read the radius r ,of the circle and calculate value of E             2 n-1 <=r<2 n             E=2 -n 2   .        start_x=0               start_y=r 3           x1=start_x             y1=start_y 4                       do               {                         x2=x1+Ey1                         y2=y1-Ex2                         [x2 represents xn+1 and x1 presents xn]                           plot (int(x2),int(y2))                            x1=x2;                           y1=y2;                         [reinitialize the current point]               }while (y1-start_y)<E or (start_x-x1)>E                         [check if the current   point is the starting   point or not .if current point is                                                                  not starting point repeat step 4; otherwise stop] 5 .                      Stop.                                                  C Program

Bresenham’s Line Drawing Method

ALGORITHM               Read the line end points   (x1,y1) & (x2,y2) such that they are not equal.             If the points are same, plot the points & exit (Else continue with the            calculation)             Calculate      r x   =   |x 2 -x 1 |      r y   =   |y 2 -y 1 | 4 .                [initialize the starting point]                   x=x1                    y=y1 5 .                e = 2 * r y - r x                   [initialize value of decision variable or error to compensate for non zero                                    intercepts] 6.                               i = 1[initialize counter] 7.                               plot(x , y) 8.                               while (e ≥ 0)                              {                                     y = y+1                                                                         e =   e – 2 * r x                                }                                

DDA Line Drawing Algorithm

DDA algorithm : Define the nodes, i.e end points in form of (x1,y1) and (x2,y2). Calculate the distance between the two end points vertically and horizontally, i.e dx=|x1-x2| and dy=|y1-y2|. Define new variable name ‘pixel’, and compare dx and dy values, if dx > dy then pixel=dx else pixel =dy. dx=dx/pixel and dy=dy/pixel x=x1; y=y1; while (i<=pixel) compute the pixel and plot the pixel with x=x+dx and y=y+dy. c program for dda algorithm :   #include <graphics.h> #include <stdio.h> #include <math.h> int main( ) { float x,y,x1,y1,x2,y2,dx,dy,pixel; int i,gd,gm; printf("Enter the value of x1 : "); scanf("%f",&x1); printf("Enter the value of y1 : "); scanf("%f",&y1); printf("Enter the value of x2 : "); scanf("%f",&x2); printf("Enter the value of y1 : "); scanf("%f",&y2); detectgraph(&gd,&gm);

PROCEDURE TO CHANGE A CIRCLE INTO A SQURE USING FLASH.

Image
1.   Go to start->macromedia->flash document 2.    Select the circle tool from the tool bar. draw a circle on the work area.colour it 3.   Click on the 40 th key frame-> insert new key frame. 4.    Selecting the last key frame ->draw a rectangle on the circle by selecting the rectangle tool bar so that it will cover the circle. colour the rectangle by the different colour. 5.   Again click on the last frame->under properties ->under tween ->change the option shape from none. 6.   Then again select the last but one frame ->go to properties->tween ->change to shape. 7.   Go to control->test movie ->see the circle changing in to rectangle. OUTPUT

PROCEDURE TO DISPLAY THE BACKGROUND GIVEN (FILENAME: GARDEN.JPG) THROUGH YOUR NAME USING MASK.

Image
1.   Go to start-> macromedia-> click on flash document 2.   Go to file-> import ->open external library-> select a background image Click open. 3.   The selected image will be stored in your library. Open library and drag the image on the work area by selecting the image. 4.   go to view->zoom out ->resize the picture such that it should fit the work area. 5.insert layer2. choose the text tool from the toolbar and type your name. 6.Select the text to change its font size and colour of your choice. place the text on the left of the workarea. 2.                       Right click on the 70 th keyframe of layer 2 and insert a keyframe. move the text to the right side of the workarea ->right click on the 69 th frame of layer 2-> choose create motion tween. 3.                  right      click on layer 2 choose the option mask. 4.             Go           to control->test movie to see the animation. OUT