# @(#) $Id$
#
# Geometric shapes, symbols, line styles and fill patterns  commonly
# used on maps and charts.
#
# There are no restrictions on the use of this file.  Feel free to
# change the size, color or shape or legend description of the symbols
# to suit your purposes.
#
# If you create additional symbols and would like to share them, please
# e-mail a copy to <simoc@users.sourceforge.net> so that they can be added to
# this file.
#
# On many computers, interpreting this large file takes more than one second.
# If this is too long, copy only the definitions being used to a separate
# file and interpret that file instead.
#

begin circleoutline
	# Displays circle outline.
	#
	key "point", "Circle Outline"
	linestyle 0.1
	circle 0, 0, 2
	closepath
	stroke
end

begin equitriangle
	# Displays equilateral triangle outline.
	#
	key "point", "Equi. Triangle"
	linestyle 0.1
	move -1, -0.866
	draw 0, 0.866, 1, -0.866
	closepath
	stroke
end

begin squareoutline
	# Displays square outline.
	#
	key "point", "Square Outline"
	linestyle 0.1
	box -1, -1, 1, 1
	stroke
end

begin filledsquare
	# Displays filled square.
	#
	key "point", "Filled Square"
	linestyle 0.1
	box -1, -1, 1, 1
	fill
end

begin filledpentagon
	# Displays filled 5-sided shape.
	#
	key "point", "pentagon1"
	color "brown"
	move -1, -1.376
	local i
	let i = 0
	while i < 4
	do
		rdraw 2, 0
		rotate 72
		let i = i + 1
	done
	closepath
	fill
end

begin filledhexagon
	# Displays filled hexagon.
	#
	key "point", "Filled Hexagon"
	linestyle 0.1
	color "red"
	hexagon 0, 0, 3
	fill
end

begin octagonoutline
	# Displays octagon outline.
	#
	key "point", "Octagon Outline"
	linestyle 0.1
	move -0.848, -0.848
	local i
	let i = 0
	while i < 7
	do
		rdraw 1.656, 0
		rotate 45
		let i = i + 1
	done
	closepath
	stroke
end

begin decagon1 
end

begin x1 
	key "point", "x1"
	linestyle 0.1
	move 1, -1
	draw -1, 1
	move -1, -1
	draw 1, 1
	stroke
end

begin plus1 
	key "point", "plus1"
	linestyle 0.1
	move -1, 0
	draw 1, 0
	move 0, -1
	draw 0, 1
	stroke
end

begin sixpointstar
	# Displays filled 6-pointed star.
	#
	key "point", "6 Point Star"
	color "gold"
	move -2, -1.732
	draw 0, 1.732, 2, -1.732
	closepath
	fill

	clearpath
	move -2, 0.866
	draw 2, 0.866, 0, -2.598
	closepath
	fill
end

begin fivepointstar
	# Displays filled 5-pointed star.
	#
	key "point", "5 Point Star"
	local i
	let i = 0
	color "red"
	while i < 360
	do
		clearpath
		move -0.8, 0
		draw 0, 3, 0.8, 0
		fill
		rotate 72
		let i = i + 72
	done
end

begin arrowupoutline
	# Displays outlined arrow pointing upwards.
	#
	key "point", "Arrow Up"
	move -2, 0
	draw 0, 2, 2, 0, 1, 0, 1, -2, -1, -2, -1, 0
	closepath
	color "grey90"
	fill
	color "blue"
	linestyle 0.2
	stroke
end

begin arrowdownoutline
	key "point", "Arrow Down"
	rotate 180
	arrowupoutline
end

begin arrowleftoutline
	key "point", "Arrow Left"
	rotate 90
	arrowupoutline
end

begin arrowrightoutline
	key "point", "Arrow Right"
	rotate -90
	arrowupoutline
end

begin arrowupleftoutline
	key "point", "Arrow Up Left"
	rotate 45
	arrowupoutline
end

begin shipwreck
	key "point", "Shipwreck"
	color "black"
	linestyle 0.1

	# Draw cross.
	#
	move 0, 0
	draw -0.7, 1.4

	rdraw 0.8, 0
	rdraw -1.6, 0
	move -0.7, 1.4
	rdraw 0.4, 0.692
	rdraw -0.8, -1.385
	stroke

	# Draw sunk ship.
	#
	clearpath
	move -2, -1
	draw 2, 1, 2, -1
	closepath
	fill
end

begin viewpoint
	key "point", "Viewpoint"
	color "green"
	local i
	let i = 0
	while i < 12
	do
		# Draw rays out from center point.
		#
		clearpath
		move 0.5, 0
		draw 2, 0.15, 2.05, 0, 2, -0.15
		closepath
		fill
		rotate 30
		let i = i + 1
	done
end

begin surveymarker
	# Display a survey marker, like |X| |
	#                               | |X|
	#
	key "point", "Survey Marker"
	color "grey90"
	linestyle 0.1
	box -1, -1, 1, 1
	fill
	color "red"
	stroke
	clearpath
	box -1, -1, 0, 0
	box 0, 0, 1, 1
	fill
end

begin trigstation
	key "point", "Trig. Station"
	color "red"
	linestyle 0.1
	move 0, 0
	draw 0, 2
	move -1, 1
	draw 1, 1
	stroke

	clearpath
	move 0, 0
	draw 1.5, -1.5
	draw -1.5, -1.5
	closepath
	fill
end

