Menu

wxdkdraw file format

Dirk Krause
← Previous ↑ Home → Next

Wxdkdraw file format

Symbols

The following symbols are used later in this text.

Bitmap images

Symbol Use
MAX Maximum colour component value for a given bit depth, i. e. 255 for a bit depth of 8.
r Red component, 0≤r≤MAX.
g Green component, 0≤g≤MAX.
b Blue component, 0≤b≤MAX.
e Gray value, 0≤e≤MAX.
c Cyan component, 0≤c≤MAX.
m Magenta component, 0≤m≤MAX.
y Yellow component, 0≤y≤MAX.
k Key (black) component, 0≤k≤MAX.
maxrgb Maximum value of r, g, and b.
max{x1, x2…} Maximum of the listed values.
min{x1, x2…} Minimum of the listed values.
median{x1, x2…} Median of the listed values.

Arrowheads

Arrowhead dimensions

Symbol Use
l Real line width.
la Arrowhead length.
wa Arrowhead width.
s Shift length between corner point and arrowhead end.

Objects

Symbol Use
cf,r Red component of fill and text colour.
cf,g Green component of fill and text colour.
cf,b Blue component of fill and text colour.
cs,r Red component of stroke colour.
cs,g Green component of stroke colour.
cs,b Blue component of stroke colour.
lb Base line width in wxdkdraw units.
l Line width in integer multiples of the base line width lb.
z Zoom level, integer value.
sl Style length, length of dashes in integer multiples of the line width.
xl Left coordinate.
xr Right coordinate.
yb Bottom coordinate.
yt Top coordinate.

Basics

Numeric values

All numeric values are specified in decimal notation.

Text encoding

UTF-8 encoding is used for all text, this includes text labels and file names of embedded images.

Coordinates

Single drawing
Each wxdkdraw file contains exactly one drawing.

Origin
The coordinates origin is the bottom left point. x values grow to the right, y values grow upwards.

Resolution
Coordinates are signed 32 bit integer values, negative values are allowed.
16,256,000 wxdkdraw units are used per inch.

Angles
Angles are specified counterclockwise in degree.

Image size
A wxdkdraw drawing is not bound to a specific paper size. The image size in wxdkdraw units is specified as bounding box in a configuration record.

Layers

Each graphic element is placed on a certain layer. Signed 16 bit integer values are used for layer numbers. −215 is the deepest layer, 215−1 is the uppermost layer.

Groups

Graphic elements can be grouped. Copy, Move and Delete operations affect all elements of a group.

Line widths

Line widths are specified in unsigned integer multiples of the base line width lb. By default the base line width is 12700 wxdkdraw units (1160 inch).
For export you have the option to change the base line width, i. e. to 11247 units (0.4pt).
Elements with line width 0 are not stroked.

Line style and style length

The style length sl specifies the dash length in dash-dot lines in integer multiples of the line width. Changing the line width while keeping sl automatically adjusts the dash-dot pattern.
Minimum is 1, maximum is 255.
The dot length is the line width. The gap length is the minimum of:

  • Average of dash length and dot length and
  • double dot length.
Style number Style
0 Solid line.
1 Dashed line.
2 Dotted line.
3 Dash-dot line.
4 Dash-dot-dot line.
5 Dash-dot-dot-dot line.

Line types

Line ends (cap style)

Style number Style
0 Butted
1 Rounded (half circle added)
2 Projecting (half square added)

Line ends

Corner points (join style)

Style number Style
0 Mitered
1 Rounded
2 Beveled

The miter limit is active for “mitered”. The distance between intersection of the outer edges and intersection of the inner edges must not exceed times the linewidth.

Line join

Fill style

Style number Style
0 No filling.
1 Pure colour filling.
2 Diagonal lines 30° to the left.
3 Diagonal lines 30° to the right.
4 Diagonal lines 30° crosshatch.
5 Diagonal lines 45° to the left.
6 Diagonal lines 45° to the right.
7 Diagonal lines 45° crosshatch.
8 Horizontal bricks.
9 Vertical bricks.
10 Horizontal lines.
11 Vertical lines.
12 Horizontal-vertical crosshatch.
13 Horizontal shingles skewed to the right.
14 Horizontal shingles skewed to the left.
15 Vertical shingles skewed to one side.
16 Vertical shingles skewed to the other side.
17 Fish scales.
18 Small fish scales.
19 Circles.
20 Hexagons.
21 Octagons.
22 Horizontal zigzag lines.
23 Vertical zigzag lines.

