Can an image be used like a stencil?

Post Reply
User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Can an image be used like a stencil?

Post 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
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Can an image be used like a stencil?

Post by Mr. Kibernetik »

MODE CLEAR clears everyting which is drawn, regardless of transparency channel.

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Can an image be used like a stencil?

Post 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.
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Can an image be used like a stencil?

Post 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.

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Can an image be used like a stencil?

Post 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.
Attachments
image.jpg
image.jpg (112.45 KiB) Viewed 1879 times
The only thing that gets me down is gravity...

Post Reply