TfxTurtle Component (c) 1997 by Chuck Gadd. All rights reserved. You are granted permission to use this component in any program royalty-free. You MAY NOT charge any fee for distributing this component. Use of this component is at your own risk. I do not make any warranty regarding this component, but it's based on code I've used for quite a while. (Ok, so I'm not good at lawyer-talk ) I make no promises regarding Updates/bug fixes, but if you find any bugs or have any feature suggestions, please let me know. My email address is cgadd@cfxc.com Feel free to drop me an email just to say 'I like it!'. If you hate it, don't bother telling me. Updates / Information / Other Components will be available from my Web page at http://www.csd.net/~cgadd/delphi.htm Description: ----------------------------------------------------------------- 'Turtle Graphics' component, as found in the 'LOGO' programming language. Graphics are drawn usings simple commands (Forward, Left, Right). This is definitely a work-in-progress, so if you've got suggestions, I'd like to hear them. LOGO Background: ----------------------------------------------------------------- With its friendly, colorful turtle graphics and a simple command structure, Logo is used by many schools to introduce children to computing concepts. However, Logo is not just a "kid's language". Many of the concepts and features will also appeal to adults interested in exploring computer programming. The original "Turtle" used in Logo was a robotic turtle, that moved around on a piece of paper, drawing a line with a pen. Soon the Turtle migrated to the computer graphics screen where it is used to draw shapes, designs, and pictures. For more information about LOGO, check out the Logo Foundation at http://el.www.media.mit.edu/groups/logo-foundation/index.html Installation: --------------------------------------------------------------- Unzip the .DCU file and the .R16 or .R32 into a directory in your library search path. for Delphi 1, from the main menu choose: Options|Install Components|Add for Delphi 2 and Delphi 3 choose: Component |Install|Add Change the File type to .DCU files, then browse to find the Dir where you unzipped this components files. It will be installed onto a new page titled 'CyberFX'. ATTENTION!!!!!!!!!!!!!!! Before installing ANY components, you should make a safe copy of your Delphi Library files (or in the case of D3, the Package files). If it gets mangled, you're hosed!!!! I haven't had any problems with this component trashing my VCL, but why take chances??? Getting Started: ------------------------------------------------------------------- The is a demo app included in the zip with this component. It shows how to use all the features. For a quick start: 1) Create a new project 2) Drop a PaintBox on form 3) Drop a fxTurtle on the form 4) Assign the Paintbox to the 'TurtleBox' property 5) Drop a button on the form. 6) In the buttons OnClick event, put the following code: fxTurtle1.Fwd(20); fxTurtle1.Left(90); fxTurtle1.RepeatHist(3); This will make the turtle draw a square in the PaintBox. Properties: --------------------------------------------------------------- TurtleBox : This is the TPaintBox that the Turtle will draw on. Currently, a TPaintBox is the only component allowed here. X, Y : This is the current location of the Turtle in the TurtleBox. Normally you should not set these directly. Instead use the Navigation methods below. Heading : The current direction, in degrees. 0 is up, 90 is right, 180 is down, 270 is left. Normally you should not set this directly. Instead use the Navigation methods below. PenDown : Current state of the Turtle's Pen. If the Pen is down, then the turtles movements will draw on the TurtleBox canvas. Showing : Determines if the Turtle itself is visible. The turtle is drawn as a triangle. Color : Determines the color of the turtle, and of the pen and brush. PenStyle : Determines the style of the Turtle's pen. See TPenStyle in Delphi help. PenWidth : Determines the width of the Turtle's pen. If a width other than 1 is used, Penstyle will always show as psSolid. BrushStyle : Determines the style of the Turtle's brush. See TBrushStyle in Delphi help. The brush is used for the Turtles FILL command. Recording : Determines if the Turtle is currently storing commands. If Recording is True, then the last 20 commands will be saved, and can be repeated using the fxTurtle.RepeatHist( nTimes ) method. History : Contains the list of History commands. Can be set directly, and executed using the RepeatHist method. Navigation Methods: ------------------------------------------------------------- Fwd(Length: Integer) : Moves the Turtle Forward 'Length' pixels. If PenDown is true, then a line will be drawn as the turtle moves. Left(Angle: Integer) : Turns 'Angle' degrees to the left (Counter-clockwise). Right(Angle: Integer) : Turns 'Angle' degrees to the Right (Clockwise). Paint/Draw Methods: ------------------------------------------------------------- Say(Words: String) : Writes 'Words' to the canvas, at the current position. Fill : Fills the space currently occupied by the turtle. Fill uses the current Color, and uses the current BrushStyle. Turtle control Methods: ------------------------------------------------------------- UpPen : Sets 'PenDown' to False. See the 'PenDown' property. DownPen : Sets 'PenDown' to True. See the 'PenDown' property. ShowTurtle : Sets 'Showing' to True. See the 'Showing' property HideTurtle : Sets 'Showing' to False. See the 'Showing' property ResetTurtle : Sets the turtle to it's starting position, Clears the canvas, Clears the history file, resets the Heading. Repaint : Used to re-draw the canvas. Call this from the TPaintBox OnPaint event. History Methods: ------------------------------------------------------------- HistoryOn : Sets 'Recording' to True. See the 'Recording' property. HistoryOff : Sets 'Recording' to False. See the 'Recording' property. RepeatHist(Count : Integer) : Will replay all the commands saved in the history buffer. Repeats them 'Count' times. ClearHist : Clears the history buffer. Thanks to: ------------------------------------------------------------------------------ Patrick Pollet INSA Centre Informatique du 1er Cycle patrick.pollet@cipinsa.insa-lyon.fr Patrick is the author of a set of turtle routines for Pascal. It was from his code that I learned the best way to do some of the needed geometry. Thanks to: ------------------------------------------------------------------------------ David R. McDermitt drmcderm@aol.com David wrote a very useful example program showing how to do Flicker-free "Sprite" Animation. I used his techniques to draw the Turtle's body. TfxTurtle Source Code: ---------------------------------------------------------- Source code is available for free. Please contact me via email for the source. cgadd@cfxc.com Future revisions: ----------------------------------------------------------- Currently on the To-Do list for this component: - Set the font properties used by the Say command - Set wrap mode, to wrap around, or stop at the edge of the box - Ability for a turtle to "hatch" new turtles, with the same properties as the parent. - Improve history functions.