Currently there are three versions of these files. Pocket Notes
version 0.3 can handle apn file version 1 and 2. Pocket Notes
version 0.4 can also handle version 3 of the apn files.
Every version of Pocket Notes saves the notes in the latest
format it can handle.

Format version 1

The goal of version 1 was to save the notes somehow, so I created
a simple format.

1-3 bytes: "APN"

4. byte: version number, currently 1

5-8. byte: Nunmber of inks

The rest of the file: the list of the inks

The inks follow immediately each other. Each ink is stored the same way:

4 bytes: Ehe width of the pen

1 byte: The red component of the pen color

1 byte: The green component of the pen color

1 byte: The blue component of the pen color

1 byte: not used, write 0.

4 bytes: Number of vertices

List of vertices

The vertices follow immediately each other. Each vertex is stored the same way:
the x and the y coordinates, both in 4 bytes.

Format version 2 and 3

The structure of version 2 is the same as version 3, the difference between the two
is that less commands can be used in version 2. (So you can handle format
version 2 as version 3 file).

1-3 bytes: "APN"

4. byte: version number, 2 or 3

The rest of the file: list of commands

The format of the commands: Each command starts with an ID byte, which is followed
by the arguments of the command. The size of the arguments depends on the command.

You have to use variables, which define the attributes of the currently read element.
There are commands to change the values of the variables. At beginning of the process
the variables have default values.

Each file can have any number of Property. Each Property is a name-value pair, where the
name and the pair can contain any characters and can be any long. There are special
Properties.

The variables and their default values:

Name of the variable

Type

Defined attribute

Default value

Pen color

RGB (int, int, int)

The color of the inks

(0, 0, 0)

Pen width

int

The width of the inks

4

Pen marker

bool

Are the inks in marker mode or not

false

Offset

2D pont (int, int)

The offset of the coordinates

(0, 0)

View offset

2D pont (int, int)

The viewing offset of the editor when the document was saved

(0, 0)

Zoom

float

The zoom level in the editor when the document was saved

1.0

Paper color

RGB (int, int, int)

The color of the paper

(255, 255, 255)

Pattern color

RGB (int, int, int)

The color of the pattern of the paper

(0, 128, 255)

Pattern size

int

The distance of the patterns of the paper

40

Pattern width

int

The line width of the patterns of the paper

1

Paper type

int

The type of the pattern of the paper (see types at command 21)

0

Year

Year number (int)

The year when the elements were drawn

1960

Month

Month number (int)

The month when the elements were drawn

1 (January)

Day

Day number (int)

The day when the elements were drawn

1

Hour

Hour number (int)

The hour when the elements were drawn (begins with 0)

0

Minute

Minute number (int)

The minute when the elements were drawn (begins with 0)

0

List of available commands:

Command ID

Effect

Parameters

From which version can you use them

0

End of the file

None

2

1

Change Pen color

3 bytes: R, G, B. Unsigned integers

2

2

Set Pen color to (0, 0, 0)

None

2

3

Set Pen color to (128, 0, 0)

None

2

4

Set Pen color to (0, 128, 0)

None

2

5

Set Pen color to (0, 0, 128)

None

2

6

Set Pen color to (128, 128, 128)

None

2

7

Change Pen width

1 byte: the new value - 1. (So if the parameter is 0 it changes Pen width to 1)

2

8

Set Pen width to 1

None

2

9

Set Pen width to 2

None

2

10

Set Pen width to 3

None

2

11

Set Pen width to 4

None

2

12

Change Offset

2 bytes: x and y offset in 1-1 bytes, unsigned

2

13

Change Offset

4 bytes: x and y offset in 2-2 bytes, unsigned

2

14

Change Offset

8 bytes: x and y offset in 4-4 bytes, unsigned

2

15

Draw polylines

Each polyline:

2 bytes: number of vertices

The vertices, each of them on 2 bytes: x and y coordinates in 1-1 byte.

They follow immediately each oter. The end of the list is a polyline with 0 vertices.

2

16

Draw polylines

Each polyline:

2 bytes: number of vertices

The vertices, each of them on 2 bytes: x and y coordinates in 2-2 bytes.

They follow immediately each oter. The end of the list is a polyline with 0 vertices.

2

17

Draw polylines

Each polyline:

2 bytes: number of vertices

The vertices, each of them on 2 bytes: x and y coordinates in 4-4 bytes.

They follow immediately each oter. The end of the list is a polyline with 0 vertices.

2

18

Change Editor Offset

8 bytes: x and y offsets in 4-4 bytes, unsigned

2

19

Change Editor zoom

4 bytes long unsigned integer: the value of zoom multiplied by 65536

2

20

Set a Property

4 bytes: The length of the name of the Property in bytes

The name of the Property

4 bytes: The length of the value of the Property in bytes

The value of the Property

2

21

Cahnge Paper type

1 byte, which can be:

0: Blank paper

1: Paper with horizontal lines

2: Paper with the same pattern as the heft of a young boy in the elementary school

3: Chequered paper

4: Quadrilled paper

2

22

Change Paper color

3 bytes: R, G and B values

2

23

Change Pattern color

3 bytes: R, G and B values

2

24

Change Pattern size

1 byte: size

2

25

Cahnge Pattern width

1 byte: size

2

26

Set Pen marker to true

None

2

27

Set Pen marker to false

None

2

28

Change Year

2 bytes: unsigned integer: the year number.

3

29

Change Month

1 byte: the month number (1 is January)

3

30

Change Day

1 byte: the day number

3

31..55

Change Hour

None, the command ID contains the parameter. The new value is (command ID - 31).

3

56..116

Minute értékének állítása

None, the command ID contains the parameter. The new value is (command ID - 56).

3

About paper patterns

A short description about the built-in pattern types.

Paper with horizontal lines: Horizontal lines. The distance between two lines is Pattern size * 3.

Paper with the same pattern as the heft of a young boy in the elementary school: Horizontal lines. The distance between two lines is Pattern size. The width of every thrid line is Pattern width * 3.

Chequered paper: Horizontal and vertical lines. The distance between them is Pattern size.

Quadrilled paper: Horizontal and vertical lines. The horizontal distance between them is Pattern size, the vertical distance between them is Pattern size * 2.