title: Clip line to screen coordinates
body: <p>I have line that is defined as two points.
  start = (xs,ys)
  end = (xe, ye)</p>
  
  <p>Drawing function that I'm using Only accepts lines that are fully in screen coordinates.
  Screen size is (xSize, ySize).</p>
  
  <p>Top left corner is (0,0). Bottom right corner is (xSize, ySize).</p>
  
  <p>Some other funcions gives me line that that is defined for example as start(-50, -15) end(5000, 200). So it's ends are outside of screen size.</p>
  
  <p>In C++</p>
  
  <pre><code>struct Vec2
  {
   int x, y
  };
  
  Vec2 start, end //This is all little bit pseudo code
  Vec2 screenSize;//You can access coordinates like start.x end.y
  </code></pre>
  
  <p>How can I calculate new start and endt that is at the screen edge, not outside screen.
  I know how to do it on paper. But I can't transfer it to c++.
  On paper I'm sershing for point that belongs to edge and line. But it is to much calculations for c++.</p>
  
  <p>Can you help?</p>