begin witchshat
	key "point", "Witch's Hat"
	color "orangered"
	linestyle 0.2
	move -1.7, 0
	draw 1.7, 0
	stroke

	clearpath
	move -1.4, 0
	draw 0, 3.5
	draw 1.4, 0
	fill
end

begin oldmoon
	key "point", "Old Moon"
	circle 0, 0, 2
	closepath
	color "cyan"
	fill

	clearpath
	move 0, -2
	arc 1, 0, 0, 0, 2
	arc -1, 2, 0, 0, -2
	color "navyblue"
	fill
end

begin newmoon
	key "point", "New Moon"
	circle 0, 0, 2
	closepath
	color "navyblue"
	fill

	clearpath
	move 0, -2
	arc -1, 0, 0, 0, 2
	arc 1, -2, 0, 0, -2
	color "cyan"
	fill
end

begin trafficlights c
	# Draw traffic lights, with either red, amber or green light
	# showing.
	#
	key "point", "Traffic Lights", "green"
	local y
	color "black"
	box -2, -4, 2, 4
	fill

	clearpath
	circle 0, 0, 1
	circle 0, 2.5, 1
	circle 0, -2.5, 1
	color "grey"
	fill

	# Calculate position for light to show.
	#
	if c eq "red"
	then
		let y = 2.5
	elif c eq "amber"
	then
		let y = 0
	elif c eq "green"
	then
		let y = -2.5
	else
		# Don't draw any light, just
		# show a grey circle again.
		#
		let y = 0
		let c = "grey"
	endif
	color c

	clearpath
	circle 0, y, 1
	fill
end

begin quadrants title, q1, q2, q3, q4, qLabels
	# Draws 4 quadrants, showing 4 levels of some attribute.
	# Relative levels are shown.
	#
	key "point", "Quadrant Chart", "Location", 3, 4, 6, 3.3, 1
	local maxValue, w
	let maxValue = max(q1, q2)
	let maxValue = max(maxValue, q3)
	let maxValue = max(maxValue, q4)

	# Show box in each quadrant, with size depending on value
	# for that quadrant.
	#
	color "orangered"
	box 0, 0, q2 / maxValue * 5, q2 / maxValue * 5
	fill
	clearpath
	box 0, -q3 / maxValue * 5, q3 / maxValue * 5, 0
	fill
	clearpath
	box -q4 / maxValue * 5, -q4 / maxValue * 5, 0, 0
	fill
	clearpath
	box -q1 / maxValue * 5, 0, 0, q1 / maxValue * 5
	fill

	# Label quadrants, normally it is enough to show labels
	# in legend and at each place it is drawn on the map.
	#
	color "black"
	if qLabels == 1
	then
		font "Helvetica", 2.5
		justify "left"

		clearpath
		move 1, 1
		label "Q2"

		clearpath
		move 1, -2.5
		label "Q3"

		clearpath
		move -4, -2.5
		label "Q4"

		clearpath
		move -4, 1
		label "Q1"
	endif

	# Draw black plus.
	#
	linestyle 0.1
	clearpath
	move -5.5, 0
	draw 5.5, 0
	move 0, -5.5
	draw 0, 5.5
	stroke

	clearpath
	justify "center"
	color "grey90"
	let w = stringwidth(title) + 1
	box -w / 2, -8.5, w / 2, -5.5
	fill
	clearpath
	color "black"
	move 0, -8
	label title
end

begin windname name
	font "Helvetica-Bold", 3
	justify "center"
	move 0, -Mapyrus.screen.resolution.mm
	move 0, Mapyrus.screen.resolution.mm
	move Mapyrus.screen.resolution.mm, 0
	move -Mapyrus.screen.resolution.mm, 0
	color "white"
	label name
	clearpath
	move 0, 0
	color "black"
	label name
end

begin windindicator bearing, strength, name
	# Draw a line with feathered tail showing wind direction and strength.
	#
	key "point", "Wind from SW at force 1", 45, 1, ""
	key "point", "Wind from SW at force 2", 45, 2, ""
	key "point", "Wind from SW at force 3", 45, 3, ""
	key "point", "Wind from SE at force 5", 315, 5, ""
	local s, y

	# Draw the label above or below the origin point
	# so that it does not interfere with the wind indicator.
	#
	let s = cos(bearing) > 0 ? -5 : 2.5
	move 0, s
	windname name

	rotate -bearing

	clearpath
	circle 0, 0, 1
	move 0, 1
	let y = 6
	draw 0, y
	while strength > 0
	do
		move 0, y
		if strength == 1
		then
			rdraw 1.2, 0.35
		else
			rdraw 2.4, 0.7
		endif
		let y = y - 1
		let strength = strength - 2
	done

	linestyle 1
	color "white"
	stroke
	linestyle 0.2
	color "black"
	stroke
end

# Display histogram showing minimum and maximum temperatures for each
# of the twelve months.
#
begin temperatureBar mint, maxt
	box 0, mint / 5, 1, maxt / 5
	fill
end

