LispPad
  • Home
  • Applications
    • 🖥️LispPad
      • Sessions
      • Editor
      • Preferences
    • 📱LispPad Go
    • 📜Language
    • 📖Libraries
  • Libraries
    • ⚙️LispKit
      • (lispkit archive tar)
      • (lispkit archive zip)
      • (lispkit base)
      • (lispkit bitset)
      • (lispkit box)
      • (lispkit bytevector)
      • (lispkit char)
      • (lispkit char-set)
      • (lispkit combinator)
      • (lispkit comparator)
      • (lispkit control)
      • (lispkit core)
      • (lispkit crypto)
      • (lispkit csv)
      • (lispkit datatype)
      • (lispkit date-time)
      • (lispkit debug)
      • (lispkit disjoint-set)
      • (lispkit draw)
      • (lispkit draw turtle)
      • (lispkit draw barcode)
      • (lispkit draw chart bar)
      • (lispkit dynamic)
      • (lispkit enum)
      • (lispkit format)
      • (lispkit graph)
      • (lispkit gvector)
      • (lispkit hashtable)
      • (lispkit heap)
      • (lispkit http)
      • (lispkit http oauth)
      • (lispkit http server)
      • (lispkit iterate)
      • (lispkit json)
      • (lispkit json schema)
      • (lispkit list)
      • (lispkit list set)
      • (lispkit log)
      • (lispkit markdown)
      • (lispkit match)
      • (lispkit math)
      • (lispkit math matrix)
      • (lispkit math stats)
      • (lispkit math util)
      • (lispkit object)
      • (lispkit port)
      • (lispkit prolog)
      • (lispkit queue)
      • (lispkit record)
      • (lispkit regexp)
      • (lispkit serialize)
      • (lispkit set)
      • (lispkit sqlite)
      • (lispkit stack)
      • (lispkit stream)
      • (lispkit string)
      • (lispkit styled-text)
      • (lispkit system)
      • (lispkit system call)
      • (lispkit system keychain)
      • (lispkit system pasteboard)
      • (lispkit test)
      • (lispkit text-table)
      • (lispkit thread)
      • (lispkit thread channel)
      • (lispkit-thread-future)
      • (lispkit thread shared-queue)
      • (lispkit type)
      • (lispkit url)
      • (lispkit vector)
    • ⚙️LispPad
      • (lisppad applescript)
      • (lisppad draw map)
      • (lisppad location)
      • (lisppad speech)
      • (lisppad system)
      • (lisppad turtle)
    • ⚙️SRFI
  • Examples
    • 📝LispKit
    • 📝LispPad
    • 📝LispPad Go
  • Releases
    • 🖥️LispPad
    • 📱LispPad Go
  • Downloads
  • Privacy Policy
  • Contact
Powered by GitBook
On this page
  1. Libraries
  2. LispKit

(lispkit draw turtle)

Last updated 5 months ago

Library (lispkit draw turtle) defines a simple "turtle graphics" API. The API provides functionality for creating turtles and for moving turtles on a plane generating drawings as a side-effect. A drawing is a data structure defined by library (lispkit draw).

A turtle is defined in terms of the following components:

  • A position (x, y) defining the coordinates where the turtle is currently located within a coordinate system defined by parameters used to create the turtle via make-turtle

  • A heading angle which defines the direction in degrees into which the turtle is moving

  • A boolean flag pen down which, if set to #t, will make the turtle draw lines on the graphics plane when moving.

  • A line width defining the width of lines drawn by the turtle

  • A color defining the color of lines drawn by the turtle

  • A drawing which records the moves of the turtle while the pen is down.

Turtles are mutable objects created via make-turtle. The functions listed below change the state of a turtle. In particular, they generate a drawing as a side-effect which can be accessed via turtle-drawing. For most functions, the turtle is an optional argument. If it is not provided, the function applies to the turtle provided by the current-turtle parammeter object.

current-turtle

Defines the current turtle, which is used as a default by all functions for which the turtle argument is optional. If there is no current turtle, this parameter is set to #f.

(turtle? obj)

Returns #t if obj is a turtle. Otherwise, it returns #f.

(make-turtle x y scale)

Returns a new turtle object. x and y determine the "home point" of the turtle. This is equivalent to the zero point of the coordinate system in which the turtle navigates. scale is a scaling factor.

(turtle-drawing turtle)

Returns the drawing associated with the given turtle.

Lifts turtle from the plane. If turtle is not provided, the turtle defined by current-turtle is used. Subsequent forward and backward operations don't lead to lines being drawn. Only the current coordinates are getting updated.

Drops turtle onto the plane. If turtle is not provided, the turtle defined by current-turtle is used. Subsequent forward and backward operations will lead to lines being drawn.

Sets the drawing color of turtle to color. If turtle is not provided, the turtle defined by current-turtle is used. color is a color object as defined by library (lispkit draw).

Sets the pen size of turtle to size. If turtle is not provided, the turtle defined by current-turtle is used. The pen size corresponds to the width of lines drawn by forward and backward.

Moves turtle to its home position. If turtle is not provided, the turtle defined by current-turtle is used.

Moves turtle to the position described by the coordinates x and y. If turtle is not provided, the turtle defined by current-turtle is used.

Sets the heading of turtle to angle. If turtle is not provided, the turtle defined by current-turtle is used. angle is expressed in terms of degrees.

Adjusts the heading of turtle by angle degrees. If turtle is not provided, the turtle defined by current-turtle is used.

Adjusts the heading of turtle by angle degrees. If turtle is not provided, the turtle defined by current-turtle is used.

Adjusts the heading of turtle by -angle degrees. If turtle is not provided, the turtle defined by current-turtle is used.

Moves turtle forward by distance units drawing a line if the pen is down. If turtle is not provided, the turtle defined by current-turtle is used.

Moves turtle backward by distance units drawing a line if the pen is down. If turtle is not provided, the turtle defined by current-turtle is used.

Turns the turtle by the given angle (in radians) and draws an arc with radius around the current turtle position if the pen is down. If turtle is not provided, the turtle defined by current-turtle is used.

(pen-up) (pen-up turtle)

(pen-down) (pen-down turtle)

(pen-color color) (pen-color color turtle)

(pen-size size) (pen-size size turtle)

(home) (home turtle)

(move x y) (move x y turtle)

(heading angle) (heading angle turtle)

(turn angle) (turn angle turtle)

(right angle) (right angle turtle)

(left angle) (left angle turtle)

(forward distance) (forward distance turtle)

(backward distance) (backward distance turtle)

(arc angle radius) (arc angle radius turtle)

⚙️