BBC BASIC
« BBCSDL graphics tools New tools: Jan 18 »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 10:44pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: BBCSDL graphics tools New tools: Jan 18  (Read 236 times)
michael
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 157
xx BBCSDL graphics tools New tools: Jan 18
« Thread started on: Jan 18th, 2017, 05:19am »

I decided to make TINT free version of FNbuttonz and other cool tools. There is a pixel tool here also

I had to test with more than one button and had to modify buttonz. If you see any problems with its function please let me know.

I have added more tools and improved FNinput.

The following command is made to line up with a text location and either fill or clear an area for text:

To set the fill color for PROCcleartext:
PROCfcolor("white") -I wanted a white fill color


PROCcleartext(100,1100,500)- x,y,length fill color is set with PROCfcolor and height is automatic for text

PROCfcolor("black")- I want my text to be black

MOVE 100,1100:PRINT "just TYPE A MESSAGE" would line up with the filled area.

PROCfcolor works with numbers 0-15 or words (foreground)

PROCbcolor works with numbers 0-15 or words (background)
Code:
      PROCgraphics(1000,600)      *REFRESH ON      PROCbcolor("white"):PROCfcolor("white")      PROCcleartext(100,1100,500)      PROCsbox(10,10,500,500,"white")      PROCfcolor("black")      MOVE 100,1100:PRINT "just TYPE A MESSAGE"      b$=FNinput(100,1000,50)      *REFRESH ON      REPEAT        a$=FNbuttonz(0,0,"clearitall")        a$=FNbuttonz(510,700,"PRESS THIS BUTTON")        a$=FNbuttonz(510,800,"NO ! PRESS THIS BUTTON")        IF a$="PRESS THIS BUTTON" THEN MOVE 510,900: PROCfcolor("white"):PRINT "YOU DID IT-Program ended":END        IF a$="NO ! PRESS THIS BUTTON" THEN MOVE 510,900: PROCfcolor("white"):PRINT "YOU DID IT-end of program":END        WAIT 10      UNTIL FALSE      END      DEFPROCcleartext(x%,y%,ln%)      RECTANGLE FILL x%-3,y%-25,ln%,35      ENDPROC      DEFFNbuttonz(X,Y,msg$)      LOCAL initialx%,fi%,reduction%,tx,ty,mx%,my%,mb%,ad%,ady%,tc$      PRIVATE st$,c$      IF c$="" THEN c$="cyan"      IF msg$<> "clearitall" THEN        initialx%=LEN(msg$)        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%        MOUSE mx%,my%,mb%        ad%=initialx%+8:ad%+=X:ady%=Y-28        IF mx% >X AND mx%<ad% AND my%<Y+8 AND my%>ady% THEN          tc$="cyan"          IF mb%=4 THEN st$=msg$        ELSE tc$="light white"        ENDIF        IF mx% <X OR mx%>ad% OR my%>Y+8 OR my%<ady% THEN          tc$="light white"        ENDIF        IF c$<>tc$ OR c$="light white" THEN          PROCfcolor(tc$):c$=tc$          FOR fi%=12 TO 48            LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%          NEXT          PROCfcolor("0")          MOVE tx,ty          PRINT msg$        ENDIF      ENDIF      IF msg$="clearitall" THEN st$=""      MOVE 0,0 REM hide that thing      =st$      REM H,V,TEXTLIMIT (simpler?)      DEF FNinput(bx,by,textlimit)      LOCAL fill,MESSAGE$      initialx%=0:sl%=0:key$="":MESSAGE$="":MES$=""      initialx%=textlimit*16.2      FOR fill=8 TO 51        PROCfcolor("15"):LINE bx-3,by+20-fill,bx+initialx%,by+20-fill      NEXT fill      PROCfcolor("0"):LINE bx-3,by+20,bx+initialx%,by+20:LINE bx-3,by+20-fill,bx+initialx%,by+20-fill:      REPEAT        REPEAT          key$ =INKEY$(1)          PROCfcolor("0")          MOVE bx,by:PRINT MESSAGE$;"_" :* REFRESH          sl%=LEN(MESSAGE$)        UNTIL key$ <>""        sl%=LEN(MESSAGE$)        IF INKEY(-48) sl%=LEN(MESSAGE$)-1:key$=""        REPEAT UNTIL INKEY(0)=-1        IF sl%<LEN(MESSAGE$) THEN          PROCfcolor("15")          MOVE bx,by          PRINT MESSAGE$;"_"        ENDIF        MES$=MID$(MESSAGE$,0,sl%)        MESSAGE$=MES$        PROCfcolor("15"):MOVE bx,by:PRINT MESSAGE$;"_"        IF LEN(key$) = 1 THEN          IF LEN(MESSAGE$)<textlimit THEN PROCfcolor("15"):MOVE bx,by:PRINT MESSAGE$;"_": MESSAGE$=MESSAGE$+key$:* REFRESH OFF          REM (jump)        ENDIF      UNTIL INKEY(-74)      * REFRESH ON      =MESSAGE$      REM SBOX **********************      DEF PROCsbox(x%,y%,w%,h%,c$)      LOCAL ry%,sx%,sy%      sx%=x%:sy%=y%      IF x%>w% THEN x%=w%:w%=sx%      IF y%>h% THEN y%=h%:h%=sy%      ry%=y%      PROCfcolor(c$)      REPEAT        LINE x%,y%,w%,y%        y%=y%+1      UNTIL y%=h%      y%=ry%      IF c$<>"0" THEN PROCfcolor("black") ELSE PROCfcolor("white")      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 RECT **********************      DEFPROCrect(x%,y%,w%,h%)      LOCAL sx%,sy%      sx%=x%:sy%=y%      IF x%>w% THEN x%=w%:w%=sx%      IF y%>h% THEN y%=h%:h%=sy%      LINE x%,y%,w%,y%      LINE w%,y%,w%,h%      LINE w%,h%,x%,h%      LINE x%,h%,x%,y%      ENDPROC      REM pixel *******************      DEFPROCpixel(x%,y%,c$)      PROCfcolor(c$)      MOVE x%,y%:DRAW x%,y%      ENDPROC      DEF PROCgraphics(x,y)      VDU 23,22,x;y;8,15,16,1      OFF      VDU 5      ENDPROC      DEFFNstcorecol(wdnum$)      LOCAL tcol%      CASE wdnum$ OF        WHEN "0","black" :tcol%=0        WHEN "1","red" :tcol%=1        WHEN "2","green" :tcol%=2        WHEN "3","yellow" :tcol%=3        WHEN "4","blue" :tcol%=4        WHEN "5","magneta" :tcol%=5        WHEN "6","cyan":tcol%=6        WHEN "7","white":tcol%=7        WHEN "8","grey":tcol%=8        WHEN "9","light red":tcol%=9        WHEN "10","light green":tcol%=10        WHEN "11","light yellow":tcol%=11        WHEN "12","light blue":tcol%=12        WHEN "13","light magneta":tcol%=13        WHEN "14","light cyan":tcol%=14        WHEN "15","light white" :tcol%=15      ENDCASE      =tcol%      DEF PROCfcolor(co$)      LOCAL rcol%      rcol%=FNstcorecol(co$)      GCOL rcol%      ENDPROC      DEF PROCbcolor(co$)      LOCAL rcol%      rcol%=FNstcorecol(co$)      GCOL 128 +rcol%      ENDPROC 
« Last Edit: Jan 19th, 2017, 03:39am by michael » User IP Logged

I like reinventing the wheel, but for now I will work on tools for D3D
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