 Hello everyone, my name is Mr. Sandesh Pare, I am currently working as an assistant professor in the department of computer science and engineering at Vulture Institute of Technology, Sallapur. In this video, I am going to explain the algorithm to draw the line, which is known as Braceram's line drawing algorithm. So let us start by the learning outcome. At the end of the session, students will be able to apply this Braceram's algorithm to draw the line on the computer screen. So let us discuss about the line drawing algorithm. At the very starting, we will discuss about what should be the desired characteristics of the target line. First point is the start point. So this point is the initiation of any line. We can define it by saying the x and y coordinate. Using the x and y coordinate, we can define that starting point of any line and same is the end line. End of the line can also be denoted by the x and y coordinate of a particular line. So the starting and ending point of the line will automatically generate intermediate points, which will connect that point and make a line. So the next characteristic is the straightness. Whatever the line which is connecting the start to end point, it should be in the straight format. And the pixels which connects from the starting point to the end point, it should hold the same brightness. It should not happen that certain pixel is a little bit dark and certain pixel is little bit brighter. They should have the equal brightness along with the line. It means from the starting to the ending. And next characteristic is the rapidity. It should draw the line in very rapid manner. It should not take very long time to draw the line on the computer screen. And the next one is the directionless. It means your line should be a directionless line. It means you can start from any point to the next end line. It means you can change the start point and end point. Though it should be the same line, it means it should be directionless so that you can draw the line in any direction. So now we will discuss about the Bresenheim's line drawing algorithm. And this algorithm is at very first built or we can say developed to the digital plotters. But even though it is used for the CRT raster devices, CRT raster devices is nothing but the cathode ray tubes. So Bresenheim's line drawing algorithm can be used for this both devices. It means but actually it is developed for the digital plotters. And the job in the Bresenheim's line drawing algorithm is to seek or to find the exact locations or the pixels in between the starting point to the end point which will lead a straight line. And two major terms are here which are not discussed or which are not present in the last line drawing algorithm. We discussed that is the DD algorithm. The first one is the slope of the line. What is the slope of the line? It is used to define out whatever the bending of the line towards the particular location. Slope of the while building when we connect the start point to the end point at that time in the algorithm we should increment the x value or the y value after every step. So to decide to whether increment x or y in every step it is very helpful to understand the slope of the line so that we can lead to a perfect line. And second one is the error line. Error means we are updating the x or y value according to the slope and based on this the other parameter is incremented or decremented is decided on the terms error that is the distance between the actual line to the nearest grid line. So this is the basis of Bresenheim's algorithm. As you can see in this diagram there is a line which is passing through 0 to the next pixel and as we can see there is one diagonal line in between the pixel which is connecting the 0 to 1. And the desired line is compared with that diagonal line and on that basis the slope of the line is decided. So we can say that 0.5 value is the slope of the diagonal one so that if the particular target line is holding the slope greater than 0.5 and obviously less than 1 it means the vertical line will holding the slope line slope value 1 and the horizontal value is the 0 about the particular slope of the line. So the slope between 0.5 to the 1 will give you the error term greater than equal to 0 so that we can we have to plot the 1 1 pixel it should be our next pixel and if the slope the value is in between the 0 to 0.5 then obviously error bit will be the less than 0 it means it will hold the minus values in that case we will have to move towards 1 0 pixel that is we have to move horizontally okay means on particular y value okay we should move vertically or the horizontally or diagonally it is decided on the slope value and on that basis the error term is measured okay according to we have to move to the next pixel and in that the sign I once again repeat that sign of the error bit will help us to find out the direction of the next pixel okay so what is the problem statement in the brazen and flat algorithm that is there should be a two points first one is the starting and another one is the end point and we have to connect them as we can say we are dealing with the graphics algorithm we direct cannot draw the line okay we have to mark the pixels intermediate between the starting to end point and on that pixel we have to mark certain color there for that we can use the put pixel method so examples are 0 0 to 5 what should be the 0 0 to 5 5 intermediate pixels that is 1 1 2 2 3 4 it means it is moving diagonally and in the second example 0 2 to 0 6 it means 0 3 0 4 0 5 are the intermediate points in this we are moving horizontally so on that basis we have to find the intermediate pixel is the job of any line drawing algorithm so there is one question for you guys that what are the terms error and slope and how they will effect in the drawing the line so the answer is the algorithm 6 to select the optimum raster location it means the intermediate pixels which would help the drawing of the straight line and to implement this we have to increment the x or y value okay so which value should be actually incremented it is based on the slope of the line and we are going to increment that particular variable and what about the other variable okay so whether it should be incremented by 0 or 1 it is decided on the terms the error the sign of the error bit will decide it okay and it is nothing but the distance between okay that the actual line and the nearest grid location so we can discuss now the algorithm as you can see the x and y value are holding the starting point values and dx and dy are the distance between the x and y okay the m term is the slope okay now we are calculating the dy by dx it means on the x axis means we are moving x by x means one by one in the x direction and for each step in the x how much y value should be incremented it is calculated in the slope one okay and error bit as the starting always less than 0.5 by the slope it is the initial value of any error sign okay and after that as you can see the one by one step we are going to increment the x value and whatever the x y values are current values according to that we are setting the pixel and until okay as I said until the error bit becomes the sorry until the error bit is greater than 0 it means the as I said the sign of the error bit will decide to move horizontally vertically or diagonally okay according to that we will increment into the y axis okay and each step error bit will be decremented and whenever we get this negative error bit at that time we will drop that low okay and at that time we will move to the next step of the x and error bit will again set okay incremented by the slope value so that it should be positive so these are some calculation as you can see uh 00255 location is there slope is 1 and error bit is 0.4 at initial and according to the our algorithm the value will will be x of y or will be incremented and error bit will always negative positive it is the difference between these slope values so this is the output screen you can see on the screen okay after execution of the program so these are some references I used to make this video thank you