-3

Would you know a software able to convert simple drawings (done with simple instructions that can be found in paintComponent like fillRectangle, drawLine... etc) into Java instructions?

I ask this question because I'm programming a Pacman game, and i wanted to be able to randomly generate ghosts, with random color, and shapes.

Thank you.

Jerry Unkhaptay
  • 1,308
  • 1
  • 8
  • 9
  • I've no idea what specifically you're asking for other than what sounds like might be an outside library, something that is off-topic for this site. – Hovercraft Full Of Eels Feb 20 '16 at 15:41
  • Instead perhaps you will want to code your own library to do what you want. If so, this is a multi-step process that will require you to break the large problem down into much smaller steps and then you will need to solve each problem one at a time. – Hovercraft Full Of Eels Feb 20 '16 at 15:43
  • 1
    You may be looking for a class that `implements Icon`, for [example](http://stackoverflow.com/search?tab=votes&q=user%3a230513%20implements%20Icon). – trashgod Feb 20 '16 at 16:18

1 Answers1

2

Maybe you can use the Polygon class. You can create Shapes by specifying Points:

Polygon triangle = new Polygon();
triangle.addPoint(0, 0);
triangle.addPoint(15, 30);
triangle.addPoint(30, 0);
g2d.setColor( Color.RED );
g2d.fill( triangle );

The fill(...) method then just draws lines from one point to another to create the Shape and fill in the color. You can also use the draw(...) method to get the outline of the Shape.

You can also check out Playing With Shapes. It allows you to use the Shape as an Icon or even a component.

camickr
  • 321,443
  • 19
  • 166
  • 288