12.07.2015 Views

wu'ed in haste; fried, stewed at leisure

wu'ed in haste; fried, stewed at leisure

wu'ed in haste; fried, stewed at leisure

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

mov cx.8sub cx.Cbp1.IntensityBitsmov ch.byte ptr [bpl.NumLevelsdec chmov bp,BaseColor[bplxchg bp.ax: Draw all rema<strong>in</strong><strong>in</strong>g pixelsXMajorLoop:add dx,bpjnc NoYAdvanceadd si.SCREEN_WIDTH-IN-BYTESNoYAdvance:add si .bx;CL - I/ of bits by which to shift: ErrorAcc to get <strong>in</strong>tensity level (8: <strong>in</strong>stead of 16 because we work only: with the high byte of ErrorAcc);mask used to flip all bits <strong>in</strong> an: <strong>in</strong>tensity weight<strong>in</strong>g, produc<strong>in</strong>g: result (1 - <strong>in</strong>tensity weight<strong>in</strong>g):***stack frame not available***:***fromnow on***:BP - ErrorAdj. AL - BaseColor.: AH - scr<strong>at</strong>ch register:calcul<strong>at</strong>e error for next pixel;not time to step <strong>in</strong> Y yet:the error accumul<strong>at</strong>or turned over,: so advance the Y coord:advance Y:X-major. so add XDir to the pixel po<strong>in</strong>ter: The Intensityeits most significant bits of ErrorAcc give us the <strong>in</strong>tensity: weight<strong>in</strong>g for this pixel, and the complement of the weight<strong>in</strong>g for the: paired pixel.mov ah.dh :msb of ErrorAccshr ah.cl :Weight<strong>in</strong>g - ErrorAcc >> IntensityShift:add ah,al :Basecolor + Weight<strong>in</strong>gmov Csi1,ah :DrawPixel(X. Y. BaseColor + Weight<strong>in</strong>g):mov ah.dh :msb of ErrorAccshr ah.cl :Weight<strong>in</strong>g - ErrorAcc >> IntensityShift:xor ah.ch :Weight<strong>in</strong>g A Weight<strong>in</strong>gComplementMaskadd ah.al :Basecolor + (Weight<strong>in</strong>g A Weight<strong>in</strong>gComplementMask)mov [si+SCREEN-WIDTH-IN-BYTES].ah:DrawPixel(X. Y+SCREEN-WIDTH-IN-BYTES,: BaseColor + (Weight<strong>in</strong>g A Weight<strong>in</strong>gComplementMask)):dec di :--0eltaXjnz XMajorLoopDone:POP dspop dipop siPOP bPret-0rawWuL<strong>in</strong>e endpend;we’re done with this l<strong>in</strong>e;restore C’s default d<strong>at</strong>a segment:restore C’s register variables:restore caller’s stack frame;doneNotes on Wu Antialias<strong>in</strong>gWu antialias<strong>in</strong>g can be applied to any curve for which it’s possible to calcul<strong>at</strong>e <strong>at</strong>each step the positions and <strong>in</strong>tensities of two bracket<strong>in</strong>g pixels, although the implement<strong>at</strong>ionwill generally be nowhere near as efficient as it is for l<strong>in</strong>es. However, Wu’sarticle <strong>in</strong> Computer Ofaphicsdoes describe an efficient algorithm for draw<strong>in</strong>g antialiasedcircles. Wu also describes a technique for antialias<strong>in</strong>g solids, such as filled circles andpolygons. Wu’s approach biases the edges of filled objects outward. Although this isno good for adjacent polygons of the sort used <strong>in</strong> render<strong>in</strong>g, it’s certa<strong>in</strong>ly possible toWu‘ed <strong>in</strong> Haste; Fried, Stewed <strong>at</strong> Leisure 791

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!