Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!petera From: petera@utcsri.UUCP (Smith) Newsgroups: net.micro Subject: PC-LISP PACKAGE (article 9 of 13) Message-ID: <2652@utcsri.UUCP> Date: Sun, 27-Apr-86 14:40:49 EDT Article-I.D.: utcsri.2652 Posted: Sun Apr 27 14:40:49 1986 Date-Received: Sun, 27-Apr-86 15:35:23 EDT Distribution: net Organization: CSRI, University of Toronto Lines: 94 ;; TURTLE.L for PC-LISP.EXE V2.10 ;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; A set of turtle graphics primitives to demonstrate PC-LISP's BIOS ;; graphics routines. These routines are pretty self explanitory. The first ;; 5 defun's define the primitives, next are a set of routines to draw things ;; like squares, triangles etc. Try the function (GraphicsDemo). It will ;; draw Squirals, Trianglerals, etc. Note that the BIOS line drawing is really ;; slow. This is because the BIOS 'set dot/pixel' routine is used for every ;; point in a line. Using the BIOS has the advantage however of portability, ;; these routines work on virtually every MS-DOS machine. The global variable ;; !Mode controls the graphics resolution that will be used. It is set by ;; default to 6 I set it to 8 or 9 for my 2000 but these routines will not ;; support the lower resolution modes. ;; ;; Peter Ashwood-Smith ;; April 2nd, 1986 ;; (setq !Mode 6) ; default setting (defun TurtleGraphicsUp() (#scrmde# !Mode)(#scrsap# 0) (cond ((= !Mode 6) ; 640x200 B&W mode (setq CenterX 100 CenterY 100 Scale 3.2 Lfactor 1) (TurtleCenter)) ((= !Mode 7) (patom '|mode 7 not allowed|)) ((or (= !Mode 8) (= !Mode 9)) ; 640x400 modes (setq CenterX 266 CenterY 200 Scale 1.2 Lfactor 2) (TurtleCenter)) (t (patom '|unsupported mode|)) ) ) (defun TurtleGraphicsDown() (#scrmde# 2)) (defun TurtleCenter() (setq Lastx CenterX Lasty CenterY Heading 1.570796372)) (defun TurtleRight(n) (setq Heading (plus Heading (times n 0.01745329)))) (defun TurtleLeft(n) (setq Heading (diff Heading (times n 0.01745329)))) (defun TurtleGoTo(x y) (setq Lastx (quotient x Scale) Lasty (times y Lfactor) )) (defun TurtleForward(n) (setq n (times n Lfactor) Newx(plus Lastx(times(cos Heading)n))Newy(plus Lasty(times(sin Heading)n))) (#scrline#(times Lastx Scale) Lasty (times Newx Scale) Newy 1) (setq Lastx Newx Lasty Newy) ) ; ; end of Turtle Graphics primitives, start of Graphics demonstration code ; you can cut this out if you like and leave the Turtle primitives intact. ; (defun Line_T(n) (TurtleForward n) (TurtleRight 180) (TurtleForward (quotient n 4)) ) (defun Square(n) (TurtleForward n) (TurtleRight 90) (TurtleForward n) (TurtleRight 90) (TurtleForward n) (TurtleRight 90) (TurtleForward n) ) (defun Triangle(n) (TurtleForward n) (TurtleRight 120) (TurtleForward n) (TurtleRight 120) (TurtleForward n) ) (defun Make(ObjectFunc Size times skew) (prog() TOP:(cond ((zerop times) (return))) (ObjectFunc Size) (TurtleRight skew) (setq times (1- times)) (go TOP:) ) ) (defun GraphicsDemo() (TurtleGraphicsUp) (Make Square 40 18 5) (Make Square 60 18 5) (gc) ; idle work (TurtleGraphicsUp) (Make Triangle 40 18 5) (Make Triangle 60 18 5) (gc) ; idle work (TurtleGraphicsUp) (Make Line_T 80 50 10) (gc) ; idle work (TurtleGraphicsDown) )