1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-26 17:55:52 +00:00
QB64-PE/internal/help/_ALPHA.txt
SMcNeill 6e01fc8dce Altered string compare routines (<,<=,>,>=) so they don't give false results with CHR$(0).
Added new _STRCMP and _STRICMP commands for quick string comparisons.
Cleaned up QB64 to finish removing the QUI (quick user insert) code and folders.
Altered UCASE and LCASE routines to be faster in some situations for us.
2014-09-22 08:19:03 -04:00

60 lines
2.7 KiB
Plaintext

The {{KW|_ALPHA}} function returns the alpha channel transparency level of a color value used on a screen page or image.
{{PageSyntax}}
:{{Parameter|result&amp;}} = {{KW|_ALPHA}}({{Parameter|colour~&amp;}} [, {{Parameter|imageHandle&amp;}}])
{{PageDescription}}
* If {{Parameter|imageHandle&amp;}} is omitted, it is assumed to be the current write page. Invalid handles will create [[ERROR Codes|Illegal function call]] errors.
* [[_NEWIMAGE]] 32 bit [[SCREEN]] modes will always use an [[_UNSIGNED]] [[LONG]] ''colour'' value.
** Color values that are set as a [[_CLEARCOLOR]] always have an alpha level of 0 (transparent).
** [[_SETALPHA]] can set any alpha level from 0 or fully transparent to 255 or opaque.
** Normal color values that are set by [[_RGB]] or [[_RGB32]] always have an alpha level of 255(opaque).
* In 4 (16 color) or 8 (256 color) bit palette screens the function will always return 255.
*[[_RED32]], [[_GREEN32]], [[_BLUE32]] and [[_ALPHA32]] are all equivalent to [[_RED]], [[_GREEN]], [[_BLUE]] and [[_ALPHA]] but they are highly optimized and only accept a 32-bit color (B8:G8:R8:A8). Using them (opposed to dividing then ANDing 32-bit color values manually) makes code easy to read.
* '''NOTE: 32 bit [[_NEWIMAGE]] screen page backgrounds are transparent black or [[_ALPHA]] 0. Use [[_DONTBLEND]] or [[CLS]] for opaque!'''
''Example 1:'' Alpha transparency levels are always 255 in 4 or 8 bit screen modes.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 13
clr~&amp; = {{Cl|_RGBA}}(255, 0, 255, 192) 'returns closest palette color attribute
{{Cl|PRINT}} &quot;Color:&quot;; clr~&amp;
{{Cl|COLOR}} clr~&amp;
{{Cl|PRINT}} &quot;Alpha:&quot;; {{Cl|_ALPHA}}(clr~&amp;)
{{Cl|END}}
{{CodeEnd}}
{{OutputStart}}{{text|Color 36|#FFFFFF}}
{{text|Alpha: 255|#FF00FF}}
{{OutputEnd}}
: ''Explanation:'' [[_RGBA]] cannot change the [[_ALPHA]] level. [[_ALPHA32]] would return 0 on any non-32 bit image or page.
''Example 2:'' Finding the transparency of a 32 bit screen mode's background before and after [[CLS]].
{{CodeStart}} '' ''
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
BG&amp; = {{Cl|POINT}}(1, 1)
{{Cl|PRINT}} &quot;Alpha =&quot;; {{Cl|_ALPHA}}(BG&amp;); &quot;Press a key to use CLS!&quot;
K$ = INPUT$(1)
{{Cl|CLS}}
BG&amp; = {{Cl|POINT}}(1, 1)
{{Cl|PRINT}} &quot;CLS Alpha =&quot;; {{Cl|_ALPHA}}(BG&amp;) '' ''
{{CodeEnd}}
{{OutputStart}}CLS Alpha = 255 {{OutputEnd}}
: ''Explanation:'' Set the ALPHA value to 255 using [[CLS]] to make the background opaque when overlaying pages.
{{PageSeeAlso}}
* [[_ALPHA32]], [[_SETALPHA]]
* [[_RGBA]], [[_RGBA32]] {{text|(set color with alpha)}}
* [[_CLEARCOLOR]], [[_CLEARCOLOR (function)]]
* [[_RED]], [[_GREEN]], [[_BLUE]]
* [[_RED32]], [[_GREEN32]]. [[_BLUE32]]
* [[CLS]], [[COLOR]], [[Images]]
{{PageNavigation}}