[an error occurred while processing this directive]
DoNaLD is a definitive notation for 2D line drawings. It was originally specified in Warwick Computer Science Research Report 086 (the report is here in gzipped Postscript format or see the official CS-RR-086 page with links to the bibliography entry in various formats and the report via FTP). A subset of the specification was first implemented by Edward Yung and subsequently modified by many other authors. The notation as it stands remains some distance away from what is specified in the research report. One of the objectives of this document is to state what is supported in the current version of DoNaLD.
x
x
in the immediate context~/x
x
in the context one level up/x
x
in the root (topmost) contextx!
pi
is a predefined constant 3.14159. It cannot be redefined
as a variable associated with any context.Type | Example |
---|---|
int | 34 |
real | 10.0 |
char | "abc" |
boolean | true, false |
point | {50, 100}, {modulo @ angle} |
line | [{10,10}, {80, 90}] |
circle | circle(centre, radius), circle({500,500}, 400) |
ellipse | ellipse(centre, major, minor) |
rectangle | rectangle({100, 100}, point1) |
image | I!ImageFile("gif", "hill.gif") |
label | label L1, L2
|
openshape | openshape cross |
within cross {
| |
shape | shape S
|
graph | func sqr { return $1 * $1; }
|
+
-
*
div
(division)mod
sqrt
(square root)log
exp
trunc
(convert real to integer)float
(convert an integer to real)rand
(random number generator)int rand(int)
or real rand(real)
10
, rand(10)
returns
a random number ranged from 0
to 9
inclusive;
1.0
, rand(1.0)
returns a random
number ranged from 0.0
to 1.0
inclusive.
sin
cos
tan
asin
acos
atan
&&
(and)||
(or)!
(not)<
<=
==
(equal)>
>=
point midpoint(line)
point intersect(line, line)
line perpend(point, line)
real dist(point, point)
bool intersects(line, line)
bool separates(line, point, point)
bool includes(circle, point)
bool incident(line, point)
bool incident(circle, point)
bool pt_betwn_pts(point, point, point)
bool colinear(point, point, point)
bool distlarger(point, point, value)
bool distlarger(line, point, value)
bool distsmaller(point, point, value)
bool distsmaller(line, point, value)
trans(shape, x, y)
scale(shape, ratio)
rot(shape, point, angle)
//
itos(int)
rtos(real, format-string)
%donald real xscale, yscale xscale, yscale = 0.8, 0.8 image zoom, source source = I!ImageScale(I!ImageFile("gif", "logo.gif"), xscale, yscale) zoom = I!ImageScale(I!ImageCut(source, 20, 0, 200 * xscale, 200 * yscale), xscale, yscale) label imgzoom, imgsrc imgzoom = label(zoom, {500, 200}) imgsrc = label(source, {500, 700})The images are centred at the specified position (same for string labels). I!functionName denotes a function returning an image. This function is translated to an Eden function named as functionName. The arguments are not fully type-checked, so may sometimes cause a problem. Since this kind of function does not need to be declared beforehand, DoNaLD can easily be extended to make use of image filters chosen by the user. (See examples in $PUBLIC/lib/tkeden/scout.init.e for examples of image filters.)
circle(center, radius)
ellipse(center, extreme_point1, extreme_point2)
rectangle(corner1, corner2)
label(string, position)
if
boolean_expression then
expr else
expr.1, .2
line l l = [{0,0}, {100,100}] point p p = l.2 # i.e. {100,100} real x x = p.1 # i.e. 100
point p, q p = {100, 200} q = p.x # i.e. {100, 0}
[]
node1_1
,
node1_2
, etc. and
the segments are named as segment1_0
, segment1_1
,
etc., where the first
number represents which visualisation of the entity and the second number is
concerned with which node or segment. You can redefine the individual
nodes and segments without any complaint from the system (BUG?).You may like to give a line or a shape a different look, by specifying a wider linewidth or a different colour. Every DoNaLD variable that can be displayed has an attribute variable (an EDEN variable) for you to modify its presentation. Integers, reals, booleans and chars have no immediate graphical representation, hence no attribute variables accompany them. Interestingly enough, openshape does not have attributes either. This is because openshape is not a shape but a collection of shapes. Its subshapes may each have an attribute but the openshape itself has not.
The attribute variables are EDEN variables, and are named after the
translated name of the DoNaLD variables in EDEN. The attribute variable
name for the DoNaLD variable Obj/line1
would be A_Obj_line1
. Attributes
are of the form:
"attr1=value1,attr2=value2..."
The set of attributes available may vary from one implementation to another. For tkeden, legal attributes are:
outlinecolor
color
outlinecolor
-
color
specified both outline and fill colours.linewidth
line
, arc
, circle
, shape
linestyle
line
dotted
, dashed
, solid
arrow
line
first
, last
, both
, none
followed by 2 spaces)locus
true
, false
fill
solid
, hollow
Notes:
Viewports are workspaces where the graphical objects are placed. For the stand alone usage of DoNaLD, viewport should not be defined. Since Scout, a definitive notation for describing screen layout, has the ability to show different pictures in different (Scout) windows, when DoNaLD is used in conjunction with Scout, viewport is a useful way of separating objects into different pictures. In DoNaLD, the line:
viewport VIEW1
means that from that line onwards the graphical objects to be declared (not defined) will be associated with the viewport VIEW1. All viewports share the same conceptual space, and variables in one viewport can freely make reference to variables in other viewports. Viewports need not be displayed. Hence it is useful to dump intermediate or conceptual objects into a viewport which will not be displayed.
For backward compatibility, declaring DoNaLD variables without first
declaring a viewport will create a default viewport displaying on a
separate screen. This default viewport is named as DoNaLD
.
DoNaLD uses #
as the comment symbol. Comment starts from #
to the
end of the line.
There are two ways of escaping from DoNaLD to EDEN.
?
will be passed to EDEN directly. Like
the DoNaLD comments, this is only for one line escape. The one line escape
is particularly useful for defining attributes. For
example:
line cable ?A_cable is "linestyle=dotted"; /* this defines the attribute of cable */ cable = ... # this is a DoNaLD definition
Not only is this escape method convenient in this case, it also gives the attribute definition a sense of close association with the DoNaLD variable.
line cable %eden A_cable is "linestyle=dotted"; /* this defines the attribute of cable */ %donald cable = ... # this is a DoNaLD definition