The image below shows fill styles 0 to 23.

Line join

Arrowheads

The image below shows the available arrowhead types in wxdkdraw.

Arrowhead types


File structure

A wxdkdraw file is a text file you should process line by line.
Line size — including line ends (simple newline or CR/NL combination) — is restricted to 1023 characters.
A *.wxd file consists of a header line and records.


Header line

WXD major minor

Type Name or value Description
string WXD Constant text “WXD” to mark the file type.
uint16_t major Major file format version number (1).
uint16_t minor Minor file format version number (0).

Records

For each record there is a start line. For some record types details lines follow.
A start line starts immediately at the start of the line without leading spaces.
Details lines are intended by exactly one space or exactly one tabulator.
On problems while processing a record — i. e. an old program version attempts to read a file in a newer format version — the program can attempt to resume reading the file on the next record start line when encountering an unknown record type.

Configuration records

All configuration records must be placed before the first graphic element record.

Configuration records are started by a leading 0. Another integer number follows to choose a configuration option. Next we have configuration values.

Bounding box

00xlxrybyt

Type Name or value Description
int16_t 0 Record type: Configuration record.
int16_t 0 Sub type: Bounding box.
int32_t xl Left coordinate in wxdkdraw units.
int32_t xr Right coordinate in wxdkdraw units.
int32_t yb Bottom coordinate in wxdkdraw units.
int32_t yt Top coordinate in wxdkdraw units.

The bounding box record is required in each wxdkdraw file.

Base line width

01lb

Type Name or value Description
int16_t 0 Record type: Configuration record.
int16_t 1 Sub type: Base line width.
uint32_t lb Base line width in wxdkdraw units.

This record is optional, it should only be used if the base line width differs from the default line width (1160 inch).

Zoom level

02z

Type Name or value Description
int16_t 0 Record type: Configuration record.
int16_t 2 Sub type: Zoom level.
int8_t z Zoom level, -14≤z≤14.

This record is optional. By default a zoom level 0 (zoom factor 100 %) is used.
Positive zoom levels are used to zoom in, negative zoom levels are used to zoom out.
Each zoom level step changes the zoom by factor 2.

Borders

0 4 bl br bb bt

Type Name or value Description
int16_t 0 Record type: Configuration record.
int16_t 4 Sub type: Borders.
uint32_t bl Left border in wxdkdraw units.
uint32_t br Right border in wxdkdraw units.
uint32_t bb Bottom border in wxdkdraw units.
uint32_t bt Top border in wxdkdraw units.

This record is optional. One inch borders are used by default.

Grid unit

05u

Type Name or value Description
int16_t 0 Record type: Configuration record.
int16_t 5 Sub type: Grid unit.
uint8_t u Grid unit:
0
inches
1
centimeters

This record is optional. Inches are used by default.

Grid base

06b

Type Name or value Description
int16_t 0 Record type: Configuration record.
int16_t 6 Sub type: Grid base.
uint8_t b Grid base:
0
Powers of 2
1
5 · powers of 2

This record is optional. Powers of two are used by default.

For zoom level 0 grid setup is used as follows:

Unit Base Optical grid Snap grid
0 (inches) 0 (powers of 2) 2 / inch 8 / inch
0 (inches) 1 (5 · powers of 2) 2 / inch 10 / inch
1 (cm) 0 (powers of 2) 1 / cm 4 / cm
1 (cm) 1 (5 · powers of 2) 1 / cm 5 / cm

Element records for grouping

Group start

1

Type Name or value Description
int16_t 1 Record type: Start of group.

Group end

-1

Type Name or value Description
int16_t -1 Record type: End of group.

Text labels

2Lcf,rcf,gcf,b
ifsfahfxyα
t
ts