begin temperatureHistogram name, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12

	key "point", "Temperature", "SYDNEY", 18.6, 18.7, 17.5, 14.6, 11.5, 9.2, 8.0, 8.9, 11.0, 13.5, 15.5, 17.4, 25.8, 25.7, 24.7, 22.3, 19.3, 16.8, 16.2, 17.7, 19.8, 22.0, 23.5, 25.1

	# Make empty box to draw graph into.
	#
	color "white"
	move -6, -3
	draw -6, 8, 6, 8, 6, -3
	fill
	color "blue"
	linestyle 0.1
	stroke

	# Draw lines and labels as a guide to temperature values.
	#
	move -6, 2
	draw 6, 2
	move -6, 4
	draw 6, 4
	move -6, 6
	draw 6, 6
	stroke
	clearpath

	font 'Helvetica-Bold', 2
	justify "left"
	move 6, 1
	label "10"
	clearpath
	move 6, 3
	label "20"
	clearpath
	move 6, 5
	label "30\260C"

	# Label city below the place where the graph goes.
	#
	clearpath
	move -6, -3
	draw -6, 0, 6, 0, 6, -3
	fill
	clearpath
	move 0, -2
	justify "centre"
	colour "white"
	label name

	# Draw a bar for each month, between minimum and maximum values.
	#
	colour "red"
	clearpath
	move -6, 0
	temperatureBar a1, b1

	clearpath
	move -5, 0
	temperatureBar a2, b2

	clearpath
	move -4, 0
	temperatureBar a3, b3

	clearpath
	move -3, 0
	temperatureBar a4, b4

	clearpath
	move -2, 0
	temperatureBar a5, b5

	clearpath
	move -1, 0
	temperatureBar a6, b6

	clearpath
	move 0, 0
	temperatureBar a7, b7

	clearpath
	move 1, 0
	temperatureBar a8, b8

	clearpath
	move 2, 0
	temperatureBar a9, b9

	clearpath
	move 3, 0
	temperatureBar a10, b10

	clearpath
	move 4, 0
	temperatureBar a11, b11

	clearpath
	move 5, 0
	temperatureBar a12, b12
end

begin speechbubble message
	# Draw a speech bubble containing a message at a point.
	#
	key "point", "Speech Bubble", "speech\nbubble"
	local height, halfWidth

	font "Helvetica-Narrow", 3
	justify "left, bottom"

	# Find size of message.
	#
	let halfWidth = stringwidth(message) / 2
	let height = stringheight(message)

	# Draw box with rounded corners and small arrow.
	#
	move 0, 0
	draw 0, 1
	draw -halfWidth, 1
	arc 1, -halfWidth, 2, -halfWidth - 1, 2
	draw -halfWidth - 1, height
	arc 1, -halfWidth, height, -halfWidth, height + 1
	draw halfWidth, height + 1
	arc 1, halfWidth, height, halfWidth + 1, height
	draw halfWidth + 1, 2
	arc 1, halfWidth, 2, halfWidth, 1
	draw 1, 1
	closepath
	color "lightyellow"
	fill
	color "black"
	linestyle 0.1
	stroke

	# Draw each line of message inside bubble.
	#
	clearpath
	move -halfWidth, 1.5
	label message
end

begin northarrow
	# Displays simple north arrow.
	#
	linestyle 0.2, "round", "round"
	color "black"
	move 0, -4
	draw 0, 4
	draw -2, 2

	move 0, 4
	draw 2, 2
	stroke

	clearpath
	move 0, 5
	font "Helvetica-Bold", 3
	justify "center"
	label "N"
end

begin nsew_arrow direction
	# One direction of north arrow.
	#
	color "black"
	move 0, 0
	draw 1.5, 1.5, 0, 6
	closepath
	fill

	clearpath
	color "white"
	move 0, 0
	draw -1.5, 1.5, 0, 6
	closepath
	fill
	color "black"
	stroke

	clearpath
	move 0, 8
	rotate -Mapyrus.rotation
	font "Times-Roman", 3
	justify "center, middle"
	label direction
end

begin nsew
	# Displays fancy north arrow with labelled directions.
	#
	linestyle 0.1
	move 0, 0
	nsew_arrow "N"
	rotate -90
	nsew_arrow "E"
	rotate -90
	nsew_arrow "S"
	rotate -90
	nsew_arrow "W"
end

begin bordercrossing
	key "point", "Border Crossing"
	color "white"
	linestyle 0.4
	circle 0, 0, 1.5
	closepath
	fill
	color "pink"
	move -1.5, 0
	draw 1.5, 0
	stroke
end

begin crosshair
	key "point", "Crosshair"
	color "black"
	linestyle 0.1
	circle 0, 0, 2
	move 0, -3
	draw 0, 3
	move -3, 0
	draw 3, 0
	stroke
end

begin lighthouse
	key "point", "Lighthouse"
	color "black"
	linestyle 0.1
	move -1.1, 0
	draw 1.1, 0

	box -0.7, 2.1, 0.7, 3

	move 1.4, 2.3
	draw 2.3, 2.1
	move 1.4, 2.8
	draw 2.3, 3

	move -1.4, 2.3
	draw -2.3, 2.1
	move -1.4, 2.8
	draw -2.3, 3
	stroke

	clearpath
	move -0.7, 0
	draw -0.7, 2.1, 0.7, 2.1, 0.7, 0
	closepath
	fill
end

#boatramp
#airport

begin information
	key "point", "Information"
	color "darkgreen"
	circle 0, 0, 2
	fill
	clearpath
	move -0.1, 0.6
	color "white"
	font "Courier-Italic", 4
	justify "center, middle"
	label "i"
end

begin sbahn
	key "point", "S-Bahn Station"
	color "green"
	circle 0, 0, 2
	fill
	clearpath
	move -0.1, 0.6
	color "white"
	font "Helvetica-Bold", 4
	justify "center, middle"
	label "S"
end

begin ubahn
	key "point", "U-bahn Station"
	color "blue"
	box -2, -2, 2, 2
	fill
	clearpath
	move -0.1, 0.6
	color "white"
	font "Helvetica-Bold", 4
	justify "center, middle"
	label "U"
