![]() |
Graphics primitives | ![]() |
This section briefly describes the primitives for images, graphics and animations. Most of them are typeset by the routines in
Typeset/Concat/concat_graphics.cpp
,
Typeset/Concat/concat_animate.cpp
and
Typeset/Concat/concat_gui.cpp
; their arities are declared in
Data/Drd/drd_std.cpp
. The rendering of graphical objects is controlled by many environment variables, such as color, fill-color, line-width, dash-style, arrow-begin, arrow-end, point-style, text-at-halign, text-at-valign, gr-frame, gr-geometry and gr-grid.
Include the image with the given url, which is resolved relative to the current document (the suffixes .eps and .pdf are tried when the url has none). Instead of a file name, the first argument may also be an embedded image of the form <tuple|<raw-data|data>|suffix>.
The width and height are lengths, in which the units w and h stand for the natural width and height of the image. When both are empty, the natural size is used; when only one of them is specified, the other one is computed so as to preserve the aspect ratio. The box is finally moved by x-offset and y-offset, in which w and h now stand for the width and height of the scaled image.
A graphics is a picture made of the graphical objects gr-content-1 until gr-content-n, which are drawn on top of each other. The coordinates of the graphical objects are expressed in the coordinate system given by the gr-frame environment variable, and the size of the picture is determined by gr-geometry (or computed automatically when gr-auto-crop is set).
Typeset content-1 until content-n as atomic boxes, and draw them on top of each other, with the same origin.
Groups several graphical objects, so that they can be manipulated as a whole in the graphics editor.
Apply a linear transformation to gr-content. The transformation is evaluated and should be one of <tuple|rotation|angle>, <tuple|rotation|center|angle> (angles in degrees), <tuple|scaling|x-factor|y-factor>, <tuple|slanting|factor> or <tuple|linear|a|b|c|d>.
Apply a graphical effect to the boxes of content-1 until content-n. The effect is evaluated and built from the effect primitives eff-move, eff-magnify, eff-bubble, eff-crop, eff-turbulence, eff-fractal-noise, eff-hatch, eff-dots, eff-gaussian, eff-oval, eff-rectangular, eff-motion, eff-blur, eff-outline, eff-thicken, eff-erode, eff-degrade, eff-distort, eff-gnaw, eff-superpose, eff-add, eff-sub, eff-mul, eff-min, eff-max, eff-mix, eff-normalize, eff-monochrome, eff-color-matrix, eff-gradient, eff-make-transparent, eff-make-opaque, eff-recolor and eff-skin. In an effect, the numbers 0, 1, etc. refer to the boxes of content-1, content-2, etc. (an empty string stands for the first box). The menus for inserting effects are only shown when the bitmap effects preference is enabled.
Place textual, mathematical or multi-paragraph content at the point pos of a graphics. The alignment of the content with respect to pos is determined by the environment variables text-at-halign (left, center or right) and text-at-valign (bottom, base, axis, center or top).
A point with coordinates x and y (evaluated), in the coordinate system of the enclosing graphics. A point also serves as a graphical object, rendered according to point-style, point-size and point-border.
Polygonal line through the points point-1 until point-n. The cline variant is closed, so that it yields a polygon, which is filled with fill-color.
The arc primitive draws the arc of a circle through the three given points, and carc the entire circle through these points. When the points are aligned, a polygonal line is drawn instead.
Open or closed spline curve through the points point-1 until point-n. The variant spline* is reserved, but not yet implemented.
<bezier|point-1|\(\cdots\)|point-n>
<cbezier|point-1|\(\cdots\)|point-n>
<smooth|point-1|\(\cdots\)|point-n>
Open and closed poly-Bezier curves. For bezier and cbezier the points alternate between points on the curve and control points; for smooth and csmooth the control points are computed automatically so as to yield a smooth curve through the given points.
These primitives represent handwritten strokes between the points start and end; the ink argument contains the recorded points of the stroke.
Reserved primitive, not yet implemented.
Typeset content and return information about its box, as specified by the literal string query. Each letter of the query adds an entry to the returned tuple: l, b, r, t, w and h for the left, bottom, right and top coordinates, the width and the height of the logical box, and the corresponding upper case letters for the ink box. If the query ends with a dot, such as w., a single length (in tmpt) is returned instead of a tuple.
Convert a point from the coordinate system of the current graphics frame into internal coordinates, or conversely.
The primitives is-equal, is-intersection, on-curve, on-text-border and on-grid are reserved for expressing geometric constraints, and the primitives transform-3d, object-3d, triangle-3d, light-3d, light-diffuse and light-specular for experimental three dimensional graphics.
This primitive can be used as a color (for instance as the value of bg-color or fill-color): the region is filled with copies of the image url, scaled to the given size. The optional alternative is a plain color which is used when patterns are not supported. The gradient primitive is reserved for gradients, but not yet implemented.
Typeset body inside an ornamental frame, with an optional title. The shape and colors of the frame are determined by the ornament-shape, ornament-title-style, ornament-border, ornament-color and related environment variables. This primitive is used by the style packages for framed and highlighted environments.
Typeset body inside a scrollable region with the given limits x1, y1, x2, y2, and scroll positions x-scroll and y-scroll. The appearance is controlled by canvas-type and the other canvas-* environment variables.
Typeset body on top of an artistic background (for instance made of images), described by the tuples properties-1 until properties-n of variable-value pairs. The properties lpadding, rpadding, bpadding and tpadding of the tuple starting with text determine the padding around the body.
Animations are typeset as boxes which change over time; they are driven by players (
Typeset/Concat/concat_animate.cpp
). Durations are specified as lengths with the units ms, s, msec, sec, min and hr.
Display content during the given duration.
Play the animations anim-1 until anim-n one after another.
Play the animation anim repeatedly.
Play anim with a modified time flow. The type may be reverse, fade-in, fade-out, faded, bump, reverse-type, or <tuple|fixed|t> for a frozen animation.
The anim-translate primitive moves content during duration from the position start to the position end; positions are tuples <tuple|x|y>, where numbers are fractions of the size of the box and lengths are absolute offsets. The anim-progressive primitive progressively reveals content, by interpolating between the clipping rectangles start and end, which are tuples with four coordinates.
Evaluate content at regular time steps step during duration, and produce the corresponding anim-compose of anim-constant frames. During the evaluation, the primitives <anim-time> and <anim-portion> return the current time and the elapsed portion (between 0 and 1) of the animation, and each morph in content is replaced by an interpolated value. The last argument is currently unused, and anim-dynamic currently behaves like anim-static.
Inside a computed animation, a morph evaluates to an interpolation between the content-i whose times t-i (numbers between 0 and 1) surround the current animation portion. Numbers, lengths, colors, with attributes, tables and graphics are interpolated recursively (
Typeset/Env/env_animate.cpp
); other content is switched abruptly. A content-i which is not a tuple is taken to be the content at time 0 (first occurrence) or 1 (second occurrence).
Include a video or sound file. For videos, repeat specifies whether the video should be played repeatedly (any value other than false).