Type Name or value Description
int16_t 2 Record type: Text label.
int16_t L Layer number.
uint8_t cf,r Text colour, red component.
uint8_t cf,g Text colour, green component.
uint8_t cf,b Text colour, blue component.

The first details line specifies text representation and coordinates:

Type Name or value Description
uint8_t if Font index, 0≤if≤34.
uint16_t sf Font size in pt (the LaTeX unit pt, 72,26999 pt = 1 inch).
uint8_t ah Horizontal alignment:
0
left
1
centered
2
right
uint8_t f Flags, bitwise combination of:
1
LaTeX text
int32_t x Text anchor coordinate in wxdkdraw units.
int32_t y Text anchor coordinate in wxdkdraw units.
int16_t α Rotation counter-clockwise in degree.

The second details line contains the text to export (the “real” text):

Type Name or value Description
string t Text to export, the “real” text.

The third details line contains a simplified text shown on the screen:

Type Name or value Description
string ts Text to show on screen in wxdkdraw (simplified version of t).

If the third details line contains just a leading space/tabulator and the line end the export text is used for on-screen representation too.
The on-screen text should be a simplified version of the export text. If you want to export “\(R_1\)” for LaTeX, use an on-screen text “R1”.
Text must not contain newlines. Multi-line text must be specified in multiple text label records.
The text must not contain more than 1020 characters.
The font index if chooses a font from the table below.
For special text (LaTeX text) font index and font size are ignored. Use LaTeX instructions in the text instead.

Font index if Font
0 Times Roman
1 Times Italic
2 Times Bold
3 Times Bold Italic
4 Avantgarde Book
5 Avantgarde Book Oblique
6 Avantgarde Demi
7 Avantgarde Demi Oblique
8 Bookman Light
9 Bookman Light Italic
10 Bookman Demi
11 Bookman Demi Italic
12 Courier
13 Courier Oblique
14 Courier Bold
15 Courier Bold Oblique
16 Helvetica
17 Helvetica Oblique
18 Helvetica Bold
19 Helvetica Bold Oblique
20 Helvetica Narrow
21 Helvetica Narrow Oblique
22 Helvetica Narrow Bold
23 Helvetica Narrow Bold Oblique
24 New Century Schoolbook Roman
25 New Century Schoolbook Italic
26 New Century Schoolbook Bold
27 New Century Schoolbook Bold Italic
28 Palatino Roman
29 Palatino Italic
30 Palatino Bold
31 Palatino Bold Italic
32 Symbol
33 Zapf Chancery Medium Italic
34 Zapf Dingbats

Graphic elements

Polyline

3nLcs,rcs,gcs,blssslcjmafla,fwa,fabla,bwa,b
x1y1
 …

Type Name or value Description
int16_t 3 Record type: Polyline.
uint16_t n Number of points, at least 2.
int16_t L Layer number.
uint8_t cs,r Stroke colour, red component.
uint8_t cs,g Stroke colour, green component.
uint8_t cs,b Stroke colour, blue component.
uint16_t l Line width in integer multiples of the base line width.
uint8_t ss Line style.
uint8_t sl Style length.
uint8_t c Line cap style.
uint8_t j Line join style.
uint8_t m Miter limit.
uint8_t af Arrowhead type, forward arrowhead.
uint8_t la,f Arrowhead length, forward arrowhead.
uint8_t wa,f Arrowhead width, forward arrowhead.
uint8_t ab Arrowhead type, backward arrowhead.
uint8_t la,b Arrowhead length, backward arrowhead.
uint8_t wa,b Arrowhead width, backward arrowhead.

There are n details lines containing point coordinates:

Type Name or value Description
int32_t xi X position.
int32_t yi Y position.

Open X-spline

4nLcs,rcs,gcs,blssslcjmafla,fwa,fabla,bwa,b
x1y1s1
 …

