A solid color is specified relative to some color space. In Bifrost, three color spaces are supported, namely RGB, CMY and HSV. These are the color spaces that seems to have the most widespread use in computer graphics (cf., e.g. [Bifrost 92], [Foley 90]). The HSV color space is probably the most intuitive of these, since defining a color in it resembles the way an artist do it. In order to ease the job of the programmer, colors can also be specified using a simple naming model. Of course, it will be possible to extend the color support in Bifrost for other color spaces too, if needed.
The number of colors available at the same time depends on the device used. If no more colors are available, a default color is used.
The following three operations are used to manipulate the attributes of a SolidColor. All three operations can be used to both set and get the values of the solid color in the respective color models:
The following example illustrates how a column with the complete color spectrum, can be drawn using the HSV color model. This is done by stacking thin lines upon each other, having hues 1, 2, ..., MaxHue respectively (that is MaxHue number of lines in all). Full saturation and values are used.
A Color Scale:
Notice that it would not suffice to instantiate just one line object and change the color of this one object, because in Bifrost each part of an image must correspond to some graphical object that is inserted into the canvas picture (by the canvas operation Draw). Changing the color of one line object would result in one line with changing colors being shown. Also notice that an instance of the predefined graphical object class Line is used. Predefined graphical objects are defined in Predefined Shapes and Graphical Objects.
By combining the different color spaces interesting effects can be achieved. The following example is an elaboration of the previous one. The example draws the complementary color spectrum in a column adjacent to the column described in the previous example.
(for h:DefaultMaxHue repeat &Line -> aLine; aLine.init; 1 -> aLine.width; ((0,h), (100,h)) -> aLine.Coordinates; &SolidColor -> aSolidColor -> aLine.SetPaint; (h, MaxSat, MaxVal) -> aSolidColor.HSVvalues; aLine -> aCanvas.draw; (* draw the line with complementary color *) &Line -> aLine; aLine.init; 1 -> aLine.width; ((110,h), (210,h)) -> aLine.Coordinates; &SolidColor -> anotherSolidColor -> aLine.SetPaint; aSolidColor.RGBvalues -> anotherSolidColor.CMYvalues; aLine -> aCanvas.draw; for);
The result of the last program is illustrated in the Figure below.
An even more intuitive 'color space' than RGB, HSV and CMY is the one used in everyday life: defining the colors simply by naming them. Bifrost support the possibility of specifying a solid color by name by means of a large number of patterns exiting RGB values corresponding to different color names. These patterns are located in the file
The following example illustrates how to draw a circle with center in (10,10) and radius 25 and filled with solid pink color, using the simple naming color model.
&Ellipse -> anEllipse; anEllipse.init; ((10,10),25,25) -> anEllipse.geometry; &SolidColor -> aSolidColor -> anEllipse.SetPaint; pink -> aSolidColor.Name; anEllipse -> aCanvas.draw;
A tiled solid color is a solid color extended with a BitMap. The BitMap will be tiled in the shape before the SolidColor is applied, and only where the pixel values of the BitMap is true the SolidColor will be visible. This is the normal tiling approach. As mentioned in Raster the hotspots of the BitMap and of the shape being filled, determine the position of the BitMap within the shape.
The Shape filled with a TiledSolidColor using the BitMap as tile:
|The Bifrost Graphics System - Reference Manual||© 1991-2004 Mjølner Informatics||
[Modified: Tuesday October 24th 2000 at 15:02]