end

begin parking
	key "point", "Parking"
	color "dodgerblue"
	box -2, -2, 2, 2
	fill
	clearpath
	move -0.1, 0.5
	color "white"
	font "Helvetica-Bold", 4
	justify "center, middle"
	label "P"
end

begin coveredparking
	key "point", "Covered Parking"
	color "dodgerblue"
	box -2, -2, 2, 3
	fill
	clearpath
	move -0.1, 0.5
	color "white"
	font "Helvetica-Bold", 4
	justify "center, middle"
	label "P"
	clearpath
	linestyle 0.4
	move -1.7, 1.7
	draw 0, 2.6, 1.7, 1.7
	stroke
end

begin cave
	key "point", "Cave"
	color "darkgray"
	move -2, 0
	draw -1.2, 0, -1.2, 2
	arc 1, 0, 2, 1.2, 2
	draw 1.2, 0, 1.4, 0
	stroke
	clearpath
	box -1.2, 0, -0.7, 2.5
	fill
end

begin flag
	key "point", "Flag"
	color "red"
	box 0, 1.5, 2, 3
	fill
	clearpath
	linestyle 0.2
	move 0, 0
	draw 0, 3
	stroke
end

begin pennant
	key "point", "Pennant"
	color "limegreen"
	move 0, 1.5
	draw 2, 2.25, 0, 3
	fill
	clearpath
	linestyle 0.2
	move 0, 0
	draw 0, 3
	stroke
end

begin pinetree
	key "point", "Tree"
	color "forestgreen"
	linestyle 0.1
	move -1, 0
	draw 1, 0
	move 0, 0
	draw 0, 1
	stroke
	clearpath
	move -1, 1
	draw 0, 3, 1, 1
	closepath
	fill
end

begin radiotower
	key "point", "Radio Tower"
	linestyle 0.1
	circle 0, 0, 1
	fill
	clearpath
	move 0.707, 0.707
	rdraw 0.5, 1, -1, 0, 0.5, 1
	stroke
end

begin church
	key "point", "Church"
	color "black"
	linestyle 0.1
	circle 0, 0, 1
	fill
	clearpath
	move 0, 1
	draw 0, 3
	move -1, 2
	draw 1, 2
	stroke
end

begin hospital
	key "point", "Hospital"
	color "white"
	linestyle 0.1
	box -2, -2, 2, 2
	fill
	color "black"
	stroke
	color "red"
	clearpath
	box -1.5, -0.4, 1.5, 0.4
	box -0.4, -1.5, 0.4, 1.5
	fill
end

begin tent
	key "point", "Camping"
	linestyle 0.2
	move -1.5, 0
	draw 0, 2.8, 1.5, 0
	closepath
	color "white"
	fill
	color "maroon"
	stroke
	clearpath
	box -0.5, 0, 0.5, 1
	fill
end

begin hut
	key "point", "Hut"
	linestyle 0.1
	color "maroon"
	move -1.3, 0
	draw 1.3, 0
	box -1, 0, 1, 1.5
	stroke
	clearpath
	move -1.3, 1.5
	draw 0, 2.8, 1.3, 1.5
	closepath
	fill
end

begin fairground
	key "point", "Fairground"
	linestyle 0.1
	color "orange"
	move 0, 4
	draw -2, 3.3, 0, 2.6
	closepath
	fill

	color "red"
	clearpath
	box -1, 0, 1, 2
	fill
	clearpath
	move 0, 2
	draw 0, 4
	stroke
end

begin factory
	key "point", "Factory"
	color "black"
	move 0, 0
	draw 2, 0, 2, 1.5, 1.2, 1.5, 0, 3, 0, 1.5, -1.2, 3, -1.2, 0
	closepath
	fill
end

begin school
	key "point", "School"
	color "white"
	box -1, 0, 3, 3
	fill
	clearpath
	color "crimson"
	linestyle 0.1
	box 0, 0, 3, 2
	move 3, 2
	draw 2.5, 3, -0.5, 3, -1, 2, -1, 0, 0, 0
	move 0, 2
	draw -0.5, 3
	box 0.7, 0.7, 1.3, 1.4
	box 1.8, 0.7, 2.4, 1.4
	stroke
end

begin postoffice
	key "point", "Post Office"
	linestyle 0.2
	color "lightyellow"
	box -2, 0, 2, 2
	fill
	color "darkgrey"
	move -2, 2
	draw 0, 0.8, 2, 2
	stroke
end

begin library
	key "point", "Library"
	color "lightblue"
	linestyle 0.1
	move 0, 0
	draw 2, -0.5, 2, 2.5, 0, 3, -2, 2.5, -2, -0.5
	closepath
	fill
	color "black"
	stroke
	move 0, 0
	draw 0, 3
	move 0.5, 2
	draw 1.5, 1.8
	move 0.5, 1.2
	draw 1.5, 1
	stroke
end

begin police
	key "point", "Police"
	box -1, 0, 2, 3
	color "white"
	fill
	color "blue"
	linestyle 0.1
	stroke
	clearpath
	box -1, 0, 0, 1
	box -1, 2, 0, 3
	box 0, 1, 1, 2
	box 1, 0, 2, 1
	box 1, 2, 2, 3
	fill
end

begin cemetary
	key "point", "Cemetary"
	color "saddlebrown"
	clearpath
	box -0.5, -1, 0.5, 3
	fill
	clearpath
	box -1.7, 1.6, 1.7, 2.2
	fill
end

