BBC BASIC for Windows
« POINT and TINT and conversion to RGB »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:19pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: POINT and TINT and conversion to RGB  (Read 436 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
cheesy POINT and TINT and conversion to RGB
« Thread started 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..
« Last Edit: Mar 27th, 2016, 8:36pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
RockOve
New Member
Image


member is offline

Avatar




PM


Posts: 7
cheesy Re: POINT and TINT and conversion to RGB
« Reply #1 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%
 
User IP Logged

David Williams
Developer

member is offline

Avatar

meh


PM

Gender: Male
Posts: 452
cheesy Re: POINT and TINT and conversion to RGB
« Reply #2 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.
--
User IP Logged

RockOve
New Member
Image


member is offline

Avatar




PM


Posts: 7
cheesy Re: POINT and TINT and conversion to RGB
« Reply #3 on: May 20th, 2016, 05:41am »

nice! tnx! :-D
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls