{DANSK > ENGLISH with manual correction, modification}
{Editing by www.lived.ch, Misel Zivanovic, 2025}


1. Introduction.
==============

Below are described all procedures and functions in the two graphics packages
UniGraphics and Turtle.




2. UniGraphics.
================

The PCgraphics package, which is mentioned in the manual, has changed its name
to UniGraphics and has been greatly expanded and modified to make it even more
compatible with UniComal's graphics packages.

In the rewrite, use has been made of several of the routines in the Amiga's 
graphics library, including the circle drawing routines, which are found in 
Kickstart 1.2 and later versions. 

This means that UniGraphics cannot be used with Kickstart 1.1
========================================================

UniGraphics contains:


PROC arc(c1,c2,r,startangle,arc)
------------------------------------------------------------------------------------
A procedure that draws a circular arc with center in (c1,c2) and radius r. 
The drawn circular arc has length arc degrees and starts at the angle startangle.

Example:

	arc(100,100,50,45,90)
	arc(x0,y0,r,v,2*v)

PROC background(color)

A procedure that sets the background color to the value of the color parameter.

Example:

	background(3) // Set the background color to red
------------------------------------------------------------------------------------


PROC circle(c1,c2,r)
------------------------------------------------------------------------------------
Draws a circle with center in (c1,c2) ​​and radius r. The drawn figure will only be
a circle if you have chosen an appropriate relationship between the horizontal
and vertical units (the window procedure).

The current pen position is not changed.

Example:

	window(-170,170,-100,100)
	circle(0,0,50) // Draw a "circular" circle.
------------------------------------------------------------------------------------


PROC clear
------------------------------------------------------------------------------------
Clears the window within the current drawing frame set by clip.
------------------------------------------------------------------------------------


PROC clearscreen
------------------------------------------------------------------------------------
Clears the window within the current viewport
------------------------------------------------------------------------------------


PROC clip(xmin,xmax,ymin,ymax)
------------------------------------------------------------------------------------
The procedure clip defines a drawing area expressed in view coordinates (see window).
All drawing operations (clear, fill, draw, etc.) that lie outside this area are 
not visible.

Example:

	clip(2.5,4.7,-2,0)
	clip(0,cx,cy,cy+10)
------------------------------------------------------------------------------------


FUNC depth
------------------------------------------------------------------------------------
Returns the depth of the graphics window (the number of bitmaps in the graphics window).
For example, if the depth is 2, there are four colors with the numbers 0-3.
The number of colors can always be calculated as

	colornumber:=2^depth
------------------------------------------------------------------------------------


PROC draw(x,y)
------------------------------------------------------------------------------------
Draws a straight line from the current pen position (x0,y0)
to the point with coordinates (x0+x,y0+y).

The new pen position is the point with coordinates (x0+x,y0+y).

Example: 

	draw(0,100) // Draws a vertical line of length 101
------------------------------------------------------------------------------------


PROC drawto(x,y)
------------------------------------------------------------------------------------
Draws a straight line from the current pen position (x0,y0)
to the point with coordinates (x,y).

The new pen position is the point with coordinates (x,y).
------------------------------------------------------------------------------------


PROC fill(x,y)
------------------------------------------------------------------------------------
Fills an area with the current pen color. The area to be filled must contain the 
point (x,y) and be bounded by either a curve in a color different from the 
background color or by the viewport's border.

The current pen position is not changed.

Example:

	pencolor(1)
	circle(300,100,50) // Draw circle with pen color 1
	pencolor(2)
	fill(300,100) // .. and fill with pen color 2
------------------------------------------------------------------------------------


FUNC getcolor(x,y)
------------------------------------------------------------------------------------
Returns the color of the point with coordinates (x,y).
The current pen position is not changed.
------------------------------------------------------------------------------------


FUNC getrgb(color register)
------------------------------------------------------------------------------------
Returns the contents of the selected color register. 
Written in hexadecimal, the contents are given in the form:

	$0rgb

where r, g and b are the contents of the red, green and blue colors 
(four bits for each color). If the graphics system is not opened, -1 is returned.
------------------------------------------------------------------------------------


PROC graphicscreen(mode)
------------------------------------------------------------------------------------
Opens the graphics system.

	mode=0 : the execute window is used as the graphics window
	mode=1 : a separate window in the execute screen is opened
	mode>1 : high-resolution graphics (interlace) with mode bitmaps.

