Page 1 of 1

Can an image be used like a stencil?

Posted: Sat Aug 29, 2015 4:03 pm
by rbytes
I thought that if I created a full-screen image and drew transparent text on it, that it could be saved as a .png (with alpha information intact) and used as a stencil. I would then load a patterned image, set GRAPHICS MODE CLEAR, and draw my stencil image onto the pattern. I thought that this would leave me with just some pattern-filled letters, but in fact it left me with a transparent screen. It seems that the transparent portion of the stencil still drew transparency, although I thought it wouldn't. Is there a flaw in my logic?

Code: Select all

F$="testimage"
ALBUM IMPORT F$                                    ' choose a pattern
GRAPHICS
GRAPHICS CLEAR 0,0,1                               ' make a color background     
GRAPHICS MODE CLEAR
DRAW FONT NAME "ArialMT"
DRAW FONT SIZE 200
DRAW TEXT "Hullabaloo" AT 50,200                   ' draw transparent text
GRAPHICS SAVE 0,0, 1024,768 TO "stencil.png"      ' save image with alpha data
GRAPHICS MODE NORMAL
DRAW IMAGE F$ AT 0,0 SCALE 1                       ' draw the patterned image
GRAPHICS MODE CLEAR
DRAW IMAGE "stencil1.png" AT 0,0 SCALE 1 'ANGLE A  ' draw the stencil
GRAPHICS SAVE 0,0, 1024,768 TO "final.png"
PAUSE 30

Re: Can an image be used like a stencil?

Posted: Sat Aug 29, 2015 4:14 pm
by Mr. Kibernetik
MODE CLEAR clears everyting which is drawn, regardless of transparency channel.

Re: Can an image be used like a stencil?

Posted: Sat Aug 29, 2015 4:52 pm
by rbytes
Thanks. It would be nice to have a mode similar to CLEAR in which the alpha channel would affect the result. I guess Apple created these graphics modes, so I will hope at some point they will add one like that.

Re: Can an image be used like a stencil?

Posted: Sat Aug 29, 2015 5:10 pm
by Mr. Kibernetik
Actually these GRAPHICS MODEs are quite powerful.

You can try MODE DESTIN if you want to erase graphics using source transparency, because R = D * Sa. All explanations of these letters are in the manual.

Re: Can an image be used like a stencil?

Posted: Sat Aug 29, 2015 9:24 pm
by rbytes
MODE DESTIN was the solution to the stencil problem. I wrote some code to test it and got these graphic-filled letters on a transparent background. Thanks, Mr. K.