Attributes of Output Primitives
-
Upload
renita-santhmayora -
Category
Education
-
view
273 -
download
3
Transcript of Attributes of Output Primitives
![Page 1: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/1.jpg)
By : Renita Josna Santhmayora,Lecturer in Compuer Science Dept,Sri Venkataramana Swamy College,
Bantwal.
![Page 2: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/2.jpg)
Structure :
Definition
Line Attribute
Curve Attribute
Color and Grayscale Level
Area Filled Attribute
Text and Characters
![Page 3: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/3.jpg)
The way a primitive is to be displayed is referred to as anAttribute Parameter.
Some attribute parameters include color ,size etc.
Different ways to incorporate attribute changes :
Extend the parameter list associated with each primitive
Maintain a system list of current attribute values anduse separate functions to set attributes.
![Page 4: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/4.jpg)
Basic attributes of a straight line segment are its type, its width, and its color.
In some graphics packages, lines can also be displayed using selected pen or brush
![Page 5: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/5.jpg)
The line-type attribute include solid lines, dashed
lines, and dotted lines. We modify a line drawing
algorithm to generate such lines by setting the length
and spacing of displayed solid sections along the line
path.
A dashed line could be displayed by generating an
inter dash spacing that is equal to the length of the
solid sections. Both the length of the dashes and the
inter dash spacing are often specified as user options.
![Page 6: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/6.jpg)
A dotted line can be displayed by generating veryshort dashes with the spacing equal to or greater thanthe dash size.
To set line type attributes in a PHICS applicationprogram, a user invokes the function
setLinetype (It)
where parameter lt is assigned a positive integer valueof 1,2,3, or 4 to generate.
lines that are, respectively, solid, dashed, dotted, ordash-dotted.
![Page 7: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/7.jpg)
![Page 8: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/8.jpg)
Raster line algorithms display line-typeattributes by plotting pixel spans.
For the various dashed, dotted, and dot-dashed pattern..,, the line-drawing procedure.
outputs sections of contiguous pixels along theline path, skipping over a number ofintervening pixels between the solid spans.
![Page 9: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/9.jpg)
Pixel counts for the span lengthand interspan spacing can bespecified in a pixel mask, which isa string containing the digits I and0 to indicate which positions toplot along the line path.
The mask 1111000, for instance,could be used to display a dashedline with a dash length of fourpixels and an interdash spacing ofthree pixels.
![Page 10: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/10.jpg)
Line- width options depends on the capabilities ofthe output device. A heavy line on video monitorcould be displayed as adjacent parallel lines, whilea pen plotter might require pen changes.
We set the line-width attribute with the command:using
setLineWidthScaleFactor(lw);
Line-width parameter lw is assigned a positivenumber to indicate the relative width of the line tobe displayed..
![Page 11: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/11.jpg)
A value of 1 specifies a standard-width line. on penplotter, for instance, a user could set lw to a value of0.5 to plot a line whose width is half that of thestandard line. Values greater than 1 produce linesthicker than the standard.
For raster implementation, a standard-width line isgenerated with single pixels at each sample position.
Other-width link line Attributes are displayed aspositive integer multiples of the standard line byplotting additional pixels along adjacent parallel linepaths.
![Page 12: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/12.jpg)
For lines with slope magnitude less than 1, wecan modify a line-drawing routine to displaythick lines by plotting a vertical span of pixelsat each x position along the line. The numberof pixels in each span is set equal to theinteger magnitude of parameter lw.
![Page 13: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/13.jpg)
For lines with slope magnitude greater than 1,we can plot thick lines with horizontal spans,alternately picking up pixels to the right andleft of the line path.
![Page 14: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/14.jpg)
We can adjust the shape of the line ends to give them a better appearance by adding line caps.
One kind of line cap is the butt cap obtained by adjusting the end positions of the component parallel lines so that the thick line is displayed with square ends that are perpendicular to the line path.
If the specified line has slope m, the square end of the thick line has slope - l / m .
![Page 15: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/15.jpg)
Another line cap is the round cap obtained byadding a filled semicircle to each butt cap.
The circular arcs are centered on the lineendpoints and have a diameter equal to the linethickness.
A third type of line cap is the projecting squarecap.
Here, we simply extend the line and add buttcaps that are positioned one-half of the linewidth beyond the specified endpoints.
![Page 16: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/16.jpg)
![Page 17: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/17.jpg)
We can generate thick polylines that aresmoothly joined at the cost of additionalprocessing at the segment endpoints.
There three possible methods for smoothlyjoining two line segments.
miter join
round join
beveI join.
![Page 18: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/18.jpg)
A miter join is accomplished byextending the outerboundaries of each of the twolines until they meet.
A round join is produced bycapping the connectionbetween the two segmentswith a circular boundary whosediameter is equal to the linewidth.
a belevel join is generated by displaying the line segments with butt caps and filling in the triangular gap where the segments meet.
![Page 19: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/19.jpg)
With some packages, lines can be displayed with pen or brush selections.
Options in this category include shape, size, and pattern.
![Page 20: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/20.jpg)
These shapes can be stored in a pixel mask
that identifies the array of pixel positions that are to be set along the line path.
![Page 21: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/21.jpg)
![Page 22: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/22.jpg)
A polyline routine displays a line in thecurrent color by setting this color value inthe frame buffer at pixel locations along theline path using the setpixel procedure. Thenumber of color choices depends on thenumber of bits available per pixel in theframe buffer.
We set the line color value in PHlCS with thefunction
![Page 23: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/23.jpg)
Nonnegative integer values, corresponding to allowed color choices, are assigned to the line color parameter lc.
A line drawn in the background color is invisible, and a user can erase a previously displayed line by respecifying it in the background color.
An example of the use of the various line attribute commands in an applications program is given by the following sequence of statements:
![Page 24: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/24.jpg)
setLineType (2 ) ;
setLinewidthScaleFactor ( 2 : ;
setPolylinesColourIndex ( 5 ) ;
polyline ( n l , wcpolnts1) :
setPolyline:clourIndex (61 ;
polyline (nl ,wcpoints2) :
![Page 25: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/25.jpg)
Parameters for curve attributes are the same asthose for line segments. We can display curveswith varying colors, widths, dotdash patterns,and available pen or brush options. Methodsfor adapting curve-drawing algorithms toaccommodate attribute selections are similarto those for line drawing.
![Page 26: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/26.jpg)
Raster curves of various widths can bedisplayed using the method of horizontal orvertical pixel spans. Where the magnitude ofthe curve slope is less than1, we plot verticalspans; where the slope magnitude is greaterthan 1, we plot horizontal spans.
![Page 27: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/27.jpg)
![Page 28: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/28.jpg)
![Page 29: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/29.jpg)
General purpose raster-scan systems, usuallyprovide a wide range of colors, while random-scan monitors typically offer only a few colorchoices, if any.
Color options are numerically coded with valuesranging from 0 through the positive integers.
For CRT monitors, these color codes are thenconverted to intensity level settings for theelectron beams. With color plotters, the codescould control ink-jet deposits or pen selections.
![Page 30: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/30.jpg)
In a color raster system, the number of colorchoices available depends on the amount ofstorage provided per pixel in the frame buffer.
color-information can be stored in the frame buffer in two ways: We can store color codes directly in the frame buffer, or we can put the color codes in a separate table and use pixel values as an index into this table.
With the direct storage scheme, whenever a particular color code is specified in an application program, the corresponding binary value is placed in the frame buffer for each-component pixel in the output primitives to be displayed in that color.
![Page 31: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/31.jpg)
A minimum number of colors can be provided in this scheme with 3 bits of storage per pixel, as shown in Table.
![Page 32: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/32.jpg)
Each of the three bit positions is used to controlthe intensity level (either on or off) of thecorresponding electron gun in an RGB monitor.
Adding more bits per pixel to the frame buffer increases the number of color choices. With 6 bits per pixel, 2 bits can be used for each gun.
This allows four different intensity settings foreach of the three color guns, and a total of 64color values are available for each screen pixel.
![Page 33: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/33.jpg)
With a resolution of 1024 by 1024, a full-color(24bit per pixel) RGB system needs 3megabytes of storage for the frame buffer.
Color tables are an alternate means forproviding extended color capabilities to a userwithout requiring large frame buffers.
Use of color tables to reduce frame-bufferstorage requirements.
![Page 34: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/34.jpg)
A possible scheme for storing color values in acolor lookup table (or video lookuptable),where frame-buffer values art- now usedas indices into the color table.
A user can set color-table entries in a PHIGSapplications program with the function
setColourRepresentation (ws, ci, colorptrl)
![Page 35: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/35.jpg)
![Page 36: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/36.jpg)
Parameter ws identifies the workstation outputdevice; parameter ci specifies the color index,
and parameter colorptr points to a hio of RGBcolor values (r,g, b) each specified in the rangefrom 0 to 1.
An example of possible table entries for color monitors is given
![Page 37: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/37.jpg)
There are several advantages in storing color codesin a lookup table.
1."reasonable" number of simultaneous colorswithout requiring large frame buffers.
2. For most applications, 256 or 512 different colorsare sufficient for a single picture.
3. Table entries can be changed at any time.
4. Visualization applications can store values forsome physical quantity, such as energy, in theframe buffer and use a lookup table to try outvarious color encodings without changing the pixelvalues.
![Page 38: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/38.jpg)
With monitors that have no color capability,color functions can be used in an applicationprogram to set the shades of gray, orgrayscale, for displayed primitives.
Numeric values over the range from 0 to 1 can be used to specify grayscale levels, which are then converted to appropriate binary codes for storage in the raster.
![Page 39: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/39.jpg)
When multiple output devices are available at an installation, the same color-table interface may be used for all monitors.
with the display intensity corresponding to a given color index ci calculated as
intensity = 0.5[min(r, g, b) + max(r, g, b)]
![Page 40: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/40.jpg)
Options for filling a defined region include achoice between a solid color or a patternedfill and choices for the particular colors andpatterns. These fill options can be applied topolygon regions or to areas defined withcurved boundaries, depending on thecapabilities of the available package. Inaddition, areas can be painted using variousbrush styles, colors, and transparencyparameters.
![Page 41: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/41.jpg)
Areas are displayed with three basic fillstyles: hollow with a color border, filledwith a solid color, or filled with aspecified pattern or design.
A basic fill style is selected in a PHIGS program with the function
Values for the fill-style parameter fsinclude hollow, solid, and pattern.
![Page 42: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/42.jpg)
Another value for fill style is hatch, which is used tofill an area with selected hatching patterns-parallellines or crossed lines.
Hollow areas are displayed using only the boundaryoutline, with the interior color the same as thebackground color.
![Page 43: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/43.jpg)
A solid fill is displayed in a single color up toand including the borders of the region.
The color for a solid interior or for a hollowarea outline is chosen with
where fill color parameter fc is set to thedesired color code.
A polygon hollow fill is generated with a linedrawing routine as a closed polyline.
![Page 44: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/44.jpg)
Solid fill of a region can be accomplished withthe scan-line procedures.
Other fill options include specifications forthe edge type, edge width, and edge color ofa region.
These attributes are set independently of thefill style or fill color, and they provide for thesame options as the line-attribute parameters
![Page 45: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/45.jpg)
We select fill patterns with
where pattern index parameter pi specifies atable position. For example, the following setof statements would fill the area defined in thefill Area command with the second patterntype stored in the pattern table:
![Page 46: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/46.jpg)
setInteriorStyle ( p a t t e r n ) ; setinteriorStyleIndex ( 2 ) ; fillArea (n, points);
For fill style pattcm, table entries can be created on individual output devices with
SetPatternRepresentatlon (w s , p., nx, ny, cp)
Parameter pi sets the pattern index number for workstation code ws, and cp is a two-dimensional array of color codes with nxcolumns and ny rows.
![Page 47: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/47.jpg)
Color array cp in thisexample specifies apattern that producesalternate red and blackdiagonal pixel lines on aneight-color system.
When a color array cp isto be applied to hll aregion, we need tospecify the size of thearea that is to be coveredby each element of thearray.
![Page 48: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/48.jpg)
We do this by setting the rectangularcoordinate extents of the pattern:
setpatternsize (dx, dy)
where parameters dx and dy give thecoordinate width and height of the arraymapping.
A reference position for starting a pattern fillis assigned with the statementsetPatcernReferencePoint (position)
![Page 49: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/49.jpg)
Parameter posit ion is a pointer to coordinates( x p , yp) that fix the lower left corner of therectangular pattern.
From this starting position, the pattern isreplicated in the x and y directions until thedefined area is covered by nonover-lappingcopies of the pattern array.
The process of filling an area with arectangular pattern is called tiling and
![Page 50: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/50.jpg)
Rectangular fill patterns aresometimes referred to as tilingpatterns.
To illustrate the use of thepattern commands, thefollowing program exampledisplays a black-and-whitepattern in the interior of aparallelogram fill area.
![Page 51: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/51.jpg)
![Page 52: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/52.jpg)
Hatch fill is applied to regions by displayingsets of parallel lines. The fill procedures areimplemented to draw either single hatching orcross hatching.
Spacing and slope for the hatch lines can be setas parameters in the hatch table.
On raster systems, a hatch fill can be specifiedas a pattern array that sets color values forgroups of diagonal pixels.
![Page 53: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/53.jpg)
In many systems, the pattern reference point (xp,yp) is assigned by the system.
For any fill region, the reference point can be chosen as the lower left corner of the bounding rectangle (or bounding box) determined by the coordinate extents of the region.
![Page 54: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/54.jpg)
If the row positions in the pattern array arereferenced in reverse (that is, from bottom to topstarting at I), a pattern value is then assigned topixel position (1, y) in screen or windowcoordinates as
setpixel (x,y , cp(y mod ny + 1, x mod nx + 1) )
Where ny and nx specify the number of rows and number of columns in the pattern array
![Page 55: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/55.jpg)
The pattern and background colorscan be combined using Booleanoperations, or the pattern colorscan simply replace the backgroundcolors.
How the Boolean and replaceoperations for a 2 by 2 fill patternwould set pixel values on a binary(black and white) system against aparticular background pattern.
![Page 56: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/56.jpg)
Modified boundary-fill and flood-fiII proceduresthat are applied to repaint areas so that the fillcolor is combined with the background colors arereferred to as soft-fill .
One use for these fill methods is to soften the fillcolors at object borders that have been blurred toantialias the edges.
Another is to allow repainting of a color area thatwas originally filled with a semitransparent brush,where the current color is then a mixture of thebrush color and the background colors "behind"the area. In either case, we want the new fill colorto have the same variations over the area as thecurrent fill color.
![Page 57: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/57.jpg)
The appearance of displayed characters is controlled by attributes such as font, size, color, and orientation.
Attributes can be set both for entire character strings (text) and for individual characters defined as marker symbols.
![Page 58: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/58.jpg)
First of all, there is the choice of font (or typeface), which is a set of characters with a particular design style such as New York, Courier, Helvetica, London, 'Times Roman, and various special symbol groups.
The characters in a selected font can also be displayed with assorted underlining styles (solid, dotted , double), in boldface, in italics. and in outline or shadow styles.
![Page 59: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/59.jpg)
A particular font and associated style is selectedin a PHlGS program by setting an integer code forthe text font parameter t f in the function.
Color settings for displayed text are stored in thesystem attribute list and used by the proceduresthat load character definitions into the framebuffer.
When a character string is to be displayed, thecurrent color is used to set pixel values in theframe buffer corresponding to the charactershapes and positions
setTextFont(tf)
![Page 60: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/60.jpg)
Control of text color (or intensity) is managedfrom an application program with
where text color parameter tc specifies anallowable color code.
Character size is specified by printers ancompositors in points, where 1 point is0.013837 inch.
Point measurements specify the size of thebody of a character but different fonts with thesame points specifications can have differentcharacter size depending on the design of thetypeface.
setTextColorIndex(tc)
![Page 61: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/61.jpg)
The distance between the bottom line and thetop line of the character body is the same for allcharacters in a particular size and typeface, butthe body width may vary.
Character height is defined as the distance between the baseline and the cap line of characters.
![Page 62: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/62.jpg)
Text size can be adjusted without changing thewidth-to-height ratio of characters with
setChatacterHeight(ch)
Parameter ch is assigned a real value greater than 0to set the coordinate height of capital letters: thedistance between baseline and capline in usercoordinates.
![Page 63: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/63.jpg)
The width only of text can be set with thefunction
setCharacterExpansionFactor(cw)
where the character-width parameter cw isset to a positive real value that scales thebody width of characters.
![Page 64: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/64.jpg)
Spacing between characters is controlled separately with
setCharacterSpacing(cs)
where the character-spacing parameter cs can he asslgned any real value. The value assigned to cs determines the spacing between character bodies along print lines.
Negative values for cs overlap character bodies; positive values insert space to spread out the displayed characters.
![Page 65: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/65.jpg)
The orientation for a displayed character string is set according to the direction of the character up vector:
setCharacterUpVector(upvect)
Parameter upvect in this function is assigned two values that specify the x and y vector components.
Text is then displayed so that the orientation of characters from baseline to capline is in the direction of the up vector.
![Page 66: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/66.jpg)
For example, with upvect = (I, I), the direction of the up vector is 45" and text would be displayed
![Page 67: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/67.jpg)
![Page 68: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/68.jpg)
It is useful in many applications to be able toarrange character strings vertically orhorizontally. An attribute parameter for thisoption is set with the statement
setTextPath(tp)
where the text-path parameter tp can beassigned the value: right, left, up, or down.
A procedure for implementing this option must transform the character patterns
into the specified orientation before
transferring them to the frame buffer..
![Page 69: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/69.jpg)
Another handy attribute for character strings is alignment. This attribute specifies how text is to be positioned with respect to the start coordinates. Alignment attributes are set with
setAlignment(h,v)
where parameters h and v control horizontal and vertical alignment.
Horizontal alignment is set by assigning h a value of left, centre, or right.
Vertical alignment is set by assigning v a value of top, cap, half, base, or bottom
![Page 70: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/70.jpg)
![Page 71: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/71.jpg)
A precision specifici~tionf or text display is given with
setTextPrecision(tpr)
where text precision parameter tpr is assigned oneof the values: string, char, or stroke.
The highest-quality text is displayed when the precision parameter is set to the value stroke
![Page 72: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/72.jpg)
A marker symbol is a single character that can hedisplayed in different colors and in different sizes.
We select a particular character to be the markersymbol with
setMarkerType(mt) where marker type parameter mt is set to an integer
code.
Typical codes for marker type are the integers 1through 5,
specifying, respectively, a dot (.), a vertical cross (+),an asterisk (*), a circle (o), and a diagonal cross (X).
DispIayed marker types are centered on the markercoordinates.
![Page 73: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/73.jpg)
We set the marker size with
setMarkerSizeScaleFactor (ms)
with parameter marker size ms assigned apositive number.
Values greater than 1 produce characterenlargement; values less than 1 reduce themarker size.
![Page 74: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/74.jpg)
Marker color is specified with
setPol y mark erColouIndex (mc )
A selected color code for parameter mc is stored in the current attribute list and used to display subsequently specified marker primitives.
![Page 75: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/75.jpg)
![Page 76: Attributes of Output Primitives](https://reader034.fdocuments.us/reader034/viewer/2022042502/55a60c561a28abde7b8b47b9/html5/thumbnails/76.jpg)