BBC BASIC for Windows
Programming >> Graphics and Games >> POINT and TINT and conversion to RGB
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1459110809

POINT and TINT and conversion to RGB
Post by michael on Mar 27th, 2016, 8:33pm

Check out this example code for:
0) POINT color extraction (for normal colors)
1) TINT color extraction for normal colors
2) custom foreground color creation
3) TINT color extraction for rgb% variable
4) conversion of the LONG rgb% to 3 variables r , g , b

http://bbcbasic.conforums.com/index.cgi?board=language&action=display&num=1459110560

Oh and this is a link to the other BBC Basic board. Richard is moderating it. Have a visit and check out his posts. He would be happy to hear from you !. Check out the board as well as this one..
Re: POINT and TINT and conversion to RGB
Post by RockOve on May 19th, 2016, 11:40pm

hey.Her is my sulotion TINT to R G B version:
Code:
      dim calc(5)
      x%=0:y%=0
      colour 1,255,128,64
      gcol 1
      circle fill x%,y%,100
      :
      r=tint(x%,y%):rem geting the rgb% total
      :
      calc(1)= int((r/&10000)):rem blue
      calc(2)= r-(int((r/&10000))*&10000)
      calc(3)=int(calc(2)/&100):rem green
      calc(4)=calc(3)*&100
      calc(5)=calc(2)-calc(4):rem red
      red%=calc(5)
      green%=calc(3)
      blue%=calc(1)
      :
      print red%,green%,blue%
 

Re: POINT and TINT and conversion to RGB
Post by David Williams on May 20th, 2016, 01:59am

on Mar 27th, 2016, 8:33pm, michael wrote:
Check out this example code for:
0) POINT color extraction (for normal colors)
1) TINT color extraction for normal colors
2) custom foreground color creation
3) TINT color extraction for rgb% variable
4) conversion of the LONG rgb% to 3 variables r , g , b


Yes, I almost always use something very close to Richard's suggestion. It's very efficient:

Code:
      rgb% = TINT(x,y)

      r% = rgb% AND &FF
      g% = (rgb% AND &FF00) >> 8
      b% = (rgb% AND &FF0000) >> 16
 



And to pack the separate RGB colour components back into a 32-bit integer variable, you could use (assuming r%, g% and b% are each in the range 0 to 255):

Code:
      rgb% = r% OR (&100*g%) OR (&10000*b%)
 


or

Code:
      rgb% = r% OR g% << 8 OR b% << 16
 



David.
--
Re: POINT and TINT and conversion to RGB
Post by RockOve on May 20th, 2016, 05:41am

nice! tnx! :-D