turtle_graphics
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| turtle_graphics [2024/09/02 10:41] – [Make Your own Picture] frchris | turtle_graphics [2024/09/12 14:27] (current) – [Make Your own Picture] frchris | ||
|---|---|---|---|
| Line 19: | Line 19: | ||
| [[https:// | [[https:// | ||
| - | THe class Main has the main method | + | Here is the class diagram of '' |
| + | {{:: | ||
| + | |||
| + | |||
| + | The class Main has the main method | ||
| <code java> | <code java> | ||
| public class Main { | public class Main { | ||
| Line 39: | Line 43: | ||
| ===== Java " | ===== Java " | ||
| + | An animated version from Berne, Switzerland has so many classes, they put them all in a Library. | ||
| The [[http:// | The [[http:// | ||
| Line 48: | Line 53: | ||
| You will need download this jar file and add it to your Libraries (Java Build Path in Eclipse, Library Tab in Preferences in BlueJ): | You will need download this jar file and add it to your Libraries (Java Build Path in Eclipse, Library Tab in Preferences in BlueJ): | ||
| - | {{ :: | + | {{ :: |
| + | ==== Make Your own Picture==== | ||
| + | Here is an example of a Turtle instance that can make a hexagon, fill it in with a color, and " | ||
| + | |||
| + | <code java> | ||
| + | import ch.aplu.turtle.*; | ||
| + | import java.awt.Color; | ||
| + | /** | ||
| + | | ||
| + | * @author (Your Name) | ||
| + | * @version September 0, 2024 | ||
| + | */ | ||
| + | public class MyPicture { | ||
| + | |||
| + | public static void main(String[] args) { | ||
| + | | ||
| + | Turtle hexter = new Turtle(Color.GREEN); | ||
| + | | ||
| + | hexter.setPos(100, | ||
| + | |||
| + | for (int i=0; i< 6; i++) { | ||
| + | hexter.forward(100); | ||
| + | hexter.right(-60); | ||
| + | } | ||
| + | | ||
| + | hexter.setPos(0, | ||
| + | hexter.setFillColor(Color.BLUE); | ||
| + | hexter.fill(); | ||
| + | | ||
| + | Turtle t = new Turtle(hexter); | ||
| + | t.setPenColor(Color.RED); | ||
| + | t.setPos(-200, | ||
| + | t.hideTurtle(); | ||
| + | t.label( "by My name" | ||
| + | | ||
| + | } | ||
| + | |||
| + | } | ||
| + | </ | ||
| + | Here is the [[http:// | ||
| + | |||
| + | The default turtle coordinate system: doubles -200.0..+200.0 in both directions (zero at center; x to left, y upward). (Turtle coordinates are rounded to to 400 x 400 pixel coordinates). | ||
| + | Unless special constructors are used, new turtles are shown in a new window. | ||
| + | |||
| + | Defaults when a turtle is created: | ||
| + | Coordinates: | ||
| + | Heading: north | ||
| + | Speed: 200 (coordinates per seconds) | ||
| + | |||
| + | Lab Scoring: | ||
| + | - Adds the [[https:// | ||
| + | - Your name as @author in a comment | ||
| + | - The date as @version in a comment | ||
| + | - Makes a Turtle that is visable | ||
| + | - Draws a shape | ||
| + | - Fills the shape with a color | ||
| + | - Autographs their work with a label | ||
| + | - (8th point: Has more than one shape with an additional Turtle instance | ||
| + | - (9th or 10th point: Has unique and creative work of art | ||
| Here's an example program which demonstrates how to use some of the fancy methods Turtle class from the APLU: | Here's an example program which demonstrates how to use some of the fancy methods Turtle class from the APLU: | ||
| Line 119: | Line 182: | ||
| [[https:// | [[https:// | ||
| - | ==== Make Your own Picture==== | ||
| - | Here is an example of a Turtle instance that can make a hexagon, fill it in with a color, and " | ||
| - | <code java> | ||
| - | import ch.aplu.turtle.*; | ||
| - | import java.awt.Color; | ||
| - | /** | ||
| - | | ||
| - | * @author (Your Name) | ||
| - | * @version September 0, 2024 | ||
| - | */ | ||
| - | public class MyPicture { | ||
| - | |||
| - | public static void main(String[] args) { | ||
| - | | ||
| - | Turtle hexter = new Turtle(Color.GREEN); | ||
| - | hexter.setPos(100, | ||
| - | |||
| - | | ||
| - | for (int i=0; i< 6; i++) { | ||
| - | hexter.forward(100); | ||
| - | hexter.right(-60); | ||
| - | } | ||
| - | hexter.setPos(0, | ||
| - | hexter.setFillColor(Color.BLUE); | ||
| - | hexter.fill(); | ||
| - | | ||
| - | Turtle t = new Turtle(hexter); | ||
| - | t.setColor(Color.RED); | ||
| - | t.setPos(-200, | ||
| - | t.hideTurtle().label( "by My name" | ||
| - | | ||
| - | } | ||
| - | |||
| - | } | ||
| - | </ | ||
| - | Here is the [[http:// | ||
| - | |||
| - | The default turtle coordinate system: doubles -200.0..+200.0 in both directions (zero at center; x to left, y upward). (Turtle coordinates are rounded to to 400 x 400 pixel coordinates). | ||
| - | Unless special constructors are used, new turtles are shown in a new window. | ||
| - | |||
| - | Defaults when a turtle is created: | ||
| - | Coordinates: | ||
| - | Heading: north | ||
| - | Speed: 200 (coordinates per seconds) | ||
| - | |||
| - | Lab Scoring: | ||
| - | - Adds the jturtle-0.1.1.jar library in either BlueJ or Eclipse | ||
| - | - Your name as @author in a comment | ||
| - | - The date as @version in a comment | ||
| - | - Makes a Turtle that is visable | ||
| - | - Draws a shape | ||
| - | - Fills the shape with a color | ||
| - | - Autographs their work with a label | ||
| - | - (8th point: Has more than one shape with an additional Turtle instance | ||
| - | - (9th or 10th point: Has unique and creative work of art | ||
turtle_graphics.1725288107.txt.gz · Last modified: 2024/09/02 10:41 by frchris