begin waypoint
	key "point", "Waypoint"
	color "white"
	box -2, -2, 2, 2
	fill
	linestyle 0.1
	color "orange"
	stroke
	clearpath
	move -2, 2
	draw 2, -2, 2, 2
	fill
end

begin capitalcity name
	local u, w
	key "point", "Capital City", "Ely"
	font "Helvetica-Bold", 4
	justify "center"
	let u = upper(name)
	let w = stringwidth(u)
	if not protected(-w / 2, 0, w / 2, 4)
	then
		protect -w / 2, 0, w / 2, 4

		# Draw yellow box with black border behind name.
		#
		color "yellow"
		box -w / 2, 0, w / 2, 4
		fill
		color "black"
		linestyle 0.1
		stroke
		clearpath
		move 0, 0.5
		label u
	endif
end

begin city name
	local w
	key "point", "City", "Ely"
	font "Helvetica-Bold", 4
	justify "center"
	let w = stringwidth(name)
	if not protected(-w / 2, 0, w / 2, 4)
	then
		protect -w / 2, 0, w / 2, 4

		# Draw yellow box behind name.
		#
		color "yellow"
		box -w / 2, 0, w / 2, 4
		fill
		color "black"
		clearpath
		move 0, 0.5
		label name
	endif
end

begin town name
	local w
	key "point", "Town", "Ely"
	font "Helvetica-Bold", 3
	justify "center"
	let w = stringwidth(name)
	if not protected(-w / 2, 0, w / 2, 3)
	then
		protect -w / 2, 0, w / 2, 3

		# Draw yellow highlight around name.
		#
		color "yellow"
		move -0.3, 0.5
		move 0.3, 0.5
		move 0, 0.8
		move 0, 0.3
		label name
		clearpath
		color "black"
		move 0, 0.5
		label name
	endif
end

begin emphasisedname name
	local w
	key "point", "Emphasised Name", "HOT"
	font "Helvetica-Bold", 3
	let w = stringwidth(name)
	if not protected(0, 0, w, 3)
	then
		protect 0, 0, w, 3

		# Draw thick red underline under name.
		#
		color "red"
		linestyle 0.6
		move 0, 0
		draw w, 0
		stroke

		clearpath
		color "black"
		move 0, 0.5
		label name
	endif
end

begin streetname name
	local w
	key "point", "Street Name", "Sesame St"
	font "Helvetica-Narrow-Bold", 3
	let w = stringwidth(name) + 1

	# Do not draw labels that overlap existing labels.
	#
	if not protected(-w / 2, 0, w / 2, 4)
	then
		# Draw street name inside a box.
		#
		clearpath
		color "forestgreen"
		circle 0, 3, 1
		fill

		clearpath
		box -w / 2, 0, w / 2, 3.3
		color "yellow"
		fill
		color "forestgreen"
		stroke

		clearpath
		move 0, 0.5
		justify "center"
		color "black"
		label name
		protect -w / 2, 0, w / 2, 4

	endif
end

# LINEPATTERNS

begin leftticks_tick
	move 0, 0
	draw 0, 0.6
	stroke
end

begin Lleftticks
	# Display line with tick marks on lefthand-side.
	#
	key "line", "Left Ticks"
	color "red"
	linestyle 0.1
	stroke
	samplepath 3, 1.5
	leftticks_tick
end

begin centerline_c
	# Display letter 'c' rotated to follow line.
	#
	font "Helvetica", 3
	justify "center, middle"
	move 0, 0.7
	label "c"
end

begin Lcenterline
	# Display line with 'c' letters along it.
	#
	key "line", "Centerline"
	color "black"
	linestyle 0.2, "round", "round", 0, 4, 4
	stroke
	samplepath 8, 6
	centerline_c
end

begin fence_tick
	move 0, -0.8
	draw 0, 0.8
	stroke
end

begin Lfence
	# Display fence line: --|--|--
	#
	key "line", "Fence"
	color "forestgreen"
	linestyle 0.1, "round", "round", 0, 3, 2
	stroke
	samplepath 5, 4
	fence_tick
end

begin bowtie
	linestyle 0.1
	move -1, -0.5
	draw 1, 0.5, 1, -0.5, -1, 0.5
	closepath
	stroke
end

begin Lbowtie
	# Display line with bow-tie like symbols.
	#
	key "line", "Bow Ties"
	color "black"
	linestyle 0.1, "round", "round", 0, 4, 4
	stroke
	samplepath 8, 6
	bowtie
end

begin motorway_label routeNumber
	local w

	# Remove any rotation and force symbol to appear horizontally.
	#
	rotate -Mapyrus.rotation
	font "Helvetica", 3
	justify "center"
	let w = stringwidth(routeNumber) + 1

	# Skip label if it overwrites an existing label.
	#
	if not protected(-w / 2, -1.5, w / 2, 1.5)
	then
		box -w / 2, -1.5, w / 2, 1.5
		color "white"
		fill
		color "black"
		linestyle 0.1
		stroke
		clearpath
		move 0, -1
		label routeNumber
		protect -w / 2, -1.5, w / 2, 1.5
	endif
end

begin Lmotorway routeNumber
	# Display motorway with route number label at intervals.
	#
	key "line", "Motorway", "M25"
	color "red"
	linestyle 1, "round", "round"
	stroke

	# Skip labels on short motorway segments.
	#
	if Mapyrus.path.length > 15
	then
		samplepath 20, 12
		motorway_label routeNumber
	endif
end

begin border_dot
	color "black"
	circle 0, 0, 1
	fill
	clearpath
end

