forward, left,
etc are used as
drawing idioms.
Turtle Graphics are typically known from the Logo programming language. All Logo Turtle primitives are implemented, including their abbreviated versions. Turtle Graphics have proven to be intuitively useable, well suited to start (graphics-) programming. Lots of shapes can be easily drawn using Turtle Graphics.
Linewidth, linejoin, linecap, etc are implicit part of the used graphics
context (java.awt.Graphics
, etc).
These properties can be changed while using the
Turtle.
StringTurtle
API.StringTurtleApplet
is provided, to program
the Turtle from HTML documents.repeat
are supported too.
This allows Turtle commands such as
repeat 5 [forward 40 left 72]
(as an easy representation of
a pentagon).RADIANS
, DEGREE
, GRAD
.forward(10).left(90);
.
com.lrdev.turtle.Turtle
public API is rather fat
(87 methods).
However many of the methods are abbreviations and other kind of aliases
to the core Turtle primitives, that consist of 18 methods.com.lrdev.turtle.Turtle
uses high precision floating
point representations (double
type) to minimize calculation
errors.doubles
), e.g. 360/7
, ease the
representation of high precision data.[
...]
) support hierarchical data
structures, which are e.g. used with control statements.PersistentTurtle
class implements Turtle
command-undoing.com.lrdev.turtle.Turtle
with a
Graphics
object and component bounds.
forward
,
back
, left
, right
, ...):
import com.lrdev.turtle.Turtle; ... public void paint(Graphics graphics) { Turtle turtle = new Turtle(graphics, bounds()); turtle.forward(20).left(90); ... }Or instantiate a
com.lrdev.turtle.PersistentTurtle
and paint after drawing.
This enables e.g. centered paintings:
import com.lrdev.turtle.PersistentTurtle; ... public void paint(Graphics graphics) { PersistentTurtle turtle = new PersistentTurtle(); turtle.forward(20).left(90); ... turtle.center(); turtle.paint(graphics, bounds()); }See also the Java Turtle samples to the
com.lrdev.turtle
Java Turtle code, also for samples
of StringTurtleApplet
usage.
And see also the sources'
'samples/
' section.
penup()
pendown()
forward(double distance)
back(double distance)
left(double omega)
right(double omega)
setxy(double x, double y)
setx(double x)
sety(double y)
setheading(double phi)
towards(double x, double y)
home()
wrap()
nowrap()
double xcor()
double ycor()
double heading()
boolean drawstate()
Abbreviated versions:
pu()
penup
.pd()
pendown
.fd(double distance)
forward
.bk(double distance)
back
.lt(double omega)
left
.rt(double omega)
right
.seth(double phi)
setheading
.Copyright (C) 1997-2003 Eric Laroche. All rights reserved. This program is free software; you can redistribute it and/or modify it. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
center()
does now scale at least at one coordinate (was at
two).
PersistentTurtle
: scale and transform are only (re-)set if
center()
is chosen.
PersistentTurtle
.
center()
method has been implemented
(PersistentTurtle
).
PersistentTurtle
is provided and can be used instead of
Turtle
.
StringTurtleApplet
now provides a center
parameter.
PersistentTurtle.undo()
undo()
.Graphics2D
objects
needed?
No, it seems not necessary, since com.lrdev.turtle.Turtle
only uses the drawLine()
method of
java.awt.Graphics
.
Other Graphics
or Graphics2D
calls are to be
made by the client application.
Also backward compatibility to older Java versions and older
web browsers are provided this way.
Is Swing an issue?
No. The Turtle core classes are graphic renderers, not user interface components.
Will there be other Logo programming language non-Turtle constructs
(besides repeat
)?
Probably no, since the Java programming language has the clearer syntax.
How can I use rotate, shear and flip transformations (as well as generalized matrix transformations)?
Use the underlying graphics' (e.g. Graphics2D
) modes.
Only scale, translate, clip and wrap modes are directly supported by
com.lrdev.turtle
.
Can you provide support for the com.lrdev.turtle
package?
No, unfortunately not, with this opensource project. However, answers to some of your problems may appear in this f.a.q. list.
Will bugfixes be included in the product?
Yes. Please send them to Eric Laroche <laroche@lrdev.com>.
Is there a mailing list for the com.lrdev.turtle
Turtle
package?
No, not at the moment. If you want to get notified on changes, drop a mail to laroche@lrdev.com.
PersistentTurtle.java
/
StringTurtle.java
/
StringTurtleApplet.java
/
Turtle.java
/
TurtleCore.java
InteractiveTurtleApplet.java
/
InteractiveTurtleApplet2.java
/
PolygonApplet.java
//
Callback.java
/
DirectiveParser.java