Unit III Transformations:
Attributes of Output Primitives, Line Attributes - Line Type, Line Width, Pen and Brush
Options, Line Color, Color and Grayscale levels- Color Tables, Grayscale, Area - Fil Attributes
- Fil Styles, Pattern Fil, Soft Fil, Character Attributes, Text Attributes Geometric
Transformations: Matrices, 2D transformations, Homogeneous representations - other
transformation - Two-Dimensional Viewing, The viewing pipeline, Viewing Coordinate
Reference Frame, Window-to-viewport Coordinate Transformation, Two-Dimensional
Viewing Functions, Clipping Operations - Point Clipping, Line Clipping, Cohen-Sutherland
Line Clipping, Polygon Clipping, Sutherland-Hodgeman Polygon Clipping.
= = = = = == = = = = = == = = = = = = = = = = == = = = = = = = = = = = = = == ======
Attributes of Output Primitives
Any parameter that affects the way a primitive is to be displayed is referred to as an 36 attribute
parameter. Attribute parameters are color, size etc. It is used to determine the fundamental
characteristics of a primitive.
TYPES OF ATTRIBUTES
1. Line Attributes
2. Curve Attributes
3. Color and Grayscale Levels
4. Area Fill Attributes
5. Character Attributes
6. Bundled Attributes
Line Attributes
Basic attributes of a straight line segment are
1. Line Type
2. Line Width
3. Pen and Brush Options
4. Line Color
Line type
Line type attribute includes solid lines, dashed lines and dotted lines.
1
• To set line type attributes in a PHIGS application program, a user invokes the function
setLinetype (lt)
where parameter lt is assigned a positive integer value of 1, 2, 3 or 4 to generate lines that are
solid, dashed, dash dotted respectively. Other values for line type parameter it could be used
to display variations in dot-dash patterns.
Attribute LineColor
LineColor is a Color-valued attribute that determines the color of the line. Its default value is
Color.Black.
Attribute Line width
• Implementation of line width option depends on the capabilities of the output device to
set the line width attributes.
To set the line-width attributes using the following command
setLinewidthScaleFactor (lw)
• Line width parameter lw is assigned a positive number to indicate the relative width
of line to be displayed.
• A value of 1 specifies a standard width line.
• To set lw to a value of 0.5 to plot a line whose width is half that of the standard line.
• Values greater than 1 produce lines thicker than the standard.
2
Line cap:
• Line caps can be used to adjust the shape of the line ends to give a better appearance.
• There are three types of line caps.
1. Butt cap which has a square end
2. Round cap which has a semi circle end
3. Projecting square cap which has one half of the line width beyond the
specified end points.
Butt cap
It 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.
Round cap
• It obtained by adding a filled semicircle to each butt cap.
• The circular arcs are centered on the line endpoints and have a diameter equal to the
line thickness.
Projecting square cap
It extends the line and adds butt caps that are positioned one-half of the line width beyond the
specified endpoints.
There are three possible methods for smoothly joining two line segments,
1. Miter Join
3
2. Round Join
3. Bevel Join
OR
The methods used for smoothly joining two line segments:
Mitter join- by extending the outer boundaries of each of the two lines until they meet.
Round join – by capping the connection between the two segments with a circular boundary
whose diameter is equal to the line width.
Bevel join – by displaying the line segments with butt caps and filling in the triangular gap
where the segment meet.
Pen and Brush Options
• In some graphics packages, lines can also be displayed using selected pen or brush
options.
• Options in this category include shape, size, and pattern. Some possible pen or brush
shapes are given in following figure
4
Line color:
• The line color is the attributes of the line. The line color specifies colors for lines.
• The set line attribute in a application program:
setPolylinecolorIndex(lc)
Non negative integer values, corresponding to allowed color choices, are assigned to the line
color parameter lc.
Example:
Various line attribute commands in an applications program is given by the following sequence
of statements
setLinetype(2);
setLinewidthScaleFactor(2);
setPolylineColourIndex (5);
polyline(n1, wc points1);
setPolylineColorIindex(6);
poly line (n2, wc points2);
= = = = = == = = = = = == = = = = = = = = = = == = = = = = = = = = = = = = == ======
COLOR AND GRAYSCALE LEVELS
• An overview of how color and intensity levels are managed in raster-scan systems,
particularly focusing on the storage and representation of color information in the frame
buffer.
• Colors are represented by color codes which are positive integers.
• Color information is stored in frame buffer or in a separate table and use pixel values
as index to the color table.
• In raster scan system→ wide range of colors
5
• In random scam monitors→ few color choices.
• Also, color-information can be stored in the frame buffer in two ways:
1. We can store color codes directly in the frame buffer.
2. We can put color codes in a separate table and use pixel values as an index into
this table.
• A minimum number of colors can be provided in this scheme with 3 bots of storage per
pixel, as shown in Table
Color and Grayscale Levels
Color Tables
• Each pixel references any one of 256 table positions
• Each entry in the table uses 24 bits to specify RGB colors.
• There are 17 million colors are available.
• User can also set the color table entries in PHIGS application program with the
function
SetColourRepresentation(ws, ci,colorptr)
Where,
Ws is a workstation, ci is the color index and colorptr points RGB colors.
6
Grayscale
• With monitors that have no color capability, color functions can be used in an
application program to set the shades of gray, or grayscale for the displayed primitives.
• Numeric values from 0 to 1, can be used to specify grayscale levels, which are
converted to appropriate binary codes for storage in the raster.
• The table given below shows the specification for intensity codes for a four level
grayscale system.
Intensity is calculated based on the colour index as follows:
Intensity = 0.5 [min (r,g,b) + max (r,g,b)]
= = == = = = = = = = = = = = === = = = = = = = = = = == = = == = = = == = == == = =
Area Fill Attributes
• Options for filling a defined region in computer graphics, which include choices
between solid colors, pattern fills, and particular colors and patterns.
Fill Options
Solid Color:
• This option involves filling the defined region with a single, uniform color.
• The color can be specified using various color models such as grayscale (0-255), RGB
(red/green/blue each in the 0-255 range or hexadecimal #rrggbb), HSV (Hue-
Saturation-Value in the 0-360, 0-1, 0-1 range), CMYK (Cyan/Magenta/Yellow/Black
each ranging from 0-100%), or by using a valid color name.
7
Note:
• Hue represents the type of color, such as red, green, blue, etc.
• It's essentially the dominant wavelength of light that determines the color's perceived
tone.
• In the HSV model, hue is represented as an angle around a color wheel, typically
ranging from 0° to 360°.
• Example: A hue of 0° corresponds to red, 120° to green, and 240° to blue on the color
wheel. Intermediate angles represent intermediate colors such as yellow, cyan, and
magenta.
Saturation:
• Saturation refers to the intensity or purity of the color.
• A saturation value of 0 corresponds to a shade of gray (completely desaturated),
while a saturation value of 1 (100%) represents the purest, most intense version
of the color.
Example: A saturation of 0% would be grayscale, while a saturation of 100% would
be the most vibrant version of the color.
Value (Brightness):
• Value represents the brightness or lightness of the color.
• A value of 0 corresponds to black (no light), while a value of 1 (100%)
corresponds to the maximum brightness for the given hue and saturation.
Example: A value of 0% would be completely black, while a value of 100% would be
the brightest and most intense version of the color.
Example 1:
As mentioned, a pure red color can be represented in HSV notation as (0°, 100%,
100%). This means:
Hue: 0°, indicating pure red.
Saturation: 100%, indicating full intensity without any white or gray mixed in.
Value: 100%, indicating maximum brightness, making the color appear as bright as
possible.
Example 2:
To represent the color magenta in the HSV color model, you would specify the following
values:
8
Hue: Magenta is typically represented with a hue angle of around 300° in the HSV color model.
It's positioned between red (0°) and blue (240°) on the color wheel, so magenta is often around
300°.
Saturation: Since magenta is a pure color, the saturation value would be at its maximum,
which is 100%.
Value: Similarly, since magenta is a bright color, the value (brightness) would also be at its
maximum, which is 100%.
So, in HSV notation, the color magenta can be represented as (300°, 100%, 100%).
This indicates that the color is fully saturated, bright, and falls on the magenta segment of the
color wheel at an angle of 300°.
CMYK (Cyan/Magenta/Yellow/Black each ranging from 0-100%):
• CMYK color model is primarily used in printing. It represents colors using percentages
of cyan, magenta, yellow, and black (key) inks.
• Example: The color black would be represented as (0%, 0%, 0%, 100%) in CMYK
notation, indicating the absence of cyan, magenta, and yellow, and full intensity of
black ink.
----END NOTE----
There are three fill styles:
1. Hollow with color border
2. Filled with solid color
3. Filled with specific pattern or design
Hollow with Color Border
The basic fill style is selected in the PHIGS (Programmer's Hierarchical Interactive Graphics
System) application program as
setInteriorStyle (fs)
• where fs is normally applied to the polygon areas it can also implemented to fill region
with curved boundaries.
• The interior of the shape (e.g., a polygon) remains unfilled or hollow.
• This fill style could be useful for drawing outlined shapes with colored borders.
Filled with solid color
9
It is used to display the single color up to including the borders of the region.
Where fill color parameter fc is to set the desired color code.
Filled with specific pattern or design
Select fill pattern with
Where the pattern index parameter pi specified to the table position. The following are the set
of statements to fill the area defined in the fill area command.
setinteriorstyle(pattern):
• This command sets the interior style of a fill area using a specific pattern.
• The pattern parameter likely refers to some predefined pattern that you want to use
for filling the area.
• After executing this command, subsequent fill operations will use this pattern to fill the
area.
setinteriorstyleindex(2):
• This command sets the interior style of a fill area using a pattern index.
• Here, 2 is the index that likely corresponds to a specific pattern stored in a table or data
structure.
10
• This is similar to the first command, but instead of directly providing the pattern, you're
specifying an index to retrieve the pattern from a predefined collection of patterns.
fillarea(n, points)
• n represents the number of points defining the boundary.
• points is a list containing tuples of (x, y) coordinates representing the boundary points.
• fillarea is the command used to fill the area enclosed by the provided points.
The process of filling a rectangular pattern called tiling. The rectangular fill pattern is
sometimes called as tilling pattern.
Soft Fill
• A soft fill algorithm where the fill color is combined with the background color based
on a transparency factor.
• Using linear soft fill algorithm repaints the area that was originally painted by merging
the forground color F with the single background color B, where 𝐹! = 𝐵.
• Assuming that we know the values of F and B we have to determine how these colors
originally combined with current color contents of the frame buffer. i.e The soft fill
algorithm repaints an area by blending the foreground color (F) with the background
color (B) based on a transparency factor (t).
• The transparency factor determines how much of the foreground color and how much
of the background color contributes to the final color of each pixel within the area.
• The current RGB color P of each pixel within a area is defined as:
𝑃 = 𝑡𝐹 + (1 − 𝑡)𝐵
Where t is the transparency factor between 0 and 1 for each pixel. The value of t is less
than 0.5 the background color contributes more to interior color.
Note:
The transparency factor (t) ranges between 0 and 1 for each pixel.
When t is closer to 0, the background color (B) contributes more to the interior color.
When t is closer to 1, the foreground color (F) contributes more to the interior color.
END Note----
Example:
Let's say we have a foreground color (F) of (255, 0, 0) (pure red), a background color (B)
of (0, 0, 255) (pure blue), and a transparency factor (t) of 0.3.
For each pixel:
P = 0.3 * (255, 0, 0) + 0.7 * (0, 0, 255)
11
P = (76.5, 0, 76.5) + (0, 0, 178.5)
P ≈ (76.5, 0, 255)
This results in a final color that is a blend of red and blue, with more weight given to the blue
color due to the lower transparency factor.
= = == = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Character Attributes
The appearance of displayed character 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.
Font: The typeface or design of the characters, such as Arial, Times New Roman, or Courier.
Fonts can vary in style, weight, and size.
Size: The height or size of the characters, typically measured in points (pt), pixels (px), or other
units. Larger sizes result in bigger characters.
Color: The color of the characters, usually specified using RGB values, hexadecimal codes, or
color names. Color can be used to convey meaning, emphasize text, or create visual hierarchy.
Orientation: The angle at which the characters are displayed, typically measured in degrees.
This attribute allows text to be rotated or skewed for artistic or functional purposes.
= = == = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Text Attributes
• The choice of font or type face is set of characters with a particular design style as
courier, Helvetica, times roman, and various symbol groups.
• The characters in a selected font also are displayed with styles (solid, dotted, double)
in bold face in italics and in outline or shadow styles.
• A particular font and associated style is selected in a PHIGS program by setting an
integer code for the text font parameter tf in the function
setTextFont (tf)
• Control of text color (or intensity) is managed from an application program with
setTextColourIndex (tc)
Where text color parameter tc specifies an allowable color code.
• We can adjust text size by scaling the overall dimensions of characters or by scaling
only the character width.
• Character size is specified by points, where 1 point is 0.013837 inch. Point
measurements specify the size of the body of a character.
12
• The distance between the bottom-line and the top line of the character body is same for
all characters in particular size and typeface, but width of the body may vary.
• Proportionally spaced fonts assign a smaller body width to narrow characters such as
i, j, l and f compared to broad characters such as W or M.
• Character height is defined as the distance between the base line and cap line of
characters.
• Text size can be adjusted without changing the width to height ratio of characters with
setCharacterHeight (ch)
Parameter ch is assigned a real value greater than 0 to set the coordinate height of capital
letters.
• The function setCharacterExpansionFactor(cw) allows you to adjust the width of
characters by scaling their body width. The parameter cw represents a positive real
value that determines the scaling factor for character widths.
• Scaling Factor: cw
The value of cw acts as a scaling factor for character widths. For example:
If cw = 1, character widths remain unchanged.
If cw > 1, character widths are scaled up, making characters wider.
If cw < 1, character widths are scaled down, making characters narrower.
13