begin Lborder
	# Display border.
	#
	key "line", "Border"
	color "black"
	linestyle 0.5, "round", "round"
	stroke
	if Mapyrus.path.length > 10
	then
		samplepath 20, 8
		border_dot
	endif
end

begin Lrailway
	# Display railway line as alternating colors along line.
	#
	key "line", "Railway"
	color "black"
	linestyle 1, "butt", "bevel"
	stroke
	linestyle 1, "butt", "bevel", 2, 4, 4
	color "grey60"
	stroke
end

begin powerline_v
	move -0.6, 1
	draw 0, 0
	draw 0.6, 1
	stroke
end

begin Lpowerline
	# Display electricity power line as ___v___v_
	#
	key "line", "Power Line"
	color "black"
	linestyle 0.1
	stroke
	if Mapyrus.path.length > 10
	then
		samplepath 10, 8
		powerline_v
	endif
end

begin Ldashdot
	# Displays a simple dash dot line --- . --- .
	#
	key "line", "Dash Dot Line"
	color "purple"
	linestyle 1, "butt", "bevel", 0, 8, 2, 1, 2
	stroke
end

begin Lmulticolorline
	# Displays line twice with different, out of phase
	# linestyles to give appearance of alternating dashes
	# in different colors.
	#
	key "line", "Multi Color Line"
	color "red"
	linestyle 1, "butt", "bevel", 0, 4, 8
	stroke
	linestyle 1, "butt", "bevel", 6, 4, 8
	color "darkred"
	stroke
end

begin Larrowline_head r
	# Draw arrowhead rotated to point at end of line.
	#
	rotate r
	move 1.2, 1.2
	draw 0, 0, 1.2, -1.2
	stroke
end

begin Larrowline_start
	# Split path into points with large spacing so there will be
	# only one sample point at start of line.  Draw arrowhead there.
	#
	samplepath 99999, 0
	Larrowline_head 0
end

begin Larrowline_end
	# Draw arrowhead at end of line.
	#
	samplepath -99999, 0
	Larrowline_head 180
end

begin Larrowline
	# Displays line with arrows at either end.
	#
	key "line", "Arrow Line"
	color "olive"
	linestyle 0.1
	stroke
	Larrowline_start
	Larrowline_end
end

begin Lsnakeline_segment
	# Display segments with alternating arcs to give wiggling effect.
	#
	move -2, 0
	arc -LsnakeY, 0, LsnakeY, 2, 0
	let LsnakeY = -LsnakeY
	stroke
end

begin Lsnakeline
	# Displays wiggly snake that looks like a snake!
	#
	key "line", "Snake Line"
	color "forestgreen"
	linestyle 2, "round", "round"
	samplepath 4, 2
	let LsnakeY=1
	Lsnakeline_segment
end

begin Linaccurateline_dot
	local y
	let y = random(1) - 0.5
	box -0.3, y - 0.3, 0.3, y + 0.3
	fill
end

begin Linaccurateline
	# Displays dotted line that jumps up and down randomly that
	# shows that position of line is not accurate.
	#
	key "line", "Inaccurate Line"
	color "black"
	samplepath 1.2, 0.6
	Linaccurateline_dot
end

# FILLPATTERNS

begin hatch1
	key "box", "Hatch 1"
	color "red"
	linestyle 0.1
	stroke
	clip "inside"
	stripepath 2, 45
	stroke
end

begin hatch2
	key "box", "Hatch 2"
	color "blue"
	linestyle 0.1
	stroke
	clip "inside"
	stripepath 2, -45
	stroke
end

begin hatch3
	key "box", "Hatch 3"
	color "forestgreen"
	linestyle 0.1
	stroke
	clip "inside"
	stripepath 2, 0
	stroke
end

begin hatch4
	key "box", "Hatch 4"
	color "black"
	linestyle 0.1
	stroke
	clip "inside"
	stripepath 2, 90
	stroke
end

begin crosshatch_lines angle
	# Makes stripes through polygon.  Used for cross-hatching
	# so that original path is saved in calling function
	# and can be re-used for second set of hatch lines.
	#
	stripepath 2, angle
	stroke
end

begin crosshatch
	# Fill polygon with crosshatching.
	#
	key "box", "Crosshatch"
	color "orange"
	linestyle 0.1
	stroke
	clip "inside"
	stroke
	crosshatch_lines 45
	crosshatch_lines -45
end

begin mesh
	# Fill polygon with horizontal and vertical mesh pattern.
	#
	key "box", "Mesh"
	color "darkgray"
	linestyle 0.1
	stroke
	clip "inside"
	stroke
	crosshatch_lines 0
	crosshatch_lines 90
end

begin doublestripefill
	# Fill polygon with stripes of two different colours.
	#
	key "box", "Double Stripes"
	color "blue"
	fill
	clip "inside"
	color "yellow"
	linestyle 1
	stripepath 2, 45
	stroke
end

begin triplestripefill
	# Fill polygon with stripes in three different colours.
	#
	key "box", "Triple Stripes"
	color "grey90"
	fill
	clip "inside"
	stripepath 5, 45
	color "lightpink"
	linestyle 3
	stroke
	color "deeppink"
	linestyle 1
	stroke
end

begin halffill_box c1, c2, c3, c4
	# Draw a square with the 4 quadrants in different colors.
	#
	box -1, -1, 0, 0
	color c1
	fill

	clearpath
	box -1, 0, 0, 1
	color c2
	fill

	clearpath
	box 0, -1, 1, 0
	color c3
	fill

	clearpath
	box 0, 0, 1, 1
	color c4
	fill
