This discussion is archived
7 Replies Latest reply: Dec 14, 2012 12:53 AM by 795605 RSS

Help with understanding drawPolygon()

795605 Newbie
Currently Being Moderated
I have a triangle that I want to draw using drawPolygon(). This is what I have:
public void paint(Graphics g)
    {
        int[] xPoints =
        {
            30, 70, 40
        };
        int[] yPoints =
        {
            30, 30, 60
        };
        Polygon imageTriangle = new Polygon(xPoints, yPoints, 3);
        g.drawPolygon(imageTriangle);
    }
So this is what am understanding:

We have three points, (30, 30), (70, 30) and (40, 60), right?

From a cartesian plane, this will display an upright pyramid. But the actual program runs producing an upside-down odd shaped triangle.

Am I missing something? What do I need to do in order to display an upright pyramid?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points