Here are well-structured lecture notes for the topics you mentioned: Line Attributes, Color
and Grayscale Levels, Character Attributes, and Inquiry Functions — ideal for a
computer graphics course module.
Lecture Notes: Computer Graphics - Basic Output
Attributes
1. Line Attributes
Line attributes define the appearance of lines drawn on a graphics output device.
a. Line Type
Solid line: Continuous line.
Dashed line: Broken into small segments.
Dotted line: Consists of dots.
Dash-dot line: Combination of dashes and dots.
Often implemented using a line-style mask.
b. Line Width
Refers to the thickness of the line.
Specified in terms of pixel units.
Wider lines may require intensity blending for smoother edges.
c. Line Color
Defines the RGB (Red-Green-Blue) or grayscale value for the line.
Affects visual clarity and emphasis.
d. Line Caps and Joins
Caps: Define the appearance at the end of lines (butt, round, projecting square).
Joins: Define how lines meet (miter, round, bevel).
2. Color and Grayscale Levels
a. Color Models
RGB (Red, Green, Blue): Common for displays.
CMY(K): Used for printing.
HSV/HSL: Describes colors more intuitively.
b. Color Depth
Defines the number of bits used to represent color.
o 1-bit: 2 colors (black and white).
o 8-bit: 256 colors.
o 24-bit: ~16 million colors (true color).
c. Grayscale
Represents images in shades of gray.
No color, only intensity levels.
Often used in medical imaging and document scanning.
8-bit grayscale = 256 levels (0 = black, 255 = white).
3. Character Attributes
These control how text appears in graphics output.
a. Font Style
Typeface such as Arial, Times New Roman, Courier.
Options include bold, italic, and underlined.
b. Character Size
Height and width of characters can be scaled.
Fixed or variable width fonts.
c. Character Orientation
Angle at which text is displayed.
Useful for vertical labels and rotated text.
d. Character Color
Similar to line color: RGB or grayscale.
Important for visibility and emphasis.
4. Inquiry Functions
These are graphics library functions used to retrieve current graphics settings or state.
a. Purpose
Allow programs to check settings like color, font, screen size, etc.
Support interactive graphics systems and debugging.
b. Examples
getLineType() – retrieves current line type.
getColor() – returns current drawing color.
getCursorPosition() – gets the position of the mouse or pointer.
getViewPort() – retrieves the current viewing window.
c. Use in APIs
Supported in systems like OpenGL, DirectX, and GKS (Graphical Kernel System).
Conclusion
Understanding line attributes, color models, text formatting, and inquiry functions helps
in precise and visually rich graphics rendering. These are foundational concepts for any
graphics API or GUI toolkit and crucial for producing high-quality output in CAD,
visualization, and multimedia systems.
Here are detailed lecture notes on Area-Filling Algorithms in computer graphics, covering
both Boundary-Fill and Flood-Fill methods—suitable for UG-level teaching, assignments,
or presentations.
Lecture Notes: Area-Filling Algorithms in Computer
Graphics
1. Introduction to Area Filling
Area-filling algorithms are used to fill connected regions or interiors of polygons with
color. They are particularly useful in:
Paint programs
Region highlighting
Pattern design
Shading and coloring in raster graphics
Two common approaches:
Boundary-Fill Algorithm
Flood-Fill Algorithm
2. Boundary-Fill Algorithm
2.1 Concept
Fills a region bounded by a specific boundary color. Starting from a seed point inside the
region, the algorithm moves outwards and fills pixels until the boundary color is
encountered.
2.2 Algorithm Logic
1. Input: Seed point (x,y)(x, y), fill color, and boundary color.
2. Check the color of pixel at (x,y)(x, y).
3. If it’s neither the boundary color nor the fill color, fill the pixel with the fill color.
4. Recursively apply the same steps to the neighboring pixels.
2.3 Types
4-connected: Considers 4 neighbors (left, right, top, bottom).
8-connected: Considers 8 neighbors (includes diagonals).
2.4 Pseudocode (4-connected)
BoundaryFill4(x, y, fill_color, boundary_color)
{
if (getPixel(x, y) ≠ boundary_color AND getPixel(x, y) ≠ fill_color)
{
setPixel(x, y, fill_color);
BoundaryFill4(x+1, y, fill_color, boundary_color);
BoundaryFill4(x-1, y, fill_color, boundary_color);
BoundaryFill4(x, y+1, fill_color, boundary_color);
BoundaryFill4(x, y-1, fill_color, boundary_color);
}
}
2.5 Limitations
May cause stack overflow for large areas due to recursion.
Slower for complex or unbounded regions.
3. Flood-Fill Algorithm
3.1 Concept
Fills an area with a new color until a boundary of a different color is reached. Unlike
boundary-fill, it doesn't require a predefined boundary color but rather replaces all pixels of a
target color.
3.2 Use Cases
Used in paint bucket tools (e.g., MS Paint)
Filling enclosed or open shapes of the same color
3.3 Algorithm Logic
1. Input: Seed point (x,y)(x, y), target color (to be replaced), and new color.
2. If the pixel at (x,y)(x, y) is the target color:
o Replace it with the new color.
o Recursively apply the function to neighboring pixels.
3.4 Types
4-connected flood fill
8-connected flood fill
3.5 Pseudocode (4-connected)
FloodFill4(x, y, target_color, new_color)
{
if (getPixel(x, y) == target_color)
{
setPixel(x, y, new_color);
FloodFill4(x+1, y, target_color, new_color);
FloodFill4(x-1, y, target_color, new_color);
FloodFill4(x, y+1, target_color, new_color);
FloodFill4(x, y-1, target_color, new_color);
}
}
3.6 Advantages
No boundary color required.
Suitable for uniformly colored regions.
4. Comparison: Boundary-Fill vs. Flood-Fill
Feature Boundary-Fill Flood-Fill
Requires boundary? Yes No
Input color? Fill color + boundary color Fill color + target color
Used when Known boundary exists Uniform region to be filled
Fill direction Outward from seed point Outward until color changes
Risk of overflow Higher for large areas Higher if not optimized
5. Optimizations
Use stack or queue-based implementations (non-recursive) to avoid stack overflow.
Scan-line fill algorithms are used for polygon filling and are more efficient for
complex shapes.
6. Applications
Paint programs
Game development (map and terrain coloring)
Image editing
User interface design
7. Summary
Area-filling algorithms are essential for creating interactive and visually rich graphics
applications. While boundary-fill is useful for well-bounded shapes, flood-fill is ideal for
filling uniform regions. Understanding both is fundamental in raster graphics processing.
void BresenhamLine(int x1, int y1, int x2, int y2)
{
int x, y, p, const1, const2;
p = 2 * (y2 - y1) - (x2 - x1);
const1 = 2 * (y2 - y1);
const2 = 2 * ((y2 - y1) - (x2 - x1));
x = x1; y = y1;
SetPixel(x, y);
while (x < x2)
{
x++;
if (p < 0)
p = p + const1;
else
{
y++;
p = p + const2;
}
SetPixel(x, y);
}
}