end

begin halffill
	# Fill polygon with squares of alternating colours.
	#
	key "box", "Half Fill"
	clip "inside"
	stripepath 2, 0
	samplepath 2, 0
	halffill_box "beige", "brown", "brown", "beige"
end

begin quiltfill
	# Fill polygon with quilt-type pattern using four different colours.
	#
	key "box", "Quilt Fill"
	clip "inside"
	stripepath 2, 0
	samplepath 2, 0
	halffill_box "red", "yellow", "purple", "orange"
end

begin circlefill_circle
	circle 0, 0, 2
	fill
end

begin circlefill
	# Fill polygon with regularly space circles.
	#
	key "box", "Circle Fill"
	color "white"
	fill
	clip "inside"
	color "dodgerblue"
	stripepath 5, 0
	samplepath 5, 0
	circlefill_circle
end

begin boxfill_box
	box -1, -1, 1, 1
	fill
end

begin boxfill
	# Fill polygon with regularly space boxes.
	#
	key "box", "Box Fill"
	color "white"
	fill
	clip "inside"
	color "lightpink"
	stripepath 4, 0
	samplepath 4, 0
	boxfill_box
end

begin repeaticon hexdigits, iconsize
	# Repeats an icon all through a polygon in
	# a tiling pattern.
	#
	clip "inside"
	stripepath iconsize, 0
	samplepath iconsize, 0
	icon hexdigits, iconsize
end

begin chessfill
	key "box", "Chessboard Pattern"
	color "black"
	repeaticon "0xaa55aa55aa55aa55", 5
end

begin walltiling
	key "box", "Wall Tiling"
	color "navy"
	repeaticon "0xf888a888f8000000", 5
end

begin trellistiling
	key "box", "Trellis Tiling"
	color "black"
	repeaticon "0xfcfcc4c4c4fc0000", 4
end

begin dotpattern
	key "box", "Dot Pattern"
	color "crimson"
	repeaticon "0xaa00aa00aa00aa00", 6
end

begin halftone
	key "box", "Halftone"
	color "black"
	repeaticon "0x56a9a659659a6a95", 5
end

begin stipple
	key "box", "Stipple"
	color "blue"
	repeaticon "0xaa44aa00aa44aa00", 5
end

begin brickfill
	key "box", "Brick Fill"
	color "firebrick"
	fill
	color "sandybrown"
	repeaticon "0xff808080ff080808", 2
end

begin weavefill_box
	# Display lines that weave under and over each other.
	# Segments must be drawn in correct order to achieve
	# correct over-and-under effect.
	#
	move -2, 0
	draw 0, 2
	color "black"
	linestyle 1
	stroke

	clearpath
	color "white"
	linestyle 2
	move -0.5, 0.5
	draw -1.5, 1.5
	stroke

	clearpath
	color "black"
	linestyle 1
	move -2, 2
	draw 2, -2
	stroke

	clearpath
	color "white"
	linestyle 2
	move 0.5, -1.5
	draw 1.5, -0.5
	stroke

	clearpath
	color "black"
	linestyle 1
	move 0, -2
	draw 2, 0
	stroke
end

begin weavefill
	# Fill polygon with perpendicular lines that appear to weave
	# in between each other.
	#
	key "box", "Weave Fill"
	color "white"
	fill
	clip "inside"
	stripepath 4, 0
	samplepath 4, 0
	weavefill_box
end

begin hashfill_box
	color "indigo"
	font "Helvetica", 3
	move 0, 0
	label "#"
end

begin hashfill
	# Fill polygon with '#' characters.
	#
	key "box", "Hash Fill"
	color "ivory"
	fill
	clip "inside"
	stripepath 2.7, 0
	samplepath 2.7, 0
	hashfill_box
end

begin wedgefill_box
	color "orange"

	move -1.8, 1
	draw 1.8, 0, -1.8, -1
	closepath

	move -1.8, 2
	draw 1.8, 2, 1.8, 1
	closepath

	move -1.8, -2
	draw 1.8, -2, 1.8, -1
	closepath

	fill
end

begin wedgefill
	# Fill polygon with triangular wedge pattern.
	#
	key "box", "Wedge Fill"
	color "grey90"
	fill
	clip "inside"
	stripepath 4, 0
	samplepath 4, 0
	wedgefill_box
end

begin aggregate_triangle
	# Draw a triangle at a random angle at a random position.
	#
	move random(4) - 2, random(4) - 2
	rotate random(360)
	equitriangle
end

begin aggregate
	# Show triangular aggregrate rock symbols in random pattern
	# through polygon.
	#
	key "box", "Aggregate"
	linestyle 0.1
	color "slateblue"
	stroke
	clip "inside"
	stripepath 4, 0
	samplepath 4, 0
	aggregate_triangle
end

begin savannah_v
	# Show 'v' symbol at random position.
	#
	local x, y
	let x = 1 - random(2)
	let y = 1 - random(2)
	clearpath
	move x - 0.6, y + 1
	draw x, y
	draw x + 0.6, y + 1
	stroke
end

begin savannah
	# Fill polygon with 'v' symbols.
	#
	key "box", "Grassland"
	clip "inside"
	stripepath 5, 0
	samplepath 5, 0
	color "#44cc44"
	linestyle 0.2
	savannah_v
end

