Chapter 4 Attributes of Graphics Primitives 2010 1
Chapter 4. Attributes of Graphics Primitives 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 1
attribute parameter § primitive의 디스플레이 방법에 영향을 줌 § lines : dotted or dashed, fat or thin, blue or orange § areas: one color or multicolor pattern § text: from left to right, across screen, vertical columns § characters: fonts, colors, sizes § object edges: intensity variation for smoothing out the raster stairstep effect 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 2
§ attribute option을 그래픽스 패키지에 첨가하는 방법 § 파리미터 리스트에 attributes를 첨가 § 예 ) line-drawing function에 color, width, or other properties등 을 endpoint coordinates에 첨가 § 또 다른 방법으로 현재 attribute values에 대한 시스템 리스트를 유지시키는 방 법 § system attribute list를 update하는 함수에 의해 attribute setting이 이루어짐 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 3
Open. GL state variables § § State variables or state parameters: output primitive 속성 및 기타 parameter (frame buffer의 현재 위치 등) 를 말함 Open. GL state parameters 에는 color, other primitive attributes, current matrix mode, model-view matrix, current position for the frame buffer, lighting parameters 등이 속함. Open. GL 의 그래픽스 프리미티브들은 현재의 상태리스트(state list) 속성들과 함께 디스플레이된다. 속성 변화는 Open. GL 상태의 변경 이후에 지정된 프리미티브에만 영향을 미친다. 상태 변화 이전에 정의된 프리미티브는 속성을 그대로 유지. § 즉, green line 을 그린 후, 현재 color 를 red 로 바꾼 뒤에, red line 을 그림 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 4
Color and Grayscale Levels § § general purpose raster-scan systems: wide-range of colors 제공, random-scan monitor는 색의 선택 수가 적다. color options는 0이상의 양수로 코드화되고 CRT 모니터에서는 이러한 코드가 electron beam의 intensity-level settings로 전환된다. Color plotter는 ink-jet or pen selection을 컨트롤한다. color information을 frame buffer에 저장하는 방법 1) 칼라 코드를 직접 프레임 버퍼에 저장하는 법 § 칼라를 저장할 최소 기억장소로는 픽셀당 3비트 필요 (Table 4 -1) § 픽셀 당 6비트를 이용한다면 R, G, B각각의 electron gun이 2비트씩 이용하여 64 칼라값을 갖게 됨 § 1024*1024의 full-color (24 -bit per pixel) RGB system : 3 megabytes 의 기억장 소가 필요하게 됨 -> 3 byte * 106이므로 3 megabytes 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 5
Table 4 -1 The eight color codes for a three-bit per pixel frame buffer (TABLE 4 -1) The eight color codes for a three-bit per pixel frame buffer Color Code 0 1 2 3 4 5 6 7 2010 -1학기 Stored color values In frame buffer Red Green Blue Displayed Color 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 0 1 1 Black Blue Green Cyan Red Magenta Yellow White Chapter 4. Attributes of Graphics Primitives 6
Figure 4 -1 A color lookup table with 24 bits per entry that is accessed from a frame buffer with 8 bits per pixel Color lookup table 0 y 196 x 196 2081 255 0 0 0 1 0 0 0 1 Red Green Blue 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 8
Intensity Codes for a Four-Level Grayscale System Intensity Codes 0. 0 0. 33 0. 67 1. 0 2010 -1학기 Stored Intensity Values In the Frame Buffer (Binary Code) Displayed Grayscale 0 (00) 1 (01) 2 (10) 3 (11) Black Dark gray Light gray White Chapter 4. Attributes of Graphics Primitives 10
Open. GL Color Functions § § § § glut. Init. Display. Mode (GLUT_SINGLE | GLUT_RGB); gl. Color 3 f (0. 0, 1. 0); gl. Color 3 fv (color. Array); gl. Color 3 i (0, 255); gl. Indexi (196); // Color-Index Mode glutsetcolor (index, red, green, blue); gl. Enable (GL_BLEND); § color blending: source color 와 destination color 를 합침 § source color: 첫 객체의 color를 frame buffer 에 올린 후에 두 번째 객체의 color를 프레임버퍼 컬러와 결합한다. gl. Dsiable (GL_BLEND); 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 11
§ gl. Enable. Client. State (GL_COLOR_ARRAY); § color 위치와 형식 지정 § gl. Color. Pointer (n. Color. Components, data. Type, offset, color. Array); typedef Glint vertex 3 [3], color 3 [3]; vertex 3 pt[8] = { {0, 0, 0}, {0, 1, 0}, … } color 3 hue[3] = {{1, 0, 0}, …} gl. Enable. Client. State (GL_VERTEX_ARRAY); gl. Enable. Client. State (GL_COLOR_ARRAY); gl. Vertex. Pointer (3, GL_INT, 0, pt); gl. Color. Pointer (3, GL_INT, 0, hue); 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 12
Other Open. GL Color Functions § § § gl. Clear. Color (red, green, blue, alpha); gl. Clear (GL_COLOR_BUFFER_BIT); gl. Clear. Index (index); 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 13
Point Attributes § § § 점의 기본 속성: color, size 점의 color 와 size 는 현재의 attribute list 에 저장된 값으로 결정됨 raster system 에서는 point size는 pixel size의 복수배로 표시 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 14
Figure 4 -2 A double-wide raster line with slope |m| < 1. 0 generated with vertical pixel spans 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 16
Figure 4 -3 A raster line with slope |m| > 1. 0 and a line width of 4 plotted using horizontal pixel spans 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 17
Figure 4 -4 Thick lines drawn with (a) butt caps, (b) round caps, and (c) projected square caps 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 19
Figure 4 -5 Thick line segments connected with a miter join (a), a round join (b), and a bevel join (c) 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 20
Curve Attributes § § colors, widths, dot-dash patterns, pen or brush options를 변화시켜 곡선의 속성을 바꿈 pixel mask 이용 § dashed, dotted pattern생성시 (그림 4 -12) § 예) 11100을 이용한다면 다양한 폭으로 raster curve를 생성할 때: horizontal or vertical pixel spans를 이용 § 기울기가 1보다 작으면 vertical span, 1보다 크면 horizontal span을 이용 (그림 410) thick curve 디스플레이 § 2개 평행한 curve paths사이의 area를 채우는 방법으로 해결 § 지정된 curve path를 one boundary로 이를 inside or outside로 shift한 것을 second boundary로 한다. 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 21
Figure 4 -12 A dashed circlular arc displayed with a dash span of 3 pixels and an inter-dash spacing 2 pixels 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 22
Figure 4 -10 A circular arc of width 4 plotted with either vertical and horizontal pixel spans, depending on the slope 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 23
§ pen or brush displays of curves § 선분의 경우와 비슷하게 처리 § 곡선의 line path를 따라 pen shape 을 복제해 감 § 펜의 중심이 curve shape를 따라 연속적으로 이동함 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 24
Open. GL Point-Attribute Functions § gl. Point. Size (size); § Point size 1. 0: a single pixel § Point size 2. 0: 2 by 2 pixel array gl. Color 3 f(1. 0, 0. 0); gl. Begin (GL_POINTS); gl. Vertex 2 i (50, 100); gl. Pointsize (2. 0); gl. Color 3 f (0. 0, 1. 0, 0. 0); gl. Vertex 2 i (75, 150); gl. Pointsize (3. 0); gl. Color 3 f (0. 0, 1. 0); gl. Vertex 2 i (100, 200); gl. End( ); 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 25
Open. GL Line-Attribute Functions § § Open. GL Line-Width Function § gl. Line. Width (width); Open. GL Line-Style Function § gl. Line. Stipple (repeat. Factor, pattern); 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 26
Area-Fill Attributes § § Fill Options: § solid color or patterned fill중에 선택 § color와 pattern의 선택 § brush, transparency parameter 이용 polygon region or 곡선 내부의 영역에 fill options을 적용 Fill style (그림 4 -17) § hollow, solid, pattern, hatch § other fill options: edge type, edge width, edge color 등 Pattern Fill § tiling: 직사각형 패턴으로 영역을 채우는 것을 말함 § 평행사변형 영역에 흑백의 패턴을 디스플레이 § scanline procedure에서 스캔라인 위를 패턴이 지나가도록 영역을 채워나감 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 27
Figure 4 -17 Basic polygon fill styles: hollow, solid, patterned 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 28
Figure 4 -18 Area filled with hatch patterns: diagonal hatch, diagonal crosshatch 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 30
§ linear soft-fill algorithm § foreground color F와 background color B 를 합쳐서 다시 칠하는 방법 § 한 영역 내의 각 픽셀의 칼라 P는 F와 B의 linear combination으로 다시 구해짐 § P = t. F + (1 -t) B t: transparency factor, 0 에서 1사이의 한 값을 가짐 § P = (PR, PG, PB) § F = (FR, FG, FB) § B = (BR, BG, BB) 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 31
Figure 4 -20 Interior pixels along a scan line y x 10 14 18 24 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 33
Figure 4 -21 Intersection points along scan lines 1 1 2 Scan Line y’ 2 1 1 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 1 Scan Line y 34
Figure 4 -22 Adjusting endpoints y values for a polygon Scan Line y+1 Scan Line y-1 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 36
§ Boundary-Fill Algorithm § 내부 한점에서 출발하여 경계선을 향하여 색칠해가는 방법(그림 4 -26) § interactive painting packages에 유용 § Procedure § 내부의 한 점 (x, y), fill color, boundary color를 입력받아, (x, y)에서 출발하 여 인접한 픽셀이 boundary color인지를 첵크하여 아니면 fill color를 주고 다시 인접한 픽셀로 테스트를 계속해감 § two methods: (그림 4 -27) § 4 -connected § 8 -connected 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 37
Figure 4 -26 Example color boundaries for a boundary-fill procedure 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 38
Figure 4 -27 Fill methods applied to a 4 -connected area and to an 8 connected area 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 39
Polygon Fill Areas § polygon: § vertex 라고 부르는 좌표점으로 구성된 평면의 모양으로 이 점들은 선분으로 연 결되어 있음. § Polygon Classifications § Convex polygon § Concave polygon 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 40
Character Generation § § § typeface (활자): characters를 위한 design style을 말함: § 수백개의 typeface가 있슴 § 예) Courier, Helvetica, New York, . . font: 특정 사이즈와 포맷으로 된 문자체을 말함 § 예) 10 -point Courier Italic등 § 요즘엔 typeface와 구별 없이 씀 typeface (or font)는 두 타입으로 분류 § serif: 문자 획의 끝에 small lines 혹은 accents 포함 § more readable § good for longer blocks of text § sans-serif: accents를 포함하지 않음 § easier to recognize § good for labeling and short heading 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 41
Figure 4 -35 The letter B represented with 8 by 8 bitmap pattern and with an outline shape 1 0 0 0 1 0 2010 -1학기 1 1 1 1 0 1 1 1 1 1 0 0 0 Chapter 4. Attributes of Graphics Primitives 43
Character Attributes § § font, size, color, orientation 등으로 속성을 나타냄 Text attributes § font및 각 폰트에 대해 underlining styles, boldface, italics, outline, shadow를 가짐 § text size: § character width의 크기를 조정하거나 height, width의 크기로 조정함 § point: size of the body of a character를 나타냄 § 1 point는 0. 013837 inch (1/72 inch)이며 point로 문자의 몸체(body)의 크 기를 나타냄 § 지정된 사이즈의 폰트 내에서 어느 문자도 topline과 bottom line의 거리 가 일정하다. § character height: base line과 cap line의 거리를 의미하며 height만으로도 텍스트의 크기를 조정할 수 있다 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 44
2010 -1학기 Chapter 4. Attributes of Graphics Primitives 45
§ proportionally spaced fonts: § i, j, l과 같은 narrow characters는 w, m과 같은 broad characters에 비해 폭 이 좁게 표시된다 § kerned characters (b, h, f, p, g, y등 상하로 돌출한 부분): bottom line을 벗어나 게 표현됨 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 46
Antialiasing § § aliasing: raster algorithm으로 디스플레이된 물체는 sampling process에 의해 discrete integer pixel position의 좌표점들을 표시하기 때문에 계단식의 들쑥날쑥한 모양을 나타내게 된다. 이와 같이 low-frequency sampling때문에 나타난 현상을 aliasing이라 고 하고 antialising method로 개선할 수 있다. antialiasing methods의 종류 § supersampling (postfilitering): 실제 이용할 수 있는 것보다 작은 그리드인 것처럼 스크린을 처리하여 sampling rate를 증가시켜 higher resolution의 특징으로 샘플 링한 다음 low resolution에 다시 디스플레이하는 방법 § area sampling (prefiltering): 디스플레이될 물체와 각 픽셀이 overlap하는 부분을 계산하여 pixel intensity를 정함 § pixel phasing: pixel areas의 디스플레이 위치를 shift시킴 (물체의 geometry에 대 해electron beam을 micropositioning) 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 47
§ § 예) subpixel intensities를 평균한 픽셀 값을 계산할 수 있음 § red line의 경계내부에 5개 subpixel이 존재하고 남은 4개 subpixel이 blue background area에 있다면 이 픽셀을 위한 색을 § pixelcolor = (5 * red + 4 * blue) / 9 로 나타낼 수 있다. pixel-weighting masks § pixel area의 중앙에 가깝게 위치한 subpixel에 weight를 크게 주도록 실행할 수 있슴 (그림 4 -49) 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 49
Figure 4 -47 Supersampling subpixel positions along a straight line segment 22 21 20 2010 -1학기 10 11 12 Chapter 4. Attributes of Graphics Primitives 50
Figire 4 -48 Supersampling subpixel positions in relation to the interior of a line of finite width 22 21 20 2010 -1학기 10 11 12 Chapter 4. Attributes of Graphics Primitives 51
Figure 4 -49 Relative weights for a grid of 3 by 3 subpixels 1 2 1 2 4 2 1 2 1 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 52
§ Area Sampling Straight Line Segments § 픽셀이 일정두께의 선분과 겹치는 부분과 비례하여 pixel intensity를 정함 § 픽셀이 선분과 90% 겹친다면 maximum intensity의 90%로 intensity를 정함 : 그 림 4 -38에서 (10, 20)위치의 픽셀의 경우 90%가 겹쳐지고 있으므로 intensity도 90%로 하고, (10, 21) 위치의 픽셀은 15% 정도의 intensity를 줌 § Pixel Phasing § 스크린 그리드 내부에서 subpixel positions을 address할 수 있는 raster systems에 서 이용함 § object geometry에 근접한 위치로 electron beam이 이동함 -> micropositioning § 각 pixel position이 pixel diameter의 1/4, 1/2, 3/4 만큼 shift됨 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 53
Figure 4 -53 Adjusting pixel intensities along an area boundary y+1 y X X+1 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 56
Figure 4 -56 Boundary edge of a fill area passing through a pixel grid section yk+1 yk+0. 5 yk xk xk+1 2010 -1학기 Chapter 4. Attributes of Graphics Primitives 57
Figure 4 -57 Overlap area of a pixel rectangle y = m (xk+0. 5) + b yk+0. 5 yk y = m (xk-0. 5) + b Overlap Area yk-0. 5 xk-0. 5 2010 -1학기 xk xk+0. 5 Chapter 4. Attributes of Graphics Primitives 58
2010 -1학기 Chapter 4. Attributes of Graphics Primitives 59
- Slides: 59