title: How to draw a triangle with border with Java Graphics
body: <p>I'm trying to draw a triangle with a border using the <code>Graphics.drawPolygon()</code> method</p>
  
  <p>The triangle is properly drawn, but how can I calculate the 3 points of the border?</p>
  
  <p>I already did it with a circle, but I can't seem to find a solution for triangle.</p>
  
  <p><strong>A requirement of the instructor as that it cannot use <code>Graphics2D</code>.</strong> </p>
  
  <p>My code:</p>
  
  <pre><code>if (xPoints != null &amp;&amp; yPoints != null) {
      int[] nXPoints = new int[] { xPoints[0] - borderThickness, xPoints[1] - borderThickness,
              xPoints[2] - borderThickness };
      int[] nYPoints = new int[] { yPoints[0] - borderThickness, yPoints[1] - borderThickness,
              yPoints[2] - borderThickness };
  
      g.setColor(borderColor);
      g.fillPolygon(nXPoints, nYPoints, 3);
  
      g.setColor(fillColor);
      g.fillPolygon(xPoints, yPoints, 3);
  }
  </code></pre>
  
  <p><strong>Edit:</strong>
  <strong>Expected result</strong></p>
  
  <p><a href="https://i.stack.imgur.com/aGF4S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aGF4S.png" alt="Expected result"></a></p>