Type Name or value Description
int16_t 4 Record type: Open X-spline.
uint16_t n Number of points, at least 2.
int16_t L Layer number.
uint8_t cs,r Stroke colour, red component.
uint8_t cs,g Stroke colour, green component.
uint8_t cs,b Stroke colour, blue component.
uint16_t l Line width in integer multiples of the base line width.
uint8_t ss Line style.
uint8_t sl Style length.
uint8_t c Line cap style.
uint8_t j Line join style.
uint8_t m Miter limit.
uint8_t af Arrowhead type, forward arrowhead.
uint8_t la,f Arrowhead length, forward arrowhead.
uint8_t wa,f Arrowhead width, forward arrowhead.
uint8_t ab Arrowhead type, backward arrowhead.
uint8_t la,b Arrowhead length, backward arrowhead.
uint8_t wa,b Arrowhead width, backward arrowhead.

There are details lines containing point coordinates and parameter value:

Type Name or value Description
int32_t xi X position.
int32_t yi Y position.
float si S parameter value, -1≤s≤1.

Open arc

5Lcs,rcs,gcs,blssslcafla,fwa,fabla,bwa,b
x1y1x2y2x3y3

Type Name or value Description
int16_t 5 Record type: Open arc.
int16_t L Layer number.
uint8_t cs,r Stroke colour, red component.
uint8_t cs,g Stroke colour, green component.
uint8_t cs,b Stroke colour, blue component.
uint16_t l Line width in integer multiples of the base line width.
uint8_t ss Line style.
uint8_t sl Style length.
uint8_t c Line cap style.
uint8_t af Arrowhead type, forward arrowhead.
uint8_t la,f Arrowhead length, forward arrowhead.
uint8_t wa,f Arrowhead width, forward arrowhead.
uint8_t ab Arrowhead type, backward arrowhead.
uint8_t la,b Arrowhead length, backward arrowhead.
uint8_t wa,b Arrowhead width, backward arrowhead.

The details line contains the coordinates of the 3 points clicked:

Type Name or value Description
int32_t x1 X position point 1.
int32_t y1 Y position point 1.
int32_t x2 X position point 2.
int32_t y2 Y position point 2.
int32_t x3 X position point 3.
int32_t y3 Y position point 3.

Polygon (closed polyline)

6nLcs,rcs,gcs,bcf,rcf,gcf,blsssljmsf
x1y1
 …

Type Name or value Description
int16_t 6 Record type: Polygon (closed polyline).
uint16_t n Number of points, at least 2.
int16_t L Layer number.
uint8_t cs,r Stroke colour, red component.
uint8_t cs,g Stroke colour, green component.
uint8_t cs,b Stroke colour, blue component.
uint8_t cf,r Fill colour, red component.
uint8_t cf,g Fill colour, green component.
uint8_t cf,b Fill colour, blue component.
uint16_t l Line width in integer multiples of the base line width.
uint8_t ss Line style.
uint8_t sl Style length.
uint8_t j Line join style.
uint8_t m Miter limit.
uint8_t sf Fill style.

There are n details lines containing point coordinates:

Type Name or value Description
int32_t xi X coordinate.
int32_t yi Y coordinate.

The start point is not repeated as end point.

Closed X-spline

7nLcs,rcs,gcs,bcf,rcf,gcf,blsssljmsf
x1y1s1
 …

Type Name or value Description
int16_t 7 Record type: Closed X-spline.
uint16_t n Number of points, at least 2.
int16_t L Layer number.
uint8_t cs,r Stroke colour, red component.
uint8_t cs,g Stroke colour, green component.
uint8_t cs,b Stroke colour, blue component.
uint8_t cf,r Fill colour, red component.
uint8_t cf,g Fill colour, green component.
uint8_t cf,b Fill colour, blue component.
uint16_t l Line width in integer multiples of the base line width.
uint8_t ss Line style.
uint8_t sl Style length.
uint8_t j Line join style.
uint8_t m Miter limit.
uint8_t sf Fill style.

There are n details lines containing point coordinates and spline value:

Type Name or value Description
int32_t xi X coordinate.
int32_t yi Y coordinate.
float si value for point, -1≤s≤1.

The start point is not repeated as end point.

Closed arc

8Lcs,rcs,gcs,bcf,rcf,gcf,blsssljmsf
x1y1x2y2x3y3

