math.answers.com/other-math/C_program_to_draw_parallel_lines

Preview meta tags from the math.answers.com website.

Linked Hostnames

8

Thumbnail

Search Engine Appearance

Google

https://math.answers.com/other-math/C_program_to_draw_parallel_lines

C program to draw parallel lines? - Answers

/* This is an incomplete program. The function below will draw two parallel lines, but depends on a putpixel function that is not defined here. Also of course needs a main function calling it somewhere, and all the other usual necessities. */ /* draw a line from point (x1, y1) to point (x2, y2) and another one that is (xoffset, yoffset) pixels away from it. Uses Bresenham's line algorithm and depends on a "putpixel" function */ void pline(int x1, int y1, int x2, int y2, int xoffset, yoffset){ int n, deltax, deltay, sgndeltax, sgndeltay, deltaxabs, deltayabs, x, y, drawx, drawy; deltax = x2 - x1; deltay = y2 - y1; deltaxabs = abs(deltax); deltayabs = abs(deltay); sgndeltax = sgn(deltax); sgndeltay = sgn(deltay); x = deltayabs >> 1; y = deltaxabs >> 1; drawx = x1; drawy = y1; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); if(deltaxabs >= deltayabs){ for(n = 0; n < deltaxabs; n++){ y += deltayabs; if(y >= deltaxabs){ y -= deltaxabs; drawy += sgndeltay; } drawx += sgndeltax; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); } }else{ for(n = 0; n < deltayabs; n++){ x += deltaxabs; if(x >= deltayabs){ x -= deltayabs; drawx += sgndeltax; } drawy += sgndeltay; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); } } }



Bing

C program to draw parallel lines? - Answers

https://math.answers.com/other-math/C_program_to_draw_parallel_lines

/* This is an incomplete program. The function below will draw two parallel lines, but depends on a putpixel function that is not defined here. Also of course needs a main function calling it somewhere, and all the other usual necessities. */ /* draw a line from point (x1, y1) to point (x2, y2) and another one that is (xoffset, yoffset) pixels away from it. Uses Bresenham's line algorithm and depends on a "putpixel" function */ void pline(int x1, int y1, int x2, int y2, int xoffset, yoffset){ int n, deltax, deltay, sgndeltax, sgndeltay, deltaxabs, deltayabs, x, y, drawx, drawy; deltax = x2 - x1; deltay = y2 - y1; deltaxabs = abs(deltax); deltayabs = abs(deltay); sgndeltax = sgn(deltax); sgndeltay = sgn(deltay); x = deltayabs >> 1; y = deltaxabs >> 1; drawx = x1; drawy = y1; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); if(deltaxabs >= deltayabs){ for(n = 0; n < deltaxabs; n++){ y += deltayabs; if(y >= deltaxabs){ y -= deltaxabs; drawy += sgndeltay; } drawx += sgndeltax; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); } }else{ for(n = 0; n < deltayabs; n++){ x += deltaxabs; if(x >= deltayabs){ x -= deltayabs; drawx += sgndeltax; } drawy += sgndeltay; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); } } }



DuckDuckGo

https://math.answers.com/other-math/C_program_to_draw_parallel_lines

C program to draw parallel lines? - Answers

/* This is an incomplete program. The function below will draw two parallel lines, but depends on a putpixel function that is not defined here. Also of course needs a main function calling it somewhere, and all the other usual necessities. */ /* draw a line from point (x1, y1) to point (x2, y2) and another one that is (xoffset, yoffset) pixels away from it. Uses Bresenham's line algorithm and depends on a "putpixel" function */ void pline(int x1, int y1, int x2, int y2, int xoffset, yoffset){ int n, deltax, deltay, sgndeltax, sgndeltay, deltaxabs, deltayabs, x, y, drawx, drawy; deltax = x2 - x1; deltay = y2 - y1; deltaxabs = abs(deltax); deltayabs = abs(deltay); sgndeltax = sgn(deltax); sgndeltay = sgn(deltay); x = deltayabs >> 1; y = deltaxabs >> 1; drawx = x1; drawy = y1; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); if(deltaxabs >= deltayabs){ for(n = 0; n < deltaxabs; n++){ y += deltayabs; if(y >= deltaxabs){ y -= deltaxabs; drawy += sgndeltay; } drawx += sgndeltax; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); } }else{ for(n = 0; n < deltayabs; n++){ x += deltaxabs; if(x >= deltayabs){ x -= deltayabs; drawx += sgndeltax; } drawy += sgndeltay; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); } } }

  • General Meta Tags

    22
    • title
      C program to draw parallel lines? - Answers
    • charset
      utf-8
    • Content-Type
      text/html; charset=utf-8
    • viewport
      minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no
    • X-UA-Compatible
      IE=edge,chrome=1
  • Open Graph Meta Tags

    7
    • og:image
      https://st.answers.com/html_test_assets/Answers_Blue.jpeg
    • og:image:width
      900
    • og:image:height
      900
    • og:site_name
      Answers
    • og:description
      /* This is an incomplete program. The function below will draw two parallel lines, but depends on a putpixel function that is not defined here. Also of course needs a main function calling it somewhere, and all the other usual necessities. */ /* draw a line from point (x1, y1) to point (x2, y2) and another one that is (xoffset, yoffset) pixels away from it. Uses Bresenham's line algorithm and depends on a "putpixel" function */ void pline(int x1, int y1, int x2, int y2, int xoffset, yoffset){ int n, deltax, deltay, sgndeltax, sgndeltay, deltaxabs, deltayabs, x, y, drawx, drawy; deltax = x2 - x1; deltay = y2 - y1; deltaxabs = abs(deltax); deltayabs = abs(deltay); sgndeltax = sgn(deltax); sgndeltay = sgn(deltay); x = deltayabs >> 1; y = deltaxabs >> 1; drawx = x1; drawy = y1; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); if(deltaxabs >= deltayabs){ for(n = 0; n < deltaxabs; n++){ y += deltayabs; if(y >= deltaxabs){ y -= deltaxabs; drawy += sgndeltay; } drawx += sgndeltax; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); } }else{ for(n = 0; n < deltayabs; n++){ x += deltaxabs; if(x >= deltayabs){ x -= deltayabs; drawx += sgndeltax; } drawy += sgndeltay; putpixel(drawx, drawy); putpixel(drawx + xoffset, drawy + yoffset); } } }
  • Twitter Meta Tags

    1
    • twitter:card
      summary_large_image
  • Link Tags

    16
    • alternate
      https://www.answers.com/feed.rss
    • apple-touch-icon
      /icons/180x180.png
    • canonical
      https://math.answers.com/other-math/C_program_to_draw_parallel_lines
    • icon
      /favicon.svg
    • icon
      /icons/16x16.png

Links

58