190 likes | 268 Views
CGMB314. Attributes of Graphics Primitives. Color and Gray Scale. Color – A basic attribute for all primitives Various color option depend on capabilities and design objectives of a particular system. RGB Color Components. In color raster system (monitor)
E N D
CGMB314 Attributes of Graphics Primitives
Color and Gray Scale • Color – A basic attribute for all primitives • Various color option depend on capabilities and design objectives of a particular system
RGB Color Components • In color raster system (monitor) • Number of color choices available depends on the amount of storage provided per pixel in the frame buffer • Two method of storing color information in the frame buffer • Directly – storing RGB color code directly in the frame buffer • Indirectly – put the color codes into a separate table and use the pixel locations to store index values referencing the color-table entries
RGB Color Components • Disadvantage • As more color options are provided, the storage required for the frame buffer also increases • 1024 x 1024 full color (24-bit per pixel) RGB system needs 3MB of storage for the frame buffer • Solution • Storing the color values in a color lookup table (color map)
Color Tables • Values stored in the frame buffer are now used as indices into the color table • Advantages • Reduce the frame-buffer storage requirement to 1MB • Table entries can be change at any time, allowing a user to be able to experiment easily with different color combinations without changing the attribute setting for the graphics data structure • When a color value in the color table is changed, all pixels with that color index will change to the new color • Without color table, we can only change the color of a pixel by storing the new color at that frame buffer location
Point Attributes • Two attributes of point • Color • Set with RGB values or an index into a color table • Size • An integer multiple of the pixel size • Large point is displayed as a square block of pixels
Line Attributes • Basic attributes • Color • Set with the same function for all graphics primitives (using RGB values) • Width • Define with separate line functions • Style • Define with separate line functions • Special effects for lines • Pen • Brush • Strokes
Line Width • A standard width line is generated with single pixels at each sample position • Thicker lines are displayed as positive integer multiplies of the standard line • Methods • If line slope magnitude ≤ 1.0 use vertical span • Plotting a vertical span of pixels in each column (x position) along the line. • If line slope magnitude > 1.0 use horizontal span • Plotting a pixels to the right and left of the line path.
Line Width • Advantage vertical/horizontal span pixel • Quick to generate the thick line • Disadvantage • The displayed width of a line is dependent to its slope • i.e. 45 degree line will displayed thinner compare to vertical and horizontal line • The line ends are horizontal or vertical regardless of the slope of the line • Solution • Adjust the shape of the line ends to give them a better appearance
Shape of the Line Ends Square ends that are perpendicular to the line path Line ends are added with a filled semi circle. Centered at the middle of the thick line. Diameter = the line thickness Extend the line and add butt caps that are positioned ½ of the line width
Line Width • Other approach producing a thick line • Displaying the line as a filled rectangle • Generating the line with a selected pen or brush
Smooth Connection Line Segment • Method discussed will not produce a smoothly connected series of line segments • It leaves pixels gaps at boundary between line segments with different slope where there is a shift from horizontal pixel spans to vertical pixel spans • Additional processing at the segment endpoints is required to solve the problem
Smooth Connection Line Segment • 3 possible methods for smoothly joining 2 line segments Extending the outer boundaries of each of the two line segments until they meet Capping the connecting between two segments with a circular boundary whose diameter = line width Displaying the line segments with butt caps and filling in the triangular gap where the segments meet
Line Style • Type • Solid • Dotted – very short dash with spacing equal to or greater than dash itself • Dashed – displayed by generating an interdash spacing • Pixel count for the span and interspan length is specified by the mask • E.g. 111100011110001111 • Note: fixed pixel with dashes can produce unequal length dashes. It depends on line orientation. So need to adjust the number of plotted pixel for different slopes
Pen and Brush • The selected “pen” or “brush” determine the way a line will be drawn • Pens and brushes attributes are size, shape, color and pattern • Pixel mask is applied in both of them
Curve Attributes • Similar to line: type + width • Thicker curve can be produced by • Plotting additional pixel • Filling the space between two concentric circles • Using thicker pen or brush