Pattern File Format

A pattern file consists of a header followed by one or more patterns. The header consists of the string "<--Picture File-->\n". This header is used to mark the file and only existing files that are so marked are written to by the Perl script WritePicture.

Patterns consist of a 6 byte length followed by a pattern body. The length is the number of bytes contained in this pattern body.

Pattern ElementLength (bytes)
<--Picture File-->\n19
length 16
pattern body 1length 1
length 26
pattern body 2length 2
......

Pattern Body Format

A pattern body consists of one or more pattern elements. Each pattern element consists of a one byte type followed by an element number followed by an element body specific to each element type.

Pattern ElementLength (bytes)
element type1
element number2
element bodyvaries
......

Pattern Element Format

There are 5 element types which are:

Basic Type

Pattern ElementLength (bytes)
01
element number2
size2
picturesize

The format of a picture is described below.

Connect Type

Pattern ElementLength (bytes)
11
element number2
left element number2
right element number2

Scale Type

Pattern ElementLength (bytes)
21
element number2
X08
Y08
XH8
YH8
XV8
YV8
scaled element number2

Rotate Type

Pattern ElementLength (bytes)
31
element number2
degrees2
rotated element number2

Reflect Type

Pattern ElementLength (bytes)
41
element number2
axis1
reflected element number2

Picture Format

A picture body consists of one or more picture segments. A picture segment consists of a one byte type followed by a segment body followed by a two byte link. The possible types and there values are:

TypeValue
Freehand0
Line1
Rectangle2
Oval3
Polygon4
Curve5
Filled Rectangle6
Filled Oval7
Filled Polygon8
Filled Curve9

The two byte link is a byte pointer pointing to the start of the picture segment. This link is used to remove segments when the 'Undo' button is clicked.

Picture ElementLength (bytes)
type 11
segment body 1varies
link 12
type 21
segment body 2varies
link 22
......

Freehand Segment

This segment consists of the number of line segments, line size and color followed by the positions of the end points of the line segments. The positions consist of x and y coordinates.

Picture ElementLength (bytes)
no line segments2
line size2
color3
x1 coord8
y1 coord8
x2 coord8
y2 coord8
......

Polygon and Filled Polygon Segments

These segments consist of the number of points, line size and color followed by the positions of the polygon's defining points.

Picture ElementLength (bytes)
no points2
line size2
color3
x1 coord8
y1 coord8
x2 coord8
y2 coord8
......

Curve and Filled Curve Segments

These segments consist of the line size and color followed by the position of the curve's start point followed by the positions of the curve's 2 control points followed by the position of the curve's end point.

Picture ElementLength (bytes)
line size2
color3
x1 coord8
y1 coord8
x2 coord8
y2 coord8
x3 coord8
y3 coord8
x4 coord8
y4 coord8

Line Segment

This segment consists of the line size and color followed by the line's end point positions.

Picture ElementLength (bytes)
line size2
color3
x1 coord8
y1 coord8
x2 coord8
y2 coord8

Rectangle, Oval, Filled Rectangle and Filled Oval Segments

These segments consist of the line size, color, x coord, y coord, width and height. The x and y coordinates specify the position of the top left corner of the defining rectangle while the width and height specify the rectangle's dimensions.

Picture ElementLength (bytes)
line size2
color3
x coord8
y coord8
width8
height8