o عَلَّمَهُ الْبَيَانَ Allah says o عَلَّمَهُ الْبَيَانَ He has taught him speech (and intelligence). Al-Qur'an, 055.004 (Ar-Rahman)
Majed Bouchahma boumaged@gmail.com Lecture-3 Attributes of Graphics Primitives : Attributes of Line Primitives Majed Bouchahma boumaged@gmail.com
Introduction In general, a parameter that affects the way a primitive is to be displayed is referred to as an attribute parameter i.e: size, color,… OpenGL assign attributes setting using separate functions that update a system attribute list. A graphic system that maintain a list for the current values of attributes is referred to as a state system. Attributes of output primitives are referred to as state variables.
OpenGL color functions glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB) 1st parameter: Frame Buffer 2nd parameter: Color mode In RGB mode we select the current color components using the function: glColor*(Colorcomponents) i.e:glColor3i(0,255,255)
Line Attributes Line Colour Line Type Solid Lines Dashed Lines Set by changing the pixel colour while drawing Line Type Different types of lines can be drawn by setting the length and spacing of displayed solid sections along the line path Solid Lines Dashed Lines Inter-dash spacing equal to the solid section Dotted Lines Inter-dash spacing greater than the solid section
Line Attributes… Line Type… (See Book P.185) Use of pixel masks Pixel counts along the line path for the solid and inter-line spacing can be specified by using pixel masks Bit strings containing ones and zeros 1111000 Draw 4 pixels and then give spacing of 3 pixels
Line Attributes… Line Width ( See book P:183) Thicker lines can be displayed as positive integer multiples of the standard line by plotting additional pixels along adjacent line paths
Brush and Pen Options The pen or the brush is the name of the tool used for drawing a line Its shape changes the way a line is drawn Brush Options
Brush and Pen Options… A brush can be represented by a pixel mask in the form of a matrix which stores the pixel values to be set at each pixel location along the path of the line 1 1
Curve Attributes Can be set in a similar ways as line attributes
Anti-aliasing in Line Drawing Displayed primitives generated by the raster algorithms contain jaggies The sampling process digitizes coordinates points on an object to discrete integer pixel positions This distortion of information due to under-sampling is called aliasing Can be removed through anti-aliasing algorithms There are no samples (pixels) available between the two steps which leads to under-sampling and as a result jaggies are produced
Anti-Aliasing through Super-Sampling Divide each pixel into a number of sub pixels and count the number of sub pixels that are along the line path Set the intensity level of each pixel in proportion to the sub pixel count
Anti-Aliasing through Super-Sampling Example Each pixel broken into 9 (3x3) sub pixels Bresenham algorithm now selects which of the sub-pixels will be turned on during line drawing Maximum number of pixels that can be turned on by the line drawing algorithm is 3 Therefore the number of color levels for each pixel is 3 The pixel colors are set proportional to the number of sub pixels turned on Pixel level for a pixel with all 3 pixels on = line color Pixel level for a pixel with no pixels on = background color
Anti-Aliasing through Super-Sampling Example Each pixel broken into 9 (3x3) sub pixels Bresenham algorithm now selects which of the sub-pixels will be turned on during line drawing Maximum number of pixels that can be turned on by the line drawing algorithm is 3 Therefore the number of color levels for each pixel is 3 The pixel colors are set proportional to the number of sub pixels turned on Pixel level for a pixel with all 3 pixels on = line color Pixel level for a pixel with no pixels on = background color Line intensity is spread out over a greater number of pixels and the stairstep effect is smoothed by displaying a blurred line path in the vicinity of the stair step
End of Lecture-3 Work expands so as to fill the time available for its completion. Cyril Northcote Parkinson (1909–1993) British political scientist, historian, and writer. Parkinson's Law (1958).