Type Name or value Description
int16_t 8 Record type: Closed arc.
int16_t L Layer number.
uint8_t cs,r Stroke colour, red component.
uint8_t cs,g Stroke colour, green component.
uint8_t cs,b Stroke colour, blue component.
uint8_t cf,r Fill colour, red component.
uint8_t cf,g Fill colour, green component.
uint8_t cf,b Fill colour, blue component.
uint16_t l Line width in integer multiples of the base line width.
uint8_t ss Line style.
uint8_t sl Style length.
uint8_t j Line join style.
uint8_t m Miter limit.
uint8_t sf Fill style.

The details line contains the coordinates of the 3 points clicked:

Type Name or value Description
int32_t x1 X position point 1.
int32_t y1 Y position point 1.
int32_t x2 X position point 2.
int32_t y2 Y position point 2.
int32_t x3 X position point 3.
int32_t y3 Y position point 3.

Circle

9Lcs,rcs,gcs,bcf,rcf,gcf,blssslsf
xyr

Type Name or value Description
int16_t 9 Record type: Circle.
int16_t L Layer number.
uint8_t cs,r Stroke colour, red component.
uint8_t cs,g Stroke colour, green component.
uint8_t cs,b Stroke colour, blue component.
uint8_t cf,r Fill colour, red component.
uint8_t cf,g Fill colour, green component.
uint8_t cf,b Fill colour, blue component.
uint16_t l Line width in integer multiples of the base line width.
uint8_t ss Line style.
uint8_t sl Style length.
uint8_t sf Fill style.

The details line contains the coordinates:

Type Name or value Description
int32_t x Center point X position.
int32_t y Center point Y position.
uint32_t r Radius.

Filled dot

13Lcf,rcf,gcf,b
xyd

Type Name or value Description
int16_t 13 Record type: Colour filled dot.
int16_t L Layer number.
uint8_t cf,r Fill colour, red component.
uint8_t cf,g Fill colour, green component.
uint8_t cf,b Fill colour, blue component.

The details line contains the coordinates:

Type Name or value Description
int32_t x Center point X position.
int32_t y Center point Y position.
uint16_t d Diameter in integer multiples of the base line width.

The filled dot is used in electronic circuits to mark electrical connections on crossing nets.
It is placed by center point.

White filled dot

14Lcs,rcs,gcs,b
xydl

Type Name or value Description
int16_t 14 Record type: White filled dot.
int16_t L Layer number.
uint8_t cs,r Fill colour, red component.
uint8_t cs,g Fill colour, green component.
uint8_t cs,b Fill colour, blue component.

The details line contains the coordinates:

Type Name or value Description
int32_t x Center point X position.
int32_t y Center point Y position.
uint16_t d Diameter in integer multiples of the base line width.
uint16_t l Line width of stroked border, ld.

The white filled dot is used in electronic circuits to mark pins at the end of a net.
It is placed by center point.

Ellipse

10Lcs,rcs,gcs,bcf,rcf,gcf,blssslsf
xyrxryα

Type Name or value Description
int16_t 10 Record type: Ellipse.
int16_t L Layer number.
uint8_t cs,r Stroke colour, red component.
uint8_t cs,g Stroke colour, green component.
uint8_t cs,b Stroke colour, blue component.
uint8_t cf,r Fill colour, red component.
uint8_t cf,g Fill colour, green component.
uint8_t cf,b Fill colour, blue component.
uint16_t l Line width in integer multiples of the base line width.
uint8_t ss Line style.
uint8_t sl Style length.
uint8_t sf Fill style.

The details line contains the coordinates:

Type Name or value Description
int32_t x X coordinate.
int32_t y Y coordinate.
uint32_t rx X radius.
uint32_t ry Y radius.
int16_t α Rotation counterclockwise in degree.

Box

11Lcs,rcs,gcs,bcf,rcf,gcf,blssslsf
xlxrybytr

Type Name or value Description
int16_t 11 Record type: Box.
int16_t L Layer number.
uint8_t cs,r Stroke colour, red component.
uint8_t cs,g Stroke colour, green component.
uint8_t cs,b Stroke colour, blue component.
uint8_t cf,r Fill colour, red component.
uint8_t cf,g Fill colour, green component.
uint8_t cf,b Fill colour, blue component.
uint16_t l Line width in integer multiples of the base line width.
uint8_t ss Line style.
uint8_t sl Style length.
uint8_t sf Fill style.