begin wheatfield_kernel
	# Show wheat kernel symbol.
	#
	rotate -Mapyrus.rotation
	move -0.8, 2
	draw -0.8, 0
	draw 0, -0.5
	draw 0, -1.5
	draw 0, -0.5
	draw 0.8, 0
	draw 0.8, 2
	stroke
	move 0, 3
	draw 0, 1
	stroke
end

begin wheatfield
	# Fill polygon with wheat symbols.
	#
	key "box", "Wheat Field"
	clip "inside"
	stripepath 6, 10
	samplepath 6, 0
	color "orange"
	linestyle 0.2
	wheatfield_kernel
end

begin barerock_rock
	# Show rock symbol as '/\_'.
	#
	rotate -Mapyrus.rotation
	move -1, 0
	draw 0, 3, 1, 0, 2, 0
	stroke
	move 1, 0
	draw 0.8, 0, -0.1, 2.8, 0, 3
	stroke
end

begin barerock
	# Fill polygon with rock symbols.
	#
	key "box", "Bare Rock",
	clip "inside"
	stripepath 6, 45
	samplepath 6, 0
	color "#cccccc"
	linestyle 0.1
	barerock_rock
end

begin marsh_grass
	# Show marsh grass symbol as '\|/'.
	#
	local x
	rotate -Mapyrus.rotation
	let x = 2 - random(4)
	clearpath
	move x - 1, 0
	draw x + 1, 0
	move x, 0
	draw x, 1
	move x, 0
	draw x + 1, 1
	move x, 0
	draw x - 1, 1
	stroke
end

begin marsh
	# Fill polygon with marsh symbols.
	#
	key "box", "Marsh"
	clip "inside"
	stripepath 6, 45
	samplepath 6, 0
	color "#a52a2a"
	linestyle 0.1
	marsh_grass
end

begin water
	key "box", "Water"
	color "#80b2ff"
	fill
end

begin citylimits
	# Display thick border line around inside of polygon.
	#
	key "box", "City Limits"
	linestyle 0.1
	stroke
	clip "inside"
	linestyle 3, "round", "round"
	color "pink", 0.5
	stroke
end

begin restrictedarea
	# Display thick border line around outside of polygon.
	#
	key "box", "Restricted Area"
	linestyle 0.1
	stroke
	clip "outside"
	linestyle 3, "round", "round"
	color "olive"
	stroke
end

# If special variable is set then show all above symbols in a legend
# on a separate page.
#
if show_symbols_legend == 1
then
	# Force each symbol to be used so that it is included as a
	# legend entry.
	#
	# Then draw the legend which is what we really want to see.
	#
	move -10, -10
	circleoutline
	equitriangle
	squareoutline
	filledsquare
	filledpentagon
	filledhexagon
	octagonoutline
	x1
	plus1
	sixpointstar
	fivepointstar
	arrowupoutline
	arrowdownoutline
	arrowleftoutline
	arrowrightoutline
	arrowupleftoutline
	shipwreck
	viewpoint
	surveymarker
	trigstation
	witchshat
	oldmoon
	newmoon
	trafficlights ""
	quadrants "", 1, 1, 1, 1, 0
	speechbubble ""
	windindicator 0, 1, ""
	temperatureHistogram "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
	bordercrossing
	crosshair
	lighthouse
	information
	sbahn
	ubahn
	parking
	coveredparking
	cave
	flag
	pennant
	pinetree
	radiotower
	church
	hospital
	tent
	hut
	fairground
	factory
	school
	postoffice
	library
	police
	cemetary
	waypoint
	capitalcity "Ely"
	city "Ely"
	town "Ely"
	emphasisedname "Ely"
	streetname ""
	Lleftticks
	Lcenterline
	Lfence
	Lbowtie
	Lmotorway ""
	Lborder
	Lrailway
	Lpowerline
	Ldashdot
	Lmulticolorline
	Larrowline
	Lsnakeline
	Linaccurateline
	hatch1
	hatch2
	hatch3
	hatch4
	crosshatch
	mesh
	doublestripefill
	triplestripefill
	halffill
	quiltfill
	circlefill
	boxfill
	chessfill
	walltiling
	trellistiling
	dotpattern
	halftone
	stipple
	brickfill
	weavefill
	hashfill
	wedgefill
	aggregate
	savannah
	wheatfield
	barerock
	marsh
	water
	citylimits
	restrictedarea

	let count = 0, x = 9999, y = 9999
	let pageNumber = 0
	while Mapyrus.key.count > 0
	do
		# Start a new page when we run off edge of page.
		#
		if x > 150
		then
			let pageNumber = pageNumber + 1
			newpage "eps", "symbols" . pageNumber . ".eps", 170, 200, "lineantialiasing=true"

			# Ensure page has a white background.
			#
			box 0, 0, Mapyrus.page.width, Mapyrus.page.height
			color "white"
			fill
			color "black"
			font "Helvetica", 3
			let x = 10, y = Mapyrus.page.height - 10
		endif

		clearpath
		move x, y

		# Draw north arrows specially.  They have no legend entry
		# as we never want them appearing in a real legend!
		#
		if counter == 0
		then
			clearpath
			move x + 5, y
			northarrow
			label "        northarrow"
		elif counter == 1
		then
			clearpath
			move x + 5, y - 15
			nsew
			label "        nsew"
			let y = y - 30
		elif match(Mapyrus.key.next, "^L")
		then
			# Display lines with bigger entries so that
			# any pattern along the line is visible.
			#
			legend 16
		else
			legend 8
		endif

		let y = y - 10
		if y < 10
		then
			let x = x + 50
			let y = Mapyrus.page.height - 10
		endif

		let counter = counter + 1
	done
endif

