turtle_graphics
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
turtle_graphics [2022/08/27 12:01] – frchris | turtle_graphics [2022/08/27 13:53] (current) – frchris | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Turtle Graphics ====== | ====== Turtle Graphics ====== | ||
- | {{ :: | ||
===== History ===== | ===== History ===== | ||
Line 14: | Line 13: | ||
This was later used (in a simulated state) to teach newer programming languages as they get invented. Here we have the Java incarnation of Turtle Graphics. | This was later used (in a simulated state) to teach newer programming languages as they get invented. Here we have the Java incarnation of Turtle Graphics. | ||
+ | [[https:// | ||
+ | |||
+ | ==== Java Console " | ||
+ | [[https:// | ||
+ | |||
+ | ==== Java "Hi Rez" Turtle ==== | ||
+ | |||
+ | Package ch.aplu.turtle Description | ||
+ | |||
+ | The Java Turtle Package provides functionality for LOGO-like Java-Programs (including multiple turtles). It is written for educational purposes by Regula Hoefer-Isenegger for the AHL at the University of Berne under the supervision of Prof. Dr. Aegidius Plüss. | ||
+ | The Java Turtle Package comes under the GNU GENERAL PUBLIC LICENSE, Version 2, June 1991 (which you can find in the COPYING file which comes along with this package) and is copyrighted by the author. | ||
+ | |||
+ | |||
+ | You will need download this jar file and add it to your Libraries (Java Build Path in Eclipse, Library Tab in Preferences in BlueJ): | ||
+ | |||
+ | {{ :: | ||
+ | |||
+ | |||
+ | Here's a simple sample program which shows how to use the Java Turtle Package: | ||
+ | <code java> | ||
+ | import ch.aplu.turtle.*; | ||
+ | import java.awt.Color; | ||
+ | public class Example | ||
+ | { | ||
+ | public static void main (String[] args) { | ||
+ | Turtle joe = new Turtle(Color.green); | ||
+ | //own window. | ||
+ | joe.setPos(-100, | ||
+ | for (int i=0; i < 4; i++) { | ||
+ | joe.rt(90).fd(200); | ||
+ | // move forward 200 pixels. | ||
+ | } | ||
+ | joe.setPenColor(Color.red); | ||
+ | joe.pu(); | ||
+ | joe.bk(50).lt(90).bk(50).rt(90).pd(); | ||
+ | for (int i=0; i < 4; i++) { | ||
+ | joe.rt(90).fd(100); | ||
+ | } | ||
+ | Turtle anne = new Turtle(joe); | ||
+ | // in the same window as joe | ||
+ | anne.speed(1000).fd(150).lt(90); | ||
+ | // then do some moves. | ||
+ | anne.ht().fd(150).lt(90).stampTurtle(); | ||
+ | anne.fd(300); | ||
+ | anne.st(); | ||
+ | // screen | ||
+ | anne.wrap(); | ||
+ | anne.setPos(200, | ||
+ | for (int i=0; i < 4; i++) { | ||
+ | anne.rt(90).fd(400); | ||
+ | } | ||
+ | anne.reinit(); | ||
+ | // e.g. home position, | ||
+ | Turtle filly = new Turtle(joe, Color.yellow); | ||
+ | // Playground. | ||
+ | filly.setPos(75, | ||
+ | filly.setFillColor(Color.black); | ||
+ | filly.fill(); | ||
+ | // non-background colored pixel, | ||
+ | // containing filly' | ||
+ | filly.setPos(175, | ||
+ | filly.setFillColor(Color.orange); | ||
+ | filly.fill(); | ||
+ | Turtle texter = new Turtle(joe, Color.magenta); | ||
+ | texter.ht().label(" | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | [[https:// | ||
turtle_graphics.1661616095.txt.gz · Last modified: 2022/08/27 12:01 by frchris