Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let drawLine = (x0, y0, x1, y1, color) => {
- // Calculate "deltas" of the line (difference between two ending points)
- let dx = x1 - x0;
- let dy = y1 - y0;
- console.log("dy = "+dy);
- // Calculate the line equation based on deltas
- let D = (2 * dy) - dx;
- let y = y0;
- // Draw the line based on arguments provided
- for (let x = x0; x < x1; x++)
- {
- // Place pixel on the raster display
- putPixel(x,y,color);
- if (D >= 0)
- {
- y = y + 1;
- D = D - 2 * dx;
- }
- D = D + 2 * dy;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement