BBC BASIC for Windows
IDE and Compiler >> Tools and Utilities >> Tool Color management in action. Better tools
http://bb4w.conforums.com/index.cgi?board=addins&action=display&num=1463886752

Tool Color management in action. Better tools
Post by michael on May 22nd, 2016, 03:12am

These functions are specific for managing the colours for the tools I have created. (its not for screen colors, although I may modify my PROCcolor so that it works with native 16 color or a rgb value.. So switching back and forth is easy as apple pie!!

I extracted the colors from the core 16 colors, so now you should have 0-15 or colors like red or you can use RGB values like 010200100 -which is 10,200,100
examples:
dv$=FNrgb("background","blue"):REM make tool background a shade of blue

dv$=FNrgb("border","255255255"):REM make the border a shade of white (9 digits 255,255,255- R,G,B
'The simplebox command":
sbox(x,y,h,v)
I tested what you see. If you find any color issues, let me know..
I will use this method to create the new version of PROCcolor("f or b","color")
which should eliminate any conflicts and allow you to use colors like 0-15 or an RGB value or a word like red
Code:
      REM       width;height;charwidth,charheight,number of colors,character set
      VDU 23,22,1024;600;8,15,16,1
      REM Turn off the text cursor _
      OFF:VDU 5 : REM Treat text as graphics (transparent background)
      REM block(x,y,h,v) 
      REM *****************************************************************************************************
      REM "type",rrrgggbbb -so if rgb is 0,100,0 then you would type 000100000 (makes it easy to port the values)
      REM so each value must be a 3 digit value, even if it is 0 or 10 or 25 or 255
      REM dv$ is just a dummy string
      dv$=FNrgb("background","blue"):REM make tool background a shade of blue
      dv$=FNrgb("border","green"):REM make the border a shade of green
      PROCsbox(100,100,500,500)
      dv$=FNrgb("background","yellow"):REM make tool background a shade of green
      dv$=FNrgb("border","255255255"):REM make the border a shade of green
      PROCsbox(800,800,500,500)
      dv$=FNrgb("background","100000100"):REM make tool background a shade of purple
      dv$=FNrgb("border","255255100")
      PROCsbox(0,1000,500,500)
      dv$=FNrgb("text","200000000"):REM make the tool text red
      dv$=FNrgb("textbackground","white"):REM make the text background a shade of white
      REM pr(x,y,"message",R 0-255,G 0-255,B 0-255)
      PROCpr(120,450,"I put a box here")
      dv$=FNrgb("text","000000000"):REM make the tool text black
      dv$=FNrgb("textbackground","light white"):REM make the text background a shade of white
      PROCpr(550,550,"here also")
      WAIT 0
      END
      REM this was created to manage special colors and to hold onto the original first 2 pallets (as I use them all the time)
      DEF FNrgb(target$,rgb$)
 IF rgb$="0" OR rgb$="black" THEN rgb$="000000000"
     IF rgb$="1" OR rgb$="red" THEN rgb$="200000000"
      IF rgb$="2" OR rgb$="green" THEN rgb$="000200000"
      IF rgb$="3" OR rgb$="yellow" THEN rgb$="200200000"
      IF rgb$="4" OR rgb$="blue" THEN rgb$="000000200"
      IF rgb$="5" OR rgb$="magneta" THEN rgb$="200000200"
      IF rgb$="6" OR rgb$="cyan" THEN rgb$="000200200"
      IF rgb$="7" OR rgb$="white" THEN rgb$="200200200"
      IF rgb$="8" OR rgb$="grey" THEN rgb$="056056056"
      IF rgb$="9" OR rgb$="light red" THEN rgb$="248056056"
      IF rgb$="10" OR rgb$="light green" THEN rgb$="056248056"
      IF rgb$="11" OR rgb$="light yellow" THEN rgb$="248248056"
      IF rgb$="12" OR rgb$="light blue" THEN rgb$="056056248"
      IF rgb$="13" OR rgb$="light magnetta" THEN rgb$="248056248"
      IF rgb$="14" OR rgb$="light cyan" THEN rgb$="056248248"
      IF rgb$="15" OR rgb$="light white" THEN rgb$="248248248"
      PRIVATE assemble$,text$,textbackground$,border$,background$
      assemble$=rgb$
      IF target$="text" THEN text$=assemble$
      IF target$="textbackground" THEN textbackground$=assemble$
      IF target$="border" THEN border$=assemble$
      IF target$="background" THEN background$=assemble$
      IF target$="gettext" THEN assemble$=text$
      IF target$="gettextbackground" THEN assemble$=textbackground$
      IF target$="getborder" THEN assemble$=border$
      IF target$="getbackground" THEN assemble$=background$
      =assemble$
      ENDPROC
      DEF PROCsbox(x%,y%,w%,h%)
      LOCAL ry%,sx%,sy%,back$,border$
      sx%=x%:sy%=y%
      LOCAL br%,bg%,bb%
      LOCAL bdr%,bdg%,bdb%,back$,border$
      back$=FNrgb("getbackground","")
      border$=FNrgb("getborder","")
      br%=VAL(MID$(back$,1,3)):bg%=VAL(MID$(back$,4,3)):bb%=VAL(MID$(back$,7,3))
      bdr%=VAL(MID$(border$,1,3)):bdg%=VAL(MID$(border$,4,3)):bdb%=VAL(MID$(border$,7,3))
      IF x%>w% THEN x%=w%:w%=sx%
      IF y%>h% THEN y%=h%:h%=sy%
      ry%=y%
      PROCcolor("f",br%,bg%,bb%)
      REPEAT
        LINE x%,y%,w%,y%
        y%=y%+1
      UNTIL y%=h%
      y%=ry%
      PROCcolor("f",bdr%,bdg%,bdb%)
      LINE x%+2,y%+2,w%-2,y%+2
      LINE w%-2,y%+2,w%-2,h%-4
      LINE w%-2,h%-4,x%+2,h%-4
      LINE x%+2,h%-4,x%+2,y%+2
      ENDPROC
      REM color "F"or"B", r,g,b
      DEF PROCcolor(fb$,r%,g%,b%)
      IF fb$="f" OR fb$="F" THEN COLOUR 0,r%,g%,b% : GCOL 0
      IF fb$="b" OR fb$="B" THEN COLOUR 1,r%,g%,b% : GCOL 128+1
      ENDPROC
      REM X,Y,text color,message,r,g,b
      REM ************************************************************************
      DEF PROCpr(x%,y%,msg$)
      LOCAL initialx%,fi%,reduction%,tx,ty
      initialx%=LEN(msg$)
      REM copy/pasted/modified for this tool
      LOCAL br%,bg%,bb%
      LOCAL bdr%,bdg%,bdb%,back$,border$
      back$=FNrgb("gettextbackground","")
      border$=FNrgb("gettext","")
      br%=VAL(MID$(back$,1,3)):bg%=VAL(MID$(back$,4,3)):bb%=VAL(MID$(back$,7,3))
      bdr%=VAL(MID$(border$,1,3)):bdg%=VAL(MID$(border$,4,3)):bdb%=VAL(MID$(border$,7,3))
      COLOUR 0,br%,bg%,bb%
      GCOL 0
      LET tx= x%+initialx%+25
      LET ty= y%:reduction%=0
      reduction%=initialx%/2
      reduction%=reduction%*6
      IF initialx%<20 THEN reduction%=reduction%/2
      initialx%=initialx%*22-reduction%
      FOR fi%=12 TO 48
        LINE x%-3,y%+20-fi%,x%+initialx%+8,y%+20-fi%
      NEXT
      COLOUR 0,bdr%,bdg%,bdb%
      GCOL 0
      MOVE tx,ty
      PRINT msg$
      MOVE 0,0 REM hide that thing
      ENDPROC

 
#