This procedure must be called before the other graphics commands can be used. 
When the graphics system is open, the command window or the graphics window can
be brought to the front by the key combination <SHIFT>+<F1>.
------------------------------------------------------------------------------------


FUNC height
------------------------------------------------------------------------------------
Returns the height of the graphics window in pixels.
------------------------------------------------------------------------------------


FUNC inq(number#)
------------------------------------------------------------------------------------
The inq function returns some of the graphics system's internal
variables. The number# parameter must be an integer in the range
0-33. The returned value is shown in the following table (if
nothing is stated next to a number, it is because
they have no meaning on the Amiga or only have meaning in connection with the Turtle package):

NUMBER 	INFORMATION ABOUT 	AREA 	     EFFECTED BY

0 	graphics mode 		0-4 	     graphic screen {graphicscreen(x)}
1
2 	text background 	0- 	     textbackground {textbackground(x)
3 	text color 		0- 	     pencolor
4
5 	graphic background 	0- 	     background
6 	pen color 		0- 	     pencolor
7 	graph-text width 	8/10 	     textstyle
8 	graph-text height 	8/10 	     textstyle
9 	graph-text direction 	0 	     (direction cannot be changed)
10 	graph-text mode 	0-1 	     textstyle
11
12 	pen in drawing frame 	0-1 	     most drawing process
13 				1
14 				0
15 	wrapping active 	0 	     (wrap does not exist)
16 	pen down 		1 	     only change in Turtle
17 	x-position 		0-width      most drawing process
18 	y-position 		0-height     most drawing process
19      viewport xmin     	0-width      viewport
20      viewport xmax     	0-width      viewport
21      viewport ymin     	0-height     viewport
22      viewport ymax     	0-height     viewport
23 	window xmin 		real number  window
24 	window xmax 		real number  window
25 	window ymin 		real number  window
26 	window ymax 		real number  window
27 				1
28 				0
29 				0
30 	x-relation 		(note 1)     window and viewport
31 	y-relation 		(note 2)     window and viewport
32 0
33 0

	note 1: (wdxmax-wdxmin)/(vpxmax-vpxmin)
	note 2: (wdymax-wdymin)/(vpymax-vpymin)
------------------------------------------------------------------------------------


PROC interiorcolor(color)
------------------------------------------------------------------------------------
Subsequent calls to the procedure polygon use the parameter color to fill with.

Example:

	interiorcolor(2) // Fill with black

	interiorcolor(-1) // No fill
------------------------------------------------------------------------------------


PROC loadscreen(name$)
------------------------------------------------------------------------------------
The procedure loads an IFF graphic image from disk into the current graphics window. 
The procedure only works satisfactorily in graphics mode 0,2,3,4. In graphics mode 1,
the image is loaded into the entire screen and not just the window.

Use of the procedure requires that IFF.library is installed
in libs:. IFF.library is a public domain library that is provided with AmigaCOMAL. If IFF.library is not present, the procedure call is ignored.

Example:

	loadscreen("Mandelbrot.iff")
------------------------------------------------------------------------------------


PROC move(x,y)
------------------------------------------------------------------------------------
Moves the pen from the current pen position (x0,y0) to
the point with coordinates (x0+x,y0+y).
------------------------------------------------------------------------------------


PROC moveto(x,y)
------------------------------------------------------------------------------------
Moves the pen to the point with coordinates (x,y)
------------------------------------------------------------------------------------


PROC noclip
------------------------------------------------------------------------------------
Procedure that cancels the effect of a previously set drawing area!
(the clip procedure).
------------------------------------------------------------------------------------


PROC outlinecolor(color)
------------------------------------------------------------------------------------
Subsequent calls to the polygon procedure use the
color parameter to draw with.

Example:

	outlinecolor(3) // Draw with red
------------------------------------------------------------------------------------


PROC paint(x,y)
------------------------------------------------------------------------------------
Fills an area with the current pen color. The area to be filled must contain the 
point (x,y) and be bounded by either a curve in the pen color or the viewport frame.

The current pen position is not changed.

Example:

	pencolor(1)
	moveto(0,0)
	drawto(500,150) // Draw a line in white
	pencolor(3)
	circle(300,100,50) // Draw a circle in red
	paint(300,100) // .. and fill the entire circle in red
------------------------------------------------------------------------------------


PROC palette(nr)
------------------------------------------------------------------------------------
Using the palette procedure, you can (in a 4-color graphics screen) select the four
colors from three different palettes:

palette 	color 0 	color 1 	color 2 	color 3

0 		black 		green 		red 		yellow
1 		black 		magenta 	cyan 		white

palette(-1) resets the palette to the original values 
(those selected in Preferences).

It should be noted that in graphics modes 0 and 1, all AmigaCOMAL's
windows will normally change color if you use the procedure.

The procedure is mostly included for compatibility with UniComal. 
Normally, you will use the much more general procedure setrgb. 
------------------------------------------------------------------------------------


FUNC pencolor(color)
------------------------------------------------------------------------------------
Sets the pen color.
------------------------------------------------------------------------------------


FUNC pixelx
------------------------------------------------------------------------------------
Function that returns the width of a single screen pixel measured
in the units selected by window

Example:

	draw(2*pixelx,0)
------------------------------------------------------------------------------------


FUNC pixely
------------------------------------------------------------------------------------
Function that returns the height of a single screen pixel measured in the units 
selected by window.

Example:

	draw(0,pixely)
	PROC plot(x,y)

Places a dot in the current pen color at the point with coordinates (x,y).
The current pen position is not changed.


PROC plottext(x,y,text$)
------------------------------------------------------------------------------------
Prints the text text$ starting at the point with coordinates (x,y).
The current pen position is not changed. 

Example:

	plottext(100,150,"AmigaCOMAL")
------------------------------------------------------------------------------------


PROC polygon(number#, REF x(), REF y())
------------------------------------------------------------------------------------
A procedure that draws a polygon with vertices whose coordinates are in x() and y(). 
The number of vertices is determined by the number# parameter 
(and not by the size of x() and y()).

The number of elements in x() and y() must be at least equal to the value 
of the number# parameter.

The polygon is drawn with the color set by the outlinecolor procedure and
filled with the color set by the interiorcolor procedure (unless
this has the value -1, in which case no filling occurs).

Example:

	DIM x(3), y(3)
	READ x(),y()
	interiorcolor(3)
	outlinecolor(2)
	polygon(3,x(),y()) // Draw a red triangle with a black border
	DATA 150,300,450
	DATA 20,150,20

Note!: The procedure uses a routine in the Amiga's graphics library. This procedure 
seems to have a bug that causes the system to crash if the vertices of the polygon 
fall outside the graphics window (the well-known GURU appears instead!).
------------------------------------------------------------------------------------


PROC printscreen
------------------------------------------------------------------------------------
Prints the contents of the graphics screen on a connected printer.
------------------------------------------------------------------------------------


PROC savescreen(name$)
------------------------------------------------------------------------------------
The procedure saves the graphics screen to disk in IFF format.

The procedure only works satisfactorily in graphics modes 0,2-4. In graphics mode 1,
the entire screen is saved, not just the window.

Use of the procedure requires that IFF.library is installed in libs:. IFF.library 
is a public domain library that is provided with AmigaCOMAL. If IFF.library is not
present, the call is ignored.

Example:

	savescreen("Mandelbrot.iff")
------------------------------------------------------------------------------------


PROC savescreen(name$,mode)
------------------------------------------------------------------------------------
Works as described above, but if the mode parameter is 1,
it is saved in compressed form. This can mean a considerable reduction in the size of the resulting file.

Example:

	savescreen("Mandelbrot.iff",1)
------------------------------------------------------------------------------------


PROC setrgb(color register,red,green,blue)
------------------------------------------------------------------------------------
Procedure that can be used to set the mixing ratio between the three basic colors
in the specified color register, which is specified by an integer in the range 0-31.
The amount of the three colors is specified by an integer in the range 0-15.

Example:

After calling

	setrgb(1,15,0,15)

Color number 1 (set with the pencolor procedure) will have a purple shade called
magenta. You can return the colors to their original values with the palette
procedure (palette(-1)).
------------------------------------------------------------------------------------


PROC textbackground(color)
------------------------------------------------------------------------------------
If plottext draws the background with (see textstyle), the color parameter is 
used as the background color.
------------------------------------------------------------------------------------


PROC textscreen
------------------------------------------------------------------------------------
Closes the graphics system.
------------------------------------------------------------------------------------


PROC textstyle(style#)
------------------------------------------------------------------------------------
Defines the appearance of the text printed by plottext.
The following values ​​can be used:

	0 =  normal text
	1 =  bold
	2 =  italic
	4 =  underlined
	8 =  inverse
	16 = text only (no background)

Multiple values ​​can be set by adding the values.

Example:

	textstyle(1+2) // Write bold and italic
------------------------------------------------------------------------------------


PROC textstyle(width#,height#,direction#,mode#)
------------------------------------------------------------------------------------
The procedure is only included for compatibility with UniComal, and only the last
parameter is significant. For this the following applies:

	0 =  characters with background
	1 =  character without background (as 16 above)
------------------------------------------------------------------------------------


PROC viewport(xmin,xmax,ymin,ymax)
------------------------------------------------------------------------------------
Delimits an area of ​​the graphics window where all graphics commands
are executed. The parameters are pixel coordinates.
------------------------------------------------------------------------------------


PROC viewport_to_window(vpx#, vpy#, REF wdx, REF wdy)
------------------------------------------------------------------------------------
The procedure converts the screen coordinates vpx# and vpy# to window coordinates 
wdx and wdy.
------------------------------------------------------------------------------------


FUNC width
------------------------------------------------------------------------------------
Returns the width of the graphics window in pixels.
------------------------------------------------------------------------------------


PROC window(xmin,xmax,ymin,ymax)
------------------------------------------------------------------------------------
Defines a coordinate system within the current viewport.
The parameters specify the new coordinates for the edges of the viewport.
------------------------------------------------------------------------------------


PROC window_to_viewport(wdx, wdy, REF vpx#, REF vpy#)
------------------------------------------------------------------------------------
The procedure converts the window coordinates wdx and wdy to the screen coordinates
vpx# and vpy#.
------------------------------------------------------------------------------------


FUNC xcor
------------------------------------------------------------------------------------
Function that returns the current x-coordinate of the pen.
------------------------------------------------------------------------------------


FUNC ycor
------------------------------------------------------------------------------------
Function that returns the current y-coordinate of the pen.
------------------------------------------------------------------------------------





3. TURTLE.
==========

This package extends UniGraphics with relative graphics (Turtle graphics). The package is written in AmigaCOMAL and uses UniGraphics.

The command graphicscreen executes a window(-160,160,-100,100)
(in graphics mode 0 - smaller widths in the other modes) and then draws
a small turtle (a triangle) in the middle of the screen.

All procedures and functions in UniGraphics are available from
Turtle, but in addition the following new procedures are made available:



PROC arcl(radius,arc)
------------------------------------------------------------------------------------
This procedure draws an arc of a circle with radius equal to the parameter radius and with length arc degrees. The drawing starts in the current
direction and is rotated to the left.

Example:

	arcl(10,90)
------------------------------------------------------------------------------------


PROC arcr(radius,arc)
------------------------------------------------------------------------------------
This procedure draws an arc with a radius equal to the parameter radius and a length
of arc degrees. The drawing starts in the current direction and is 
rotated to the right.
------------------------------------------------------------------------------------


PROC back(x)
------------------------------------------------------------------------------------
Moves the turtle x units back.
------------------------------------------------------------------------------------


PROC forward(x)
------------------------------------------------------------------------------------
Moves the turtle x units forward.
------------------------------------------------------------------------------------


FUNC heading
------------------------------------------------------------------------------------
Function that returns the current pen direction relative to the home direction 
(vertically upwards) and positive to the right.
------------------------------------------------------------------------------------


PROC hideturtle
------------------------------------------------------------------------------------
Hides the turtle
------------------------------------------------------------------------------------


PROC home
------------------------------------------------------------------------------------
Centers the turtle in the graphics window with its head facing upwards.
------------------------------------------------------------------------------------


FUNC inq(number#)
------------------------------------------------------------------------------------
The inq function returns some of the graphics system's internal
variables. The parameter number must be an integer in the range 0-
33. The returned value is shown in the following table (if
nothing is specified next to a number, it is because they have no
meaning on the Amiga):

NUMBER 	INFORMATION ABOUT 	AREA  		EFFECTED BY

0 	graphics mode 		0-4 		graphicscreen
1
2 	text background 	0- 		textbackground
3 	text color 		0- 		pencolor
4
5 	graphics background 	0- 		background
6 	pencolor 		0- 		pencolor
7 	graph-text width 	8/10 		textstyle
8 	graph-text height 	8/10 		textstyle
9 	graph-text direction 	0 		(direction cannot be changed)
10 	graph-text mode 	0-1 		textstyle
11 	pen visible 		0-1 		hideturtle/showturtle
12 	pen in drawing frame 	0-1 		most drawing process
13 				1
14 				0
15 	wrapping active 	0 		(wrap does not exist)
16 	pen down 		0-1 		pendown and penup
17 	x-position 		0-width 	most drawing process
18 	y-position 		0-height 	most drawing process
19 	viewport xmin 		0-width 	viewport
20 	viewport xmax 		0-width 	viewport
21 	viewport ymin 		0-height 	viewport
22 	viewport ymax 		0-height 	viewport
23 	window xmin 		real number 	window
24 	window xmax 		real number 	window
25 	window ymin 		real number 	window
26 	window ymax 		real number 	window
27 	cos(pendirection) 	[-1;1] 		arcl,arcr,setheading,
28 	sin(pendirection) 	[-1;1] 		left,right,home
29 	pen size 		0- 		turtlesize
30 	x-ratio 		(note 1) 	window and viewport
31 	y-ratio 		(note 2) 	window and viewport
32 				0
33 				0

	note 1: (wdxmax-wdxmin)/(vpxmax-vpxmin)
	note 2: (wdymax-wdymin)/(vpymax-vpymin)
------------------------------------------------------------------------------------


PROC left(v)
------------------------------------------------------------------------------------
Turns the turtle v degrees to the left (left).
------------------------------------------------------------------------------------


PROC pendown
------------------------------------------------------------------------------------
Lowers the pen. The pen will now draw when moved (except for move and moveto).
------------------------------------------------------------------------------------


PROC penup
------------------------------------------------------------------------------------
Raises the pen. The pen will no longer draw when moved (except for draw and drawto).
------------------------------------------------------------------------------------


PROC right(v)
------------------------------------------------------------------------------------
Turns the turtle v degrees to the right (right).
------------------------------------------------------------------------------------


PROC setheading(v)
------------------------------------------------------------------------------------
Turns the turtle so that it makes an angle v with the vertical
(positively upward)
------------------------------------------------------------------------------------


PROC setxy(x,y)
------------------------------------------------------------------------------------
Procedure that moves the pen to the point with coordinates (x,y) and draws a line if
the pen is down.
------------------------------------------------------------------------------------


PROC turtlesize(x)
------------------------------------------------------------------------------------
Defines the size of the turtle.
------------------------------------------------------------------------------------


PROC showturtle
------------------------------------------------------------------------------------
Show turtle.
------------------------------------------------------------------------------------


ABBREVIATIONS:
------------------------------------------------------------------------------------
In the Turtle package, the following abbreviations can be used:

	bk     = back
	bg     = background
	cs     = clearscreen
	fd     = forward
	ht     = hideturtle
	lt     = left
	pc     = pencolor
	pd     = pendown
	pu     = penup
	rt     = right
	seth   = setheading
	st     = showturtle
	textbg = textbackground
------------------------------------------------------------------------------------


UNIGRAPHICS vs TURTLE COORDINATES!
------------------------------------------------------------------------------------

Most programs developed for UniGraphics can run without change with Turtle. 
In some cases, however, it is necessary to set the window back to the physical
coordinates with the command

	window(0,width-1,0,height-1)

since Turtle sets window to other values. This must be done immediately after calling
the procedure graphicscreen(x). If you are annoyed by having to make this change very 
often, you can fix Turtle, which is written in AmigaCOMAL.

Another thing that does not directly prevent a program from running correctly is 
the turtle. You should probably (if you do not use it directly)...
...remove it with the command

	hideturtle

Otherwise, the drawing will be very slow. This can also be fixed in the Turtle package. 
Find the line

turtle:=true

in the procedure init'turtle and replace true with false.
