File: devguide-27.html

package info (click to toggle)
sketch 0.6.13-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,284 kB
  • ctags: 8,453
  • sloc: python: 34,711; ansic: 16,543; makefile: 83; sh: 26
file content (139 lines) | stat: -rw-r--r-- 5,217 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<html>
<head>
<title>Developer's Guide: File Format</title>
</head>
<body bgcolor=white text=black link=blue vlink=navy alink=red>
<TABLE WIDTH="100%">
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
<TR>
<TD ALIGN="left"><A HREF="devguide-26.html">Message Passing</A></TD>
<TD ALIGN="center"><A HREF="devguide.html">Developer's Guide</A></TD>
<TD ALIGN="right"></TD>
</TR>
</TABLE>
<HR NOSHADE>
<H1><FONT face="Helvetica,Arial"><A NAME="N1"></A>File Format</font></H1>

<P>Sketch stores drawings in plain ASCII files using a line oriented
format. The main idea is that each line of an sk file looks like a
Python function call. Originally, this was just for convenience, as the
import filter just had to define all those functions in a dictionary,
and read and (r)eval each line.</P>
<P>That turned out to be quite slow, probably because each line is compiled
to bytecode and then executed just once. Sketch now uses a parser
written in C. This is much faster and doesn't have the potential
security problems of eval.</P>
<P>All function arguments are Python literals, ints, floats, strings
(delimited with single- or double-quotes, the usual \ escapes are
allowed, but no triple quoted strings or raw strings), tuples and lists.
Keyword arguments are also allowed. </P>
<P>Boolean values are represented as the ints 0 or 1.</P>
<P>Colors are represented by float triples describing the RGB values, each
in the range 0..1 (e.g. red (1.0, 0.0, 0.0)).</P>
<P>All sk files start with '##Sketch' followed by two numbers, the major
and minor version number of the file format.</P>
<P>Lines starting with # are comments, empty lines are ignored.</P>


<H2><FONT face="Helvetica,Arial"><A NAME="N2"></A>Overall structure</font></H2>

<P>The first function in an sk-file is always 'document()'. This function
takes no parameters.</P>
<P>The next part defines global parameters like the page layout and objects
like styles.</P>
<P>After this follow the layers from bottom to top.</P>

<H2><FONT face="Helvetica,Arial"><A NAME="N3"></A>Globals</font></H2>

<P>Functions for global parameters:</P>
<P>
<DL>
<DT><B>layout(<i>format</i>, <i>orientation</i>)</B><DD>
<P><i>format</i> is either the name of a predefined paper-format or
a tuple (<i>width</i>, <i>height</i>) in pt. See
Sketch/Lib/pagelayout.py for a list of predefined paper-formats.</P>
<P><i>orientation</i> is 0 for portrait or 1 for landscape.</P>


<DT><B>dstyle(<i>name</i>)</B><DD>
<P>Define the style named <i>name</i> (a string). The preceding
functions define the properties of this style. See the section
on <A HREF="#N8">properties</A> for details.</P>

</DL>
</P>

<H2><FONT face="Helvetica,Arial"><A NAME="N4"></A>Layers</font></H2>

<P>There are three kinds of layers, <EM>normal layers</EM>, <EM>grid layers</EM>
and <EM>guide layers</EM>.</P>
<P>Normal layers and guide layers can contain other objects. All objects
defined after a layer function are part of that layer. A layer is
implicitly closed by another layer function or the end of file.</P>
<P>The layer functions:</P>
<P>
<DL>
<DT><B>layer(<i>name</i>, <i>visible</i>, <i>printable</i>,
	<i>locked</i>, <i>outlined</i>, <i>outline_color</i>)</B><DD>
<P>Start a normal layer named <i>name</i> (a string). The booleans
<i>visible</i>,<i>printable</i>, <i>locked</i> and <i>outlined</i>
determine whether the layer is visible, printable, locked or
only shown outlined.</P>
<P><i>outline_color</i> defines the color used for the outlines of
the objects in the layer.</P>

<DT><B>grid(<i>geometry</i>)</B><DD>
<P>Define the grid-layer. The <i>geometry</i> is a tuple of the form
(<i>xorig</i>, <i>yorig</i>, <i>xwidth</i>, <i>ywidth</i>)</P>

<DT><B>guidelayer(<i>name</i>, <i>visible</i>, <i>printable</i>,
	<i>locked</i>, <i>outlined</i>, <i>outline_color</i>)</B><DD>
<P>Start the guide layer. The arguments are the same as for the
normal layer, but the arguments <i>printable</i> and
<i>outlined</i> will be ignored and set to 0 and 1 respectively.</P>

</DL>
</P>


<H2><FONT face="Helvetica,Arial"><A NAME="N5"></A>Objects</font></H2>


<H3><FONT face="Helvetica,Arial"><A NAME="N6"></A>Primitives</font></H3>

<P>Primitives </P>

<H3><FONT face="Helvetica,Arial"><A NAME="N7"></A>Compound Objects</font></H3>




<H2><FONT face="Helvetica,Arial"><A NAME="N8"></A>Properties
</font></H2>








<HR NOSHADE>
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="left"><A HREF="devguide-26.html">Message Passing</A></TD>
<TD ALIGN="center"><A HREF="devguide.html">Developer's Guide</A></TD>
<TD ALIGN="right"></TD>
</TR>
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
</TABLE>
</body>
</html>