0

In school, we used TurtleGraphics.jar in Eclipse. The teacher told us how to draw an arrow(pen.up(); and pen.move(90);)

I understand now that you need to actually create a class for "pen." I thought it already came with Java.

Online, I've only found code like g.Rect that can draw rectangles. The "pen" class was really useful because you could go in any direction you wanted to create any shape. I'm using Netbeans at home. How do you create a "pen," and what imports would you need?

Walshy
  • 850
  • 2
  • 11
  • 32
TwixPasta
  • 11
  • 3

2 Answers2

2

You might want to look at class java.awt.Graphics2D, which contains the primitive drawing operations supported by that framework: drawing lines, arcs, rendering text and images, etc.

Javier Martín
  • 2,537
  • 10
  • 15
0

Turtle graphics was some kind of a begginers tools-set to begin with the graphics section of java, that you use at school so you don't get bummered when you start your travel in programmer's world. Java contains a lot of libraries with ready-set-go classes that you can import in your code in order to help you create shapes, draw, or make your drawings move. You can import one or more Graphics classes by typing import java.awt.*; at the beginning of your code and use any of the drawLine, drawArc, drawRect, drawOval, drawPolygon methods, of which "drawLine" can also work like the pen you were more used to.

Efthimis_28
  • 333
  • 1
  • 6
  • 15