Home | Reviews | GUIpedia | Forum | Fun500

Does anyone know how to do a simple transparency routine in screen 13? Or know about a tutorial on it? If anyone could help me that would help a lot.
2011-03-1611:42 PM

you could try using a dithering routine using line's bit scan: X1% = 10 Y1% = 10 X2% = 310 Y2% = 190 Col% = 15 FOR X% = X1% TO X2% Indent% = Indent% XOR 1 LINE (X%, Y1% + Indent%)-(X%, Y2%), Col%, , &HAAAA NEXT X% This will create a checkered square in the middle of your screen

You could also try using 256 shades of gray instead of the default color palette and then use:
FOR Col% = 0 to 255 OUT &H3C8, Col% OUT &H3C9, Col% \ 4 OUT &H3C9, Col% \ 4 OUT &H3C9, Col% \ 4 NEXT Col% X1% = 10 Y1% = 10 X2% = 310 Y2% = 190 Brightness% = 20 FOR X% = X1% TO X2% FOR Y% = Y1% TO Y2% Col% = POINT(X%, Y%) + Brightness% IF Col% > 255 THEN Col% = 255 IF Col% < 0 THEN Col% = 0 PSET (X%, Y%), Col% NEXT Y% NEXT X%
I'd suggest the first one, it's not too flash but it's much faster than plotting pixels individually
2011-03-1712:38 AM

Conceptually, transparency is easily done by saying that whatever color your transparent window is, the closer it is to the pixels beneath it (in terms of color). So let's say your window is RGB(255,255,255) [white] and your background is RGB(0,0,255) [blue] - just for simplicity. The alpha value determines how much transparency it has so in your case, you'd take the difference of your window's color pattern and the background's color pattern: (255, 255, 0).Your alpha value ranges from 0 to 1 (as a floating point) and you simply multiply each difference in color by the alpha value to find its true color: [for example] alpha = 0.5 ===> RGB(127, 127, 0). Then you subtract this color from your window's color values to find the pixel color for transparency.I know this is really complex but that's how it works conceptually. Maybe it'll help, maybe it won't.
2011-03-177:49 AM

What Todd said. Essentially, you're taking a weighted average of the R, G, and B components for the foreground and background color. In order to do this in screen 13, you'll probably have to muck about with the palette.
2011-03-1710:17 AM

Well, todd, the end result og 50% transparency with white(255, 255, 255) over blue (0, 0, 255) would be Sky Blue(128, 128, 255)
2011-03-222:52 PM

I hope you read the routines I gave you.
2011-03-235:02 PM

Jason, you might want to put some code or pre tags around those. They're pretty hard to read as is. Or you could fix your br tags.
2011-03-236:18 PM

It renders fine in Chrome and Internet Explorer
i use "Less Than"+"Forward Slash"+"BR"+"Greater Than"
2011-03-2311:19 PM

Regardless of how it renders in those browsers, it's not correct to have a closing tag without an opening tag, and firefox doesn't like it. Perhaps you were going for the XHTML convention, which is <br />. If you used the <pre> tag, you'd have the advantage of not having to put all of those breaks in explicitly, and the indentation would be preserved as well.
2011-03-241:01 AM

argh fine ill fix it, you can still read the code
back on topic! try my routines. i suggest the dithering technique as it is fast and the palette doesnt need modifying.
the other routine appends to the current color of the plotted pixel, it takes much longer to draw (this would be slower than drawing a box 1px at a time)
2011-03-245:55 AM

Well, I think that the dithering would work for Cyclops, but I am using another routine that takes a palette file and reads it into the palette, then takes the current pixel and replaces it's transparent counterpart.
2011-03-242:02 PM

Here is a screen-shot:
2011-03-2411:42 PM

that seems like the way to go. in my gui (not soon to be released, im urbexing for the meanwhile) users will have the option to use 256 shades of grey instead of 16m colors
2011-03-278:23 AM

BASIC Programming Help

2021 Brandon Cornell