1 Introduction

This manual is a short tutorial in the use of the Bifrost Graphics System. The imaging model of the Bifrost Graphics System is based on the Stencil & Paint metaphor known from, e.g., PostScript. That is, drawings are defined by constructing a Stencil, in Bifrost termed a Shape, describing the outline of the drawing, and filling it with a Paint. A composition of a Shape and a Paint is known as a Graphical Object. Graphical Objects can be combined into composite graphical objects, in Bifrost termed Pictures. This is the Bifrost abstraction of what is also known as Graphics Modelling.

A Graphical Object can be drawn on a Canvas. The Canvas is the Bifrost abstraction of the drawing device, and can be, e.g., a window in a window system. When a Graphical Object is drawn on a Canvas, the Canvas 'remembers' the Graphical Object by putting it into a Picture in the Canvas. In a window system this means that the Graphical Object is automatically redrawn when needed, once it has been drawn in the Canvas. The position of a Graphical Object in the list of Graphical Objects in the Canvas Picture determines the 'stacking order' of the Graphical Object in the Canvas, i.e., which objects are below and on top of the Graphical Object. The Canvas also allows interaction to be performed on the Graphical Objects, e.g. moving and reshaping as well as highlighting the Graphical Objects in various ways. Graphical Objects can even be created interactively in Canvasses.

Figure 1: A Spline Segment

[203 bytes 40x76 GIF]

A pure Shape is composed of two different types of Segments: LineSegments and SplineSegments. LineSegments consist of a begin and an end point. SplineSegments are used for constructing curves. They also have a begin and an end point, but in addition more control points may be added. Except for the begin and end point, the spline curve does not go through the control points. Instead the intermediate control points act as small 'magnets', that 'pull' the curve. For instance, the spline to the right is composed of three control points in addition to the begin and end points.

To avoid some of the tedious work of defining shapes, Bifrost includes a number of Predefined Shapes for the most commonly used Graphical Objects. The Graphical Objects using the Predefined Shapes are termed Predefined Graphical Objects. Besides relieving the user from the tedious shape defining work, the Predefined Shapes and Predefined Graphical Objects also allows Bifrost to utilize many of the devices more effectively, since most devices have predefined operations for drawing, e.g., ellipses and text. Some of the Predefined Shapes are Strokeable Shapes. Strokeable Shapes have the property, that when used with a Paint in a Graphical Object, instead of being filled with the Paint, it can be stroked, i.e. outlined, using the Paint and a given stroke width.

The Paint describes the color or raster to be pushed through the shape, when the graphical object is displayed on a Canvas. The paint concept in Bifrost supports any kind of pure colors, as well as more sophisticated features such as hatching, tiling, and sampled raster images. These various features of paint can be described in two main paint concepts: solid color and raster paint. A solid color fills out the entire shape with one particular color. This concept may be specialized by allowing a repeated pattern, a tile, to be applied to the Paint, conceptually by only allowing the paint to reach the canvas where this pattern allows it to. This is a way of obtaining various hatching effects. Raster paint uses a Raster to fill the shape. A Raster is a rectangular grid of pixel values. In order to use a Raster to fill the Shape it must be specified what to do if the Raster is too small to fill out the entire shape. Bifrost supports two approaches in this case: repeating the Raster over and over again, thus tiling the interior of the Shape with it, or by using a solid color called a padding color to fill out any parts of the Shape not covered by the Raster, and thus not filled by the raster image.

For a complete description of the Bifrost Graphics System, including interface descriptions, see the Bifrost Reference Manual [MIA 91-13].

This tutorial presents the development of the graphical interface for a system for designing a subway railroad net for a city. The requirements for this system are as follows:

The presentation will be performed in small steps, so that only a few new major concepts are used in each step. All the programs described in this tutorial can be found on-line in the directory ~beta/bifrost/tutorial. In Appendix A the final program resulting from the tutorial is shown. In Appendix B a screen snapshot of the final application can be found.

The Bifrost Graphics System - Tutorial
© 1991-2002 Mjølner Informatics
[Modified: Tuesday October 24th 2000 at 15:07]