[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: filled contours with POLYFILL



Ted Graves wrote:

Ted, could you set your right margin to about 72 characters? This makes
the quoted text easier to read.

> I am drawing closed contours over an image, and would like to fill the contours with
> a pattern which allows viewing of the image beneath (like a checkerboard).  I have an
> array of vertices which i plot using PLOTS, then i tried passing the vertices to
> POLYFILL to fill in the enclosed area.  I tried using a pattern of
> 
> [ [255, 0  ]
>   [0,   255] ]
> 
> to generate a checkerboard, but despite my finger crossing the zeroes in the pattern
> are drawn as black and not left undrawn.  Is there any simple way to achieve the kind
> of "holey" pattern i'm looking for with POLYFILL?  Or do i need to do something fancy
> with POLYFILLV?

POLYFILL has a TRANSPARENT keyword which is exactly what you are looking
for, alas, it only works for the Z buffer. You could display your image
there, too, then use polyfill, grab the output and display it in a
'real' window.

set_plot, 'Z' ; switch graphics device to Z buffer
; draw some images
ployfill, x, y, /device, pattern=pattern, transparent=1 ; fill the
contour
image = tvrd( 0, 0, xsize, ysize ) ; capture output
set_plot, 'X' ; back to X (or set_plot, 'Win' if using Windows
tv, image ; display the captured output

Not too elegant, I admit. Another way would be not using polyfill:

; Grab the image from the screen with tvrd()
image = tvrd( 0, 0, xsize, ysize )

; make a copy
image2 = image

; set every 2nd pixel to 255. xsize needs to be odd for this to work!
; be sure xsize or ysize are long integers!
image2[lindgen( xsize*ysize/2 ) * 2] = 255

; get the indices inside the polygon
index = polyfillv( x, y, xsize, ysize )

; change the original image
image[index] = image2[index]

; re-display the altered image
tv, image

I didn't test this, but I think it should work. Easier solutions may
exist.

        Alex
-- 
  Alex Schuster     Wonko@weird.cologne.de          PGP Key available
                    alex@pet.mpin-koeln.mpg.de