The details line contains the coordinates.

Type Name or value Description
int32_t xl Left X coordinate.
int32_t xr Right X coordinate.
int32_t yb Bottom Y coordinate.
int32_t yt Top Y coordinate.
uint32_t r Corner radius (0 for simple rectangle).

The rounded corners radius must be smaller than half the smaller rectangle side length.

Embedded image

12Lcf,rcf,gcf,b
fmrgb2graymrgb2cmykxywh
nf

Type Name or value Description
int16_t 12 Record type: Embedded image.
int16_t L Layer number.
uint8_t cf,r Fill colour, red component.
uint8_t cf,g Fill colour, green component.
uint8_t cf,b Fill colour, blue component.

The background colour is only used if the image contains an alpha channel and no background colour information.

The first details line contains flags and coordinates:

Type Name or value Description
uint8_t f Flags, see table below.
int8_t mrgb2gray Method for RGB to gray conversion.
int8_t mrgb2cmyk Method for RGB to CMYK conversion.
int32_t x X position of lower left point.
int32_t y Y position of lower left point.
uint32_t w Image width (must be larger than 0).
uint32_t h Image height (must be larger than 0).

The second details line contains the image file name:

Type Name or value Description
string nf Image file name.

UTF-8 encoding is used for the file name. I recommend to use ASCII characters only in file names.
Relative file names should be used.

The flags f value is an or-combination of the following bits (bit 0 is the least significant bit on the right):

Bit number Purpose
0 Keep aspect ratio:
0
no
1
yes
1 Use opacity value from alpha channel:
0
no, ignore alpha channel
1
yes, mix foreground against background
2 Allow image interpolation:
0
no
1
yes
3 Allow direct re-use of DCT-compressed data:
0
no
1
yes
4 Allow image interpolation on directly re-used DCT data:
0
no
1
yes
5 Enforce background colour from WXD file:
0
no, prefer background colour information from image file if available
1
yes

The following mrgb2gray values can be used to choose the RGB to gray conversion method:

Value Formula Method
-1 Default method.
0 e=299r+587g+114b1000 Keep luminance as specified by ITU BT601.
1 e=30r+59g+11b100 Alternative method to keep luminance (shorter coefficients).
2 e=(77r+151g+28b)>>8 Fast and a little inaccurate by avoiding divisions.
3 e=((r<<1)+(g<<2)+g+b)>>3 Faster and more inaccurate by avoiding both multiplications and divisions.
4 e=2126r+7152g+722b10000 Keep luminance as specified by ITU BT709.
5 e=r+g+b3 Average.
6 e=max(r,g,b)+min(r,g,b)2 Desaturation.
7 e=min(r,g,b) Minimum decomposition.
8 e=median(r,g,b) Median decomposition.
9 e=max(r,g,b) Maximum decomposition.
10 e=r Red channel.
11 e=g Green channel.
12 e=b Blue channel.

The following mrgb2cmyk values can be used to choose the RGB to CMYK conversion method:

Value Method
-1 Default method (same as 0).
0 Algorithm as not described in Adobe PS and PDF standard.
1 Simplified algorithm from Adobe PS and PDF standard without undercolor removal and black correction.

The mrgb2cmyk value is ignored, wxd2lat produces RGB or gray output only.

Algorithm 0:

maxrgb = max{r,g,b}
if 0 = maxrgb
then
k = MAX
c = m = y = 0
else
c = maxrgb - r
m = maxrgb - g
y = maxrgb - b
c = (MAX * c) / maxrgb
m = (MAX * m) / maxrgb
y = (MAX * y) / maxrgb
k = MAX - maxrgb
endif

Algorithm 1:

maxrgb = max{r,g,b}
c = maxrgb - r
m = maxrgb - g
y = maxrgb - b
k = MAX - maxrgb


← Previous ↑ Home → Next

Related

Wiki: wxdkdraw

MongoDB Logo MongoDB