Home | Reviews | GUIpedia | Forum | Fun500
tacodrake95 | TransparencyDoes 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-16 | 11:42 PM |
Jason | Re:Transparencyyou 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-17 | 12:38 AM |
Todd | Re:TransparencyConceptually, 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-17 | 7:49 AM |
pharoah | Re:TransparencyWhat 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-17 | 10:17 AM |
tacodrake95 | Re:TransparencyWell, 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-22 | 2:52 PM |
Jason | Re:TransparencyI hope you read the routines I gave you. | 2011-03-23 | 5:02 PM |
pharoah | Re:TransparencyJason, 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-23 | 6:18 PM |
Jason | Re:TransparencyIt renders fine in Chrome and Internet Explorer
i use "Less Than"+"Forward Slash"+"BR"+"Greater Than" | 2011-03-23 | 11:19 PM |
pharoah | Re:TransparencyRegardless 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-24 | 1:01 AM |
Jason | Re:Transparencyargh 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-24 | 5:55 AM |
tacodrake95 | Re:TransparencyWell, 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-24 | 2:02 PM |
tacodrake95 | Re:TransparencyHere is a screen-shot:
| 2011-03-24 | 11:42 PM |
Jason | Re:Transparencythat 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-27 | 8:23 AM |
BASIC Programming Help
2021 Brandon Cornell