BBC BASIC for Windows
Programming >> Graphics and Games >> Custom Button maker with BMP file creation!!
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1458009418

Custom Button maker with BMP file creation!!
Post by michael on Mar 15th, 2016, 02:36am

Thanks for the help.
I have sourced some offered code and modified it so the BMP image file name and the button creation can be done in one command.. It automatically adjusts the BMP image for the button and saves it..
Although I do want to make the perfect buttons and this one is just made quick for a sample... Its just a basic one with a decent color and depth

I figured the object creation should be in a separate utility to reduce the code size in a program...
BUT
I could make this into a library function and then it would be a neat instant button creation tool.

If you see anything I am doing wrong please let me know.
I removed any code that was irrelevant to the program,

The ways I use variables is still the same, but I plan to change my learned ways so they are correctly done.. (not quite yet...LOL)
Code:
     
      REM SET MODE TO 8 USING VDU
      VDU 22,8
      REM SET LINE THICKNESS TO 3
      VDU 23,23,3|
      REM OFF
      GCOL 1

      REM create and save button images------------------------------------

      REM**********(Filename,H,V,BEGIN,SIZE,R,G,B,Dimmer)    Dont use .BMP as it is automatically added in PROC
      PROC_button("Mybuttonimage",500,500,15,30,200,185,200,15)
      REM The colors will be hard to adjust as you have no tool to customize the colors (YET) -its coming
      REM its really trial and error with the dimmer setting, and RGB settings.. (too much value gap can make your button look odd)
      REM MAIN --------------------------------
      (mou)
      WAIT 0 : REM just wait, nothing to do !
      GOTO (mou)

      DEF PROC_button(filename$,H,V,BEGIN,SIZE,X,C,A,DI)
      filename$=filename$+".BMP"
      R=X
      G=C
      B=A
      P=SIZE-BEGIN
      P=P/2
      P=BEGIN+P
      FOR Y=P TO SIZE
        COLOUR 1,X,C,A
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X-DI
        C=C-DI
        A=A-DI
        IF X<2 THEN X=2
        IF C<2 THEN C=2
        IF A<2 THEN A=2
      NEXT Y
      FOR Y=BEGIN TO P
        COLOUR 1,X,C,A
        LINE H-Y,V-Y,H+Y,V-Y
        LINE H+Y,V-Y,H+Y,V+Y
        LINE H+Y,V+Y,H-Y,V+Y
        LINE H-Y,V+Y,H-Y,V-Y
        X=X+DI
        C=C+DI
        A=A+DI
      NEXT Y
      COLOUR 1,R,G,B
      FILL H,V
      REM I hope I dont burn out any brain cells with this solution...LOL
      file1$=@usr$+ filename$
      h$=STR$(H-SIZE-5)
      v$=STR$(V-SIZE-5)
      size$=STR$(SIZE*2+10)
      combinit$=h$+","+v$+","+size$+","+size$
      pos1$=combinit$
      OSCLI "SCREENSAVE "+file1$+" "+pos1$

      ENDPROC
 
;D