Lập trình đồ họa trong C (phần 4) pps

50 754 0
Lập trình đồ họa trong C (phần 4) pps

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

3-3. Dev~se a consistent scheme for implement~ng the polyline funct~on, for any set of input line endpoints, using a modified Bresenhani line algorithm so that geometric trenrises magnitudes are maintained (Section 3-1 0). 3-4. Use the midpoint method to derive decision parameters for generating points along a straight-line path with slope in the range 0 < rn < 1. Show that the midpoint decision parameters are the same as those in the Bresenham line algorithm. 3-5. Use the midpoint method to derive decision parameters that can be used to generate straight line segments with any slope. 3-6. Set up a parallel version of Bresenham's line algorithm for slopes in the range 0 < m < 1. 3-7. Set up a parallel version of Bresenham's algorithm for straight lines of any slope. 3-8. Suppose you have a system with an 8-inch by l0.inch video monitor that can display 100 pixels per inch. If memory is orgamzed in one-byte words, the starting frame- buffer address is 0, and each pixel is assigned one byte of storage, what is the frame- buffer address of the pixel with screen coordinates (>, v)? 3-9. Suppose you have a system with an &inch by 10-~nch video monitor that can display 100 pixels per inch. If memory is organized in one-byte words, the starting frame- buffer address is 0, and each pixel is assigned 6 bits of storage, what IS the frame- buffer address (or addresses) of the pixel with screen coordinates (x, y)? 3-10. Implement the setpixel routine in Bresenham's l~ne algorithm using iterative tech- niques for calculating frame-buffer addresses (Section 3-3). 3-1 1. Rev~se the midpoint circle algorithm to display v) that geometric magnitudes are maintained (Section 3-10). 3-1 2. Set up a procedure for a parallel implementation of the midpoint circle algorithm. 3-1 3. Derive decision parameters for the midpoint ell~pse algorithm assuming the start posi- tion is (r,, 0) and points are to be generated along the curve path in counterclockwise order. 3-1 4. Set up a procedure for a parallel implementation of the midpoint ellipse algorithm 3-1 5. Devise an efficient algorithm that takes advantage of symmetry propertie to display a sine function. 3-16. Dcvisc an efficient algorithm, taking function symmetry into account, to display d plo~ of damped harmonic motion: y - Ae-" sin (ox'+ 0) where w is the angular frequency and 0 is the phase of the sine function. Plot y as a function of x for several cycles of Ihe sine function or until the maximum amplitude is reduced to A/10. 3-1 7. Using the midpoint method,-md taking symmetry into account, develop an efficient algorithm for scan conversion of the follow~ng curve over the Interval -10 5 x 5 10: 3-1 8. Use the midmint method and symmetry considerations to scan convert the parabola over the interval - 10 I x 5 10. 1-19. Use the midpoint method and symmetry considerations to scan convert the parabola forthe interval -10 5 y 5 10. Chapter J 3-20. Set up a midpoint algorithm, taking symmetry considerat~ons into account to scan Output Prim~lives convert any parabola of th? form with input values for parameters a, b, and the range of u 3-21. Write a program to $can convert the interior of a specified ell~pse Into a solid color. 3-22. Devise an algorithm for determining interior regions for any input set of vertices using the nonzero winding number rule and cross-product calculations to identify the direc- tion of edge crossings 3-23. Devise an algor~thm ic~r determ~ning interior regions for any input set of vertices using the nonzero winding number rule and dot-product calculations to identify the direc- tion of edge crossings. 3-24. Write a prcedure (01 filling the interior of any specif~cd set of "polygon" vertices using the nonzero winding number rule to identify interior regions. 3-25. Modily the boundaly-(ill algorithm for a 4-connected region to avoid excessi~e stack- ing by incorporating scan-line methods. 3-26. Write a boundary-fill procedure to fill an 8-connected region. 3-27. Explain how an ellipse displayed with the midpoint method could be properly filled with a boundary-fill algorithm. 3-28. Develop and mplenent a flood-fill algorithm to fill the interior of any specified area. 3-29. Write a routine to implement the text function. 3-30. Write a routine to implement the polymarker function 3-31. Write a program to display a bar graph using the polyline function. lnput to the program is to include :he data points and thc labeling reqi~ired for the x and y axes. The data points are to be scaled by the program so that the graph is displayed across the full screen area. 3-32. Write a Drogram to d~splay a bar graph in any selected sclren area. Use the poly- line function to draw the bars. 3-33 Write a procedure to display a line graph lor any input sel ol data points in any se- lected area of the scrrtn, with the input dam set scaled to f~t the selected screen area. Data points are to be displayed as asterisks joined with straight line segments, and the x and y axes are to be labeled according to input speciiica~~ons. (Instead of asterisks. small circles or some orher symbols could be used to plot the data points.) 3-34. Using d circle function, write a routine todisplay a ple chart with appropriate label- ing. lnput to the routine is to include a data set giving the distribution of the data over some set of intervals, the name of the pie chart, and the names of the intervals. Each section label IS to be displayed outside the boundary of the pie chart near the corre- sponding pie section. [...]... settings for the character-spacing parameter The orientation for a displayed character string is set according to the direction of the character up vector: width 1.0 width 2.0 Figwe 4-27 The effect of different character-width settingson displayed text Spacing 0.0 setcharacterupvector (upvect) Spacing 0.5 Parameter upvec t in this function is asslgned two vdlues that specify the x and y vector components... fill color with the two background colors to obtain the new pixel color With three background colors and one foreground color, or with two background and two foreground colors, we nccd all thrcc RCB cquations to obtain the relative amounts of the four colors For some foreground and background color combinations, however, the system of two or three RCB equations cannot be solved This occurs when the color... ratio of characters with character kern -, character I' kern body Height 1 wctior 4-5 Character Anr~butes Height 2 H i h 3 l ' i p r c 4-26 The effect of different characterheight settings an displayed text Parameter ch is assigned a real value greater than 0 to set the coordinate height of capital letters: the distance between baseline and capline in user coordinates This setting also affects character-body... fill color Vector Equation 4-1 holds for'each Section 4-5 RGB component of the colors, with Character Attributes P = ( P R ,PC, PR), F = (FR, FR), Fc, B = (BR, BB) Bc, We can thus calculate the value of parameter f using one of the ponents as (4-2) RGB color com- where k = R, G, or B; and Fk * Bk.Theoretically, parameter t has the same value for each RCB component, but roundoff to integer codes can... typeface The distance between the bottorrrlirie and the lopline of the character body is the same for all characters in a particular size and typeface, but thr body width may vary Proportior~ollyspaced for~ts assign J smaller body width to narrow characters such as i, j, 1, and f compared to hroad characters such as W or M Character heigk: is defined as the distance between thc baseline and the cuplint-... implemented bv procedures that load , the chosen character into the raster at the defined positions with the specified color and size We select a particular character to be the marker symbol with Direction of Character up Vector (a) where marker type parameter m t is set to an integer code Typical codes for marker type are the integers 1 through 5, specifying, respectively, a dot (.I, a vertical cross (+),... When a character string is to be displayed, the current (color i; used to set pixel values in the frame hufier corresponding to the character shapes and positions Control of text color (or intensity) is managed from an application program with where text color piramcter t c specifies a n allowable color code We can a d j ~ ~text size by scaling theoverall dimensions (height a n d width) st of characters... characters Text height is unaffected by this attribute setting Examples of text displayed with different character expansions is given in Fig 4-27 Spacing between characters is controlled separately with where the character-spacing parameter c s can he asslgned any real value The value assigned to c s determines the spacing between character bodes along print lines Negative values for c s overlap character... To Eiur Gun Section 4-3 WS =- 2 Ci Color - - Figure 4-17 Workstation color tables Crayscale With monitors that have no color capability, color hmctions can be used in an application program to set the shades of gray, or grayscale, 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... characters Kerned characters, such as f and j in Fig 4-25, typically extend beyond the character-body limits, and letters with descenders (g, j, p, q, y) extend below the baseline Each character is positioned within the character body by ;I font designer to allow suitable spacing along and h~ tween print lines when text is displayed with character hodies touching Text size can be adjusted without changing . the cirmlar arc, as discussed in Section 3-10, we can set the radii for the concentric boundary arcs at r = 14 and r = 17. Although this method is accurate for generating thick circles,. for a circrular arc in the first quadrant. Here, the center of the rectangular pen is moved to successive curve positions to produce the curve shape shown. Curves displayed with a rectangular. =- 2 Ci Color Section 4-3 Color and Graywale Levels - - Figure 4-17 Workstation color tables. Crayscale With monitors that have no color capability, color hmctions can be used

Ngày đăng: 07/07/2014, 05:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan