#106490 - 2003-11-03 02:38 PM
Re: Mini-putt for a slow day on korg ...
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
code:
Break ON Dim $, $c, $x $= "&00FFFF" for $x=2 to 6 step 2 $rc = execute("$$c = &"+ substr($,$x,2)) ? $c next
exit 0
|
|
Top
|
|
|
|
#106491 - 2003-11-03 02:52 PM
Re: Mini-putt for a slow day on korg ...
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
ok, ok - you made it look too easy - let me give you entire spec ...
This is going to be used in a FadeToBlack() UDF ... FadeToBlack() takes a number (a hex number) in the BBGGRR format above, and a second parameter called "level" that is a number from 0 to 255 (0 to FF) ... you call it like this:
$color = FadeToBlack($color, 200)
Here's what FadeToBlack should do. Compare each color component (0-FF) with "level" ... if the color component is less than level, leave it alone. If the color component is equal to or greater than level - set the color component to equal level. Then "reassemble" the color components back into a BBGGRR color, for example:
$color = &00DDFF $color = FadeToBlack($color, &EE)
color should now be: &00DDEE. Then when you call it again, using the new value of color and a new value for level,
$color = &00DDEE $color = FadeToBlack($color, &DD)
color should now be &00DDDD
and again:
$color = &00DDDD $color = FadeToBlack($color, &CC)
color will be &00CCCC and so on and so on. The level parm will always be a value from 0 to FF (255) ... under no circumstances should a negative BBGGRR color be returned ...
|
|
Top
|
|
|
|
#106495 - 2003-11-03 03:41 PM
Re: Mini-putt for a slow day on korg ...
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
code:
function FadeToBlack($color, $level)
Dim $B, $G, $R $B=$color/65536 $G=($color mod 65536)/256 $R=$color-($B*65536)-($G*256) $B = IIF($B<$level), $B, $B-17) $G = IIF($G<$level), $G, $G-17) $R = IIF($R<$level), $R, $R-17)
$B = IIF($B<0), 0, $B) $G = IIF($G<0), 0, $G) $R = IIF($R<0), 0, $R) return ($B*65536)+($G*256)+$R
endfunction
|
|
Top
|
|
|
|
#106500 - 2003-11-03 04:08 PM
Re: Mini-putt for a slow day on korg ...
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Howards submission has some mis-matched parens and doesn't return the number, but when patched, returns the wrong number - but close:
code:
function FadeToBlack($color, $level)
Dim $B, $G, $R
$B=$color/65536 $G=($color mod 65536)/256 $R=$color-($B*65536)-($G*256) $B = IIF($B<$level, $B, $B-17) $G = IIF($G<$level, $G, $G-17) $R = IIF($R<$level, $R, $R-17)
$B = IIF($B<0, 0, $B) $G = IIF($G<0, 0, $G) $R = IIF($R<0, 0, $R) $fadeToBlack = ($B*65536)+($G*256)+$R
endfunction
$c = fadeToBlack(&00DDFF,&DD)
?"value=" DecToHex($c)
returned value is CCEE, should be &00DDDD
-Shawn
|
|
Top
|
|
|
|
#106504 - 2003-11-03 04:21 PM
Re: Mini-putt for a slow day on korg ...
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
shawn, you changed the rules. first you gave input of string and now you give hex. try to make up your mind!
doing simple test run:
code:
$in= "&00FFFF" val($in) ? $level function fadetoblack($i,$l) Dim $, $c, $x $l=right($l,2) for $x=1 to 3 $c=substr($i,$x*2,2) $=$+iif($l>$c,$c,$l) next $fadetoblack=val("&"+$) endfunction fadetoblack( "&00FFFF","&DD")
get $
gives correct results.
_________________________
!download KiXnet
|
|
Top
|
|
|
|
#106505 - 2003-11-03 04:23 PM
Re: Mini-putt for a slow day on korg ...
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Slow on the draw there Lonkero. Saw that immediately thus my approach.
|
|
Top
|
|
|
|
#106506 - 2003-11-03 04:25 PM
Re: Mini-putt for a slow day on korg ...
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
where did I say that FadeToBlack took a string ? said it took a number in the BBGGRR format. Check-out the examples in the long-winded specification.
jochen - in a way, you have already seen this game - about 3 years ago in the BGI days ![[Wink]](images/icons/wink.gif) [ 03. November 2003, 16:27: Message edited by: Shawn ]
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 601 anonymous users online.
|
|
|