1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 13:50:36 +00:00

Makes _RGB32 more flexible and powerful.

Existing syntax:
colour~& = _RGB32(red, green, blue)

New possible uses:
- Instead of passing identical rgb values to achieve a shade of gray, pass only 1 parameter for all color components:

    colour~& = _RGB32(51) 'same as _RGB32(51, 51, 51)

- _RGB32 can now take an optional alpha parameter, which makes _RGBA32 obsolete (although it still exists for retrocompatibility):

    colour~& = _RGB32(255, 0, 255, 30) 'same as _RGBA32(255, 0, 255, 30)

- If you want a shade of gray and also to specify the alpha level, you can pass just two parameters:

    colour~& = _RGB32(51, 30) 'same as _RGBA32(51, 51, 51, 30)

In summary:

    - 1 parameter  = red, green and blue simultaneously set.
    - 2 parameters = red, green and blue simultaneously set plus alpha level.
    - 3 parameters = red, green and blue as usual.
    - 4 parameters = red, green and blue plus alpha level (same as _RGBA32).
This commit is contained in:
FellippeHeitor 2018-07-01 21:46:08 -03:00
parent 4264666130
commit 6ee70f1afa
3 changed files with 40 additions and 8 deletions

View file

@ -564,12 +564,15 @@ extern int32 func__font(int32 i,int32 passed);
extern void sub__freefont(int32 f);
extern void sub__printmode(int32 mode,int32 i,int32 passed);
extern int32 func__printmode(int32 i,int32 passed);
extern uint32 func__rgb32(int32 r,int32 g,int32 b);
extern uint32 func__rgba32(int32 r,int32 g,int32 b,int32 a);
extern int32 func__alpha32(uint32 col);
extern int32 func__red32(uint32 col);
extern int32 func__green32(uint32 col);
extern int32 func__blue32(uint32 col);
uint32 func__rgb32(int32 r,int32 g,int32 b,int32 a);
uint32 func__rgb32(int32 r,int32 g,int32 b);
uint32 func__rgb32(int32 i,int32 a);
uint32 func__rgb32(int32 i);
uint32 func__rgba32(int32 r,int32 g,int32 b,int32 a);
int32 func__alpha32(uint32 col);
int32 func__red32(uint32 col);
int32 func__green32(uint32 col);
int32 func__blue32(uint32 col);
extern uint32 matchcol(int32 r,int32 g,int32 b);
extern uint32 matchcol(int32 r,int32 g,int32 b,int32 i);
extern uint32 func__rgb(int32 r,int32 g,int32 b,int32 i,int32 passed);
@ -935,6 +938,18 @@ inline int32 func_sgn(long double v){
}
//Working with 32bit colors:
inline uint32 func__rgb32(int32 r,int32 g,int32 b,int32 a){
if (r<0) r=0;
if (r>255) r=255;
if (g<0) g=0;
if (g>255) g=255;
if (b<0) b=0;
if (b>255) b=255;
if (a<0) a=0;
if (a>255) a=255;
return (a<<24)+(r<<16)+(g<<8)+b;
}
inline uint32 func__rgb32(int32 r,int32 g,int32 b){
if (r<0) r=0;
if (r>255) r=255;
@ -944,6 +959,22 @@ inline uint32 func__rgb32(int32 r,int32 g,int32 b){
if (b>255) b=255;
return (r<<16)+(g<<8)+b|0xFF000000;
}
inline uint32 func__rgb32(int32 i,int32 a){
if (i<0) i=0;
if (i>255) i=255;
if (a<0) a=0;
if (a>255) a=255;
return (a<<24)+(i<<16)+(i<<8)+i;
}
inline uint32 func__rgb32(int32 i){
if (i<0) i=0;
if (i>255) i=255;
return (i<<16)+(i<<8)+i|0xFF000000;
}
inline uint32 func__rgba32(int32 r,int32 g,int32 b,int32 a){
if (r<0) r=0;
if (r>255) r=255;

View file

@ -15680,6 +15680,7 @@ IF LEN(f$) THEN 'special format given
ELSE 'no special format given
IF n$ = "ASC" AND args = 2 THEN GOTO skipargnumchk
IF n$ = "_RGB32" AND (args > 0 AND args <= 4) THEN GOTO skipargnumchk
IF id2.args <> args THEN Give_Error "Incorrect number of arguments passed to function": EXIT FUNCTION
END IF

View file

@ -1331,8 +1331,8 @@ clearid
id.n = "_RGB32"
id.subfunc = 1
id.callname = "func__rgb32"
id.args = 3
id.arg = MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER)
id.args = 4
id.arg = MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER)
id.ret = ULONGTYPE - ISPOINTER
regid