Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago