Question: 3. Write a JavaScript program that implements the tollowing: Implement the Bresenham straight line algorithm Make sure that your implementation uses integer addition/subtraction operations only

 3. Write a JavaScript program that implements the tollowing: Implement the

3. Write a JavaScript program that implements the tollowing: Implement the Bresenham straight line algorithm Make sure that your implementation uses integer addition/subtraction operations only The function should get as input the starting point (2D in pixels), ending point (2D in pixels), and color (RGB), and should render the line by setting pixels in a target image according to the specified color 2. Implement the scanline triangle filling algorithm for an arbitrary triangle The algorithm works by computing the starting and ending points of HORIZONTAL scanlines and then filling between these points The function should get as input three vertices (2D in pxels), and color (RGB), and should render a filled triangle by setting pixels in a target image according to the specitied color. Two filling modes should be supported filling with a uniform color, and filling with a different random color for each scanline (to help verify the correctness of your implementation). 3. Write a program that renders random trangles and lines using random colors and locations continuously so that a new triangle or line is rendered every 0.1 seconds 4. Have buttons to toggle: line drawing, triangle drawing, fill mode for triangle deanwing (unitorm color or ditterent scanline colors), and pausing the animation 5. A skeleton program will be provided. You are not required to use the provided skeleton program and may modify it as needed. 3. Write a JavaScript program that implements the tollowing: Implement the Bresenham straight line algorithm Make sure that your implementation uses integer addition/subtraction operations only The function should get as input the starting point (2D in pixels), ending point (2D in pixels), and color (RGB), and should render the line by setting pixels in a target image according to the specified color 2. Implement the scanline triangle filling algorithm for an arbitrary triangle The algorithm works by computing the starting and ending points of HORIZONTAL scanlines and then filling between these points The function should get as input three vertices (2D in pxels), and color (RGB), and should render a filled triangle by setting pixels in a target image according to the specitied color. Two filling modes should be supported filling with a uniform color, and filling with a different random color for each scanline (to help verify the correctness of your implementation). 3. Write a program that renders random trangles and lines using random colors and locations continuously so that a new triangle or line is rendered every 0.1 seconds 4. Have buttons to toggle: line drawing, triangle drawing, fill mode for triangle deanwing (unitorm color or ditterent scanline colors), and pausing the animation 5. A skeleton program will be provided. You are not required to use the provided skeleton program and may modify it as needed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!