Gradiance V3

Post Reply
User avatar
rbytes
Posts: 1794
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Gradiance V3

Post by rbytes » Fri Jul 20, 2018 8:20 pm

This is the first version I have posted of my full-screen gradient maker called "Gradiance".
Because it requires several support files, I have posted it as a Dropbox folder containing other folders. If you download that and install it, it will work on the first try.

The LOAD button is not active yet, but I wanted to fit it into the interface now.

Here is the link: https://www.dropbox.com/sh/dssgclacgz1p ... FZOla?dl=0

Below see the program code and some sample screenshots.

Code: Select all

/*Gradiance V3
by rbytes July 2018
creates gradients, with many options

V3 Added gamma slider, new HSV to RGB converter, file requester, multi-device compatibility
   Note - the Load button was added but its function is not yet coded
   Note - a custom top toolbar subroutine was added, but its function is not yet coded
V2 Added buttons to set multiple gradient directions, sliders for variable saturation & brightness
V1 The original program, horizontal gradients, full saturation and brightness, iPad only
*/
'c'
'*** initialize
SET ORIENTATION LANDSCAPE
set buttons custom
set toolbar off
option sprite pos central
laun$=LAUNCHER$ ()
dev$=DEVICE_TYPE$()
N$="gradiance.jpg"
maxx = SCREEN_WIDTH()!sw=maxx
maxy = SCREEN_HEIGHT()!sh=maxy
iostest=0
IF iostest THEN
  sw=568!maxx=sw
  sh=320!maxy=sh
  dev$=""
ENDIF
rw=sw/1024!rh=sh/768
if rw<1 then corr2=25*rh else corr2=0     '*** slider vertical correction
path2$="Gradiance/System/"
GRAPHICS
Graphics clear
draw image path2$&"gradiance.jpg" at 0,0 scale rw,rh
draw font name "Avenir-Black"
draw font size 40*rw
NM$="GRADIANCE"
draw text "GRADIANCE" at maxx/2-TEXT_WIDTH(NM$)/2,95*rh
draw color 0,0,0

'*** load frames and display animated title
sprite "warp" load path2$&"grad220.png"
for t=221 to 235
  t$=t
  sprite "temp"&t$ load path2$&"grad"&t$&".png"
  sprite "warp" add "temp"&t$
next t
sprite "warp" at 4+maxx/2,120*rh scale .4 *rw
sprite "warp" show
sprite "warp" delay .02
sprite "warp" loop

'*** create interface
SLIDER "hue" VALUE 0 AT 220*rw,460*rh-corr2 SIZE 700*rw
SLIDER "range" VALUE .25 AT 220*rw,500*rh-corr2 SIZE 700*rw
SLIDER "sat" VALUE 1 AT 220*rw,540*rh-corr2 SIZE 700*rw
SLIDER "brt" VALUE 1 AT 220*rw,580*rh-corr2 SIZE 700*rw
SLIDER "gam" VALUE .5 AT 220*rw,620*rh-corr2 SIZE 700*rw

'*** black font color (shadow) text fields
field "hue" text "HUE" at 122*rw,457*rh size 80*rw, 40*rh RO
field "hue" back alpha 0
field "hue" font size 18*rw
field "hue" font color 0,0,0
field "range" text "RANGE" at 122*rw,497*rh size 80*rw, 40*rh RO
field "range" back alpha 0
field "range" font size 18*rw
field "range" font color 0,0,0
field "sat" text "SAT" at 122 *rw,537*rh size 80*rw, 40*rh RO
field "sat" back alpha 0
field "sat" font size 18*rw
field "sat" font color 0,0,0
field "brt" text "BRT" at 122*rw,577*rh size 80*rw, 40*rh RO
field "brt" back alpha 0
field "brt" font size 18*rw
field "brt" font color 0,0,0
field "gam" text "GAM" at 122*rw,617*rh size 80*rw, 40*rh RO
field "gam" back alpha 0
field "gam" font size 18*rw
field "gam" font color 0,0,0

'*** white font color text fields
field "hue2" text "HUE" at 120*rw,455*rh size 80*rw, 40*rh RO
field "hue2" back alpha 0
field "hue2" font size 18*rw
field "hue2" font color 1,1,1
field "range2" text "RANGE" at 120*rw,495*rh size 80*rw, 40*rh RO
field "range2" back alpha 0
field "range2" font size 18 *rw
field "range2" font color 1,1,1
field "sat2" text "SAT" at 120 *rw,535 *rh size 80*rw, 40*rh RO
field "sat2" back alpha 0
field "sat2" font size 18 *rw
field "sat2" font color 1,1,1
field "brt2" text "BRT" at 120 *rw,575*rh size 80*rw, 40*rh RO
field "brt2" back alpha 0
field "brt2" font size 18 *rw
field "brt2" font color 1,1,1
field "gam2" text "GAM" at 120*rw,615*rh size 80*rw, 40*rh RO
field "gam2" back alpha 0
field "gam2" font size 18 *rw
field "gam2" font color 1,1,1

'*** buttons
SET BUTTONS FONT SIZE 20*rw
Button "new" text "NEW" at 110*rw,690*rh size 100*rw,40*rw
Button "start" text "START" at 230*rw,690*rh size 100*rw,40*rw
Button "dir" text "LEFT" at 350*rw,690*rh size 100*rw,40*rw
Button "ang" text "VERT" at 470*rw,690*rh size 100*rw,40*rw
Button "load" text "LOAD" at 590*rw,690*rh size 100*rw,40*rw
Button "save" text "SAVE" at 710*rw,690*rh size 100*rw,40*rw
Button "stop" text "STOP" at 830*rw,690*rh size 100*rw,40*rw

'*** initialize values
hue=0
range=.5
sat=1
brt=1
gam=.5
dirs=1!dir=0
ang=0!angs=0

'*** start of program loop
commence:

do   
  if bp("stop") then stopper
  if bp("save") then saveit
  if bp("dir") then
    dirs=1
    angs=0
    dir=1-dir
    if dir then
      Button "dir" text "RIGHT"   '*** gradient angles downward to the right
    else
      Button "dir" text "LEFT"    '*** gradient angles downward to the left
    endif
  endif
  if bp("ang") then
    angs=1
    dirs=0
    ang=1-ang
    if ang then
      Button "ang" text "HORZ"    '*** horizontal gradient
    else
      Button "ang" text "VERT"    '*** vertical gradient
    endif
  endif
  if slider_changed("hue") then hue=slider_value("hue")
  if slider_changed("range") then range=.1+slider_value("range")*2
  if slider_changed("sat") then sat=slider_value("sat")
  if slider_changed("brt") then brt=slider_value("brt")
  if slider_changed("gam") then gam=slider_value("gam")
  SLOWDOWN
until bp("start")
graphics clear
sprite "warp" hide

'r'
'*** draw the gradient
'*** NOTE: the LEFT and RIGHT gradients are much slower to draw, because every point has a slightly different color.
'*** The HORZ and VERT gradients draw almost instantly, because each line has a constant color.
FOR y=0 TO maxy
  g=y/maxy
  FOR x=0 TO maxx
    if dirs then
      if dir=0 then
        h=hue+range*(x/maxx+y/maxy)     '*** gradient direction - downward to the left
      else
        h=hue+range*(x/maxx+1-y/maxy)   '*** gradient direction - downward to the right
      endif
    endif
    if angs then
      if ang=0 then
        h=hue+range*(y/maxx)            '*** gradient direction - vertical
      else
        h=hue+range*(x/maxx)            '*** gradient direction - horizontal
      endif
    endif
    pal(h,sat,1,brt,gam)
    r=pal.r!g=pal.g!b=pal.b
    draw COLOR r,g,b
    if angs then
      if ang then
        draw line x,0 to x,sh
      else
        draw line 0,y to sw,y
        x=maxx
      endif
    else
      DRAW line x-1,y-1 to x,y
    endif
  NEXT x
  if angs and ang then y=maxy
  if SLIDER_CHANGED("hue") then
    hue=SLIDER_VALUE("hue")
    goto commence
  ENDIF
  if SLIDER_CHANGED("range") then
    range=SLIDER_VALUE("range")
    goto commence
  ENDIF
  if SLIDER_CHANGED("sat") then
    sat=SLIDER_VALUE("sat")
    goto commence
  ENDIF
  if SLIDER_CHANGED("brt") then
    brt=SLIDER_VALUE("brt")
    goto commence
  ENDIF
  if bp("stop") then end
  if bp("new") then commence
NEXT y
''
DO
  SLOWDOWN   
  if bp("stop") then
    stopper:
    IF laun$="desktop" THEN
      IF FILE_EXISTS("/launch") THEN
        RUN "/-Launch.sb"
      ELSE
        EXIT
      ENDIF
    ENDIF
    END
  endif
  if bp("dir") then
    dirs=1
    angs=0
    dir=1-dir
    if dir then
      Button "dir" text "RIGHT"   '*** gradient angles downward to the right
    else
      Button "dir" text "LEFT"    '*** gradient angles downward to the left
    endif
  endif
  if bp("ang") then
    angs=1
    dirs=0
    ang=1-ang
    if ang then
      Button "ang" text "HORZ"    '*** horizontal gradient
    else
      Button "ang" text "VERT"    '*** vertical gradient
    endif
  endif
  if bp("new") then
    graphics clear
    goto commence
  endif
  if sc("hue") then hue=slider_value("hue")
  if sc("range") then range=.1+slider_value("range")*2
  if sc("sat") then sat=slider_value("sat")
  if sc("brt") then brt=slider_value("brt")
  if sc("gam") then gam=slider_value("gam")
  IF bp("save") THEN
    saveit:
    refresh on
    SPRITE "temp" SCAN 0,0,sw,sh
    GRAPHICS CLEAR .5,.5,.5
    path$="Gradiance/"
    corr=50*rh ' corrects an unwanted horizontal shift in toolbar
    F$=file_select$(350*rw,20*rh,220*rw,254*rh,2,path$)
    sprite "temp" at sw/2,sh/2
    if F$<>"" then
      sprite "temp" save F$
      DRAW FONT SIZE 40*.rw
      DRAW TEXT "SAVING" AT sw/2-TEXT_WIDTH("SAVING")/2+10*rw, sh/2
      pause 2
    endif
    draw image "gradiance.jpg" at 0,0 scale rw,rh
    draw color 1,1,1
    draw text "GRADIANCE" at maxx/2-TEXT_WIDTH(NM$)/2,95*rh
    page "" set
    page "" show
    goto commence
  ENDIF
UNTIL 0
end

'r' ===== Combined Palette functions, Henko and Dutchman, by rbytes
DEF Pal(Tint,SATURATION,Brighten,Intensity,Gamma)
' ---- adjust parameter values between zero and 1.
h=tint*360
tint%=1
Sat=ABS(SATURATION)
IF Sat>1 THEN Sat%=1
Intensity=ABS(Intensity) 
IF Intensity>1 THEN Intensity%=1
Brighten=ABS(Brighten)
IF Brighten>1 THEN Brighten%=1
r=0 ! g=0 ! b=0 ! h%=360
IF h<120 OR h>240 THEN r=palsub(ABS(h-360*FLOOR(h/240)),Gamma)
IF h<240 THEN g=palsub(ABS(h-120),Gamma)
IF h>120 THEN b=palsub(ABS(h-240),Gamma)
Sat: ' with constant luminance
' ---- apply Saturation and Brighten
IF Sat<1 THEN
  Y=0.3*R+0.59*G+0.11*B
  U=B-Y ! U*=sat
  V=R-Y ! v*=sat
  W=G-Y ! w*=sat
  R=Y+V ! G=Y+W ! B=Y+U
  IF Brighten<>0 THEN
    Ysup=1-MAX(MAX(R,G),B)' max white to add
    Ysup*=Brighten
    R+=Ysup ! G+=Ysup ! B+=Ysup
  ENDIF
ENDIF
' ---- apply Intensity
IF Intensity<1 THEN
  R*=Intensity
  G*=Intensity
  B*=Intensity
ENDIF
Y=0.3*R+0.59*G+0.11*B
END DEF ' Pal
DEF palsub(e,Gamma)
f=Gamma   ' 0<=f<=1 better balance between primary and secondary colors
IF e<60 THEN c=1 ELSE ! x=(120-e)/60 ! c=x*(1+f-f*x) ! END IF
RETURN c
END DEF

''
DEF bp(a$) = BUTTON_PRESSED(a$)
DEF sc(a$) = SLIDER_CHANGED(a$)

'b'
' file browser/selector            Original code by Henko, modified by rbytes
' returns selected file with path

DEF file_select$(xtop,ytop,wid,hgt,type,path$)
OPTION BASE 1
PAGE "freq" set
page "freq" show
page "" hide
'type = 1 for load, 2 for save
maxdim=500 ! SET LISTS CUSTOM
trans=0
DIM directs$(maxdim),FILES$(maxdim), combi$(2*maxdim)
FILL COLOR 1,1,1 ! DRAW COLOR 0,0,0
sw=.sw ! sh=.sh
rw=.rw ! rh=.rh
wid=320*rw
headspace=50*rw
set lists font size 18*rw
IF type=1 THEN
  fb$="Select file"&CHR$(10)&CHR$(10)&"Click OK to load it"&CHR$(10)&CHR$(10)&"Or RENAME or DELETE it"&CHR$(10)&CHR$(10)&"Click CANCEL to escape"
ELSE
  fb$="Select or name file"&CHR$(10)&CHR$(10)&"Click OK to save it"&CHR$(10)&CHR$(10)&"Or RENAME or DELETE it"&CHR$(10)&CHR$(10)&"Click CANCEL to escape"
ENDIF
IF xtop+wid>sw-10 THEN xtop=sw-wid-10 ! xbot=xtop+wid
IF ytop+hgt>sh-10 THEN ytop=sh-hgt-10 ! ybot=ytop+hgt*1.6
SPRITE "fbrow" SCAN xtop-2,ytop-2,wid+4,hgt+4
DRAW SIZE 3 !FILL RECT xtop,ytop TO xbot,ybot*.8
DRAW RECT xtop,ytop TO xbot,ybot*.8
DRAW LINE xtop,ytop*6 TO xbot,ytop*6
DRAW FONT SIZE 22*.rw
DRAW COLOR 0,0,0
DRAW TEXT title$ AT sw*.18,ytop+sh*.116
DRAW TEXT title2$ AT sw*.18,ytop+sh*.166
DRAW TEXT title3$ AT sw*.18,ytop+sh*.216
FIELD "namer" TEXT "" AT xtop+wid*.05,ytop+hgt*1 SIZE wid*.87,hgt*.18
FIELD "namer" FONT SIZE 20*.rw
FIELD "namer" FONT NAME "Arial-BoldMT"
IF fil$="" THEN fil$=.backfil$
FIELD "namer" TEXT fil$
procnam$=fil$
FIELD "feedback" TEXT fb$ AT xtop*.4,ytop*1.6 SIZE sw*.16+2,sh*.408 RO ML
DRAW RECT xtop*.4-2,ytop*1.6-2 TO xtop*.4+sw*.16+3,ytop+hgt*.35+sh*.31
FIELD "feedback" FONT SIZE 20*.rw
FIELD "filter" TEXT "filter" AT xtop*2.005,ytop+hgt*.08 SIZE sw*.216,sh*.05
FIELD "filter" FONT SIZE 20*.rw
BUTTON "cancel" title "CANCEL" AT xtop*2,ytop+hgt*.8 SIZE sw*.1,sh*.07
BUTTON "ok" title "OK" AT xtop*2,ytop+hgt*1.05 SIZE sw*.1,sh*.07
BUTTON "back" title "BACK" AT xtop*2,ytop+hgt*.55 SIZE sw*.1,sh*.07
BUTTON "root" title "ROOT" AT xtop*2,ytop+hgt*.3 SIZE sw*.1,sh*.07
BUTTON "+dir" title "+ DIR" AT xtop*2.34,ytop+hgt*1.05 SIZE sw*.1,sh*.07
BUTTON "-dir" title "- DIR" AT xtop*2.34,ytop+hgt*.8 SIZE sw*.1,sh*.07
BUTTON "rename" title "RENAME" AT xtop*2.34,ytop+hgt*.3 SIZE sw*.1,sh*.07
BUTTON "del" title "DELETE" AT xtop*2.34,ytop+hgt*.55 SIZE sw*.1,sh*.07
FILL COLOR 1,.5,.5
set buttons font size 18*rw
FILL COLOR 1,1,1
DRAW ALPHA 1
FILL ALPHA 0
BUTTON "clrfld" TEXT CHR$(8855) AT xtop*1.77,ytop+hgt*1.02
DRAW ALPHA 1
FILL ALPHA 1
IF type=2 THEN
  filter$=""
ELSE
  filter$=""
ENDIF
filter2$=""
fil$=""
fil_lab1: DIR$=""
fil_lab2: 
IF DIR$>"" THEN path$=path$ & "/" & DIR$ & "/"
fil_lab21:
DIR path$ LIST DIRS directs$,n1
DIR path$ LIST FILES FILES$,n2
fil_lab3:
IF n1 THEN
  FOR i=1 TO n1 ! combi$(i)="DIR: " & directs$(i) ! NEXT i
  END IF
fil_lab4:
ntot=n1
IF n2 THEN
  FOR i=1 TO n2
    IF filter$="" OR filter$="filter" OR INSTR(FILES$(i),filter$)>=0 OR (type=1 AND INSTR(FILES$(i),filter2$)>=0) THEN
      ntot+=1 ! combi$(ntot)=FILES$(i)
      END IF
    NEXT i
  END IF
IF ntot=0 THEN ! ntot=1 ! combi$(1)="" ! END IF
DIM temp$(ntot)
FOR i=1 TO ntot ! temp$(i)=combi$(i) ! NEXT i
LIST "fsel" TEXT temp$ AT xtop+2*rw,sh*.03 SIZE xbot-xtop-4*rw,hgt*.93
DRAW SIZE 3 ! DRAW LINE xtop,ytop+hgt*.95 TO xbot,ytop+hgt*.95
.path$=path$ ! .fil$=fil$

fil_lab5:
IF BUTTON_PRESSED("-dir") THEN
  dirop=1
  fb$="Select directory"&CHR$(10)&CHR$(10)&"Click OK to delete it"&CHR$(10)&CHR$(10)&"Click CANCEL to escape"
  FIELD "feedback" TEXT fb$
ENDIF
IF BUTTON_PRESSED("+dir") THEN
  dirop=2
  fb$="Enter name of new directory"&CHR$(10)&CHR$(10)&"Click OK to create it"&CHR$(10)&CHR$(10)&"Click CANCEL to escape"
  FIELD "feedback" TEXT fb$
ENDIF
IF BUTTON_PRESSED("cancel") THEN
  ret$="" ! GOTO fil_lab6
END IF
IF BUTTON_PRESSED("clrfld") THEN FIELD "namer" TEXT ""
IF BUTTON_PRESSED("del") THEN
  'if file not yet selected, ask user to select one.
  checksel=LIST_SELECTED("fsel")
  IF checksel=-1 THEN
    fb$="You must first select a file to delete."
    GOTO skipremove
  ENDIF
fil$=temp$(checksel)
fb$="Are you sure you wish to delete the file """&fil$&""" ? If yes, press OK. If no, press Cancel. A deleted file cannot be recovered!"
deleter=1
skipremove:
FIELD "feedback" TEXT fb$
BEEP
BEEP
ENDIF

IF BUTTON_PRESSED("rename") THEN
'if not yet selected, ask user to select a file.
  checksel=LIST_SELECTED("fsel")
  IF checksel=-1 THEN
    fb$="You must first select a file to rename."
    GOTO skiprename
  ENDIF
fil$=temp$(checksel)
fb$="Are you sure you wish to rename the file """&fil$&""" ? If yes, enter the new name and press OK. If no, press Cancel."
FIELD "feedback" TEXT fb$
renamer=1
skiprename:
FIELD "feedback" TEXT fb$
BEEP
ENDIF
IF BUTTON_PRESSED("ok") THEN
  IF RIGHT$(path$,1)<>"/" THEN path$&="/"
  IF FIELD_TEXT$("namer")<>"" THEN fil$=FIELD_TEXT$("namer")
  IF dirop=2 AND fil$<>"" THEN
    DIR path$&fil$ CREATE
    FIELD "namer" TEXT ""
    dirop=0
    GOTO fil_lab21
  ENDIF
  IF dirop=1 AND fil$<>"" THEN
    DIR path$&fil$ DELETE
    FIELD "namer" TEXT ""
    dirop=0
    GOTO fil_lab21
  ENDIF
  IF deleter THEN
    FILE path$&fil$ DELETE
    deleter=0
    ret$=""
    GOTO fil_lab21
  ENDIF
  IF renamer THEN
    FILE path$&combi$(sel) RENAME path$&fil$
    renamer=0
    ret$=""
    GOTO fil_lab21
  ENDIF
  IF fil$>"" THEN
    IF path$ > "" THEN
     ret$=path$ & fil$
    ELSE
     ret$ = fil$
    END IF
    GOTO fil_lab6
  END IF
END IF

IF filter$<>filterhold$ THEN
'IF FIELD_CHANGED("filter") THEN
  filter$=FIELD_TEXT$("filter")
  'filterhold$=FIELD_TEXT$ ("filter")
  GOTO fil_lab4
END IF
  filterhold$=FIELD_TEXT$ ("filter")
IF FIELD_CHANGED("namer") THEN
  fil$=FIELD_TEXT$("namer")
  LIST "fsel" SELECT -1
  GOTO fil_lab4
ENDIF
IF BUTTON_PRESSED("back") THEN 
  IF path$<>"Listful/" THEN
    IF RIGHT$(path$,1)="/" THEN path$=LEFT$(path$,LEN(path$)-1)
    FOR k=LEN(path$) TO 1 STEP -1
      IF MID$(path$,k,1)="/" THEN BREAK
      NEXT k
    IF k THEN ! path$=LEFT$(path$,k) ! GOTO fil_lab21 ! END IF
  ENDIF
END IF
IF BUTTON_PRESSED("root") THEN
  path$="/" ! DIR$=""
  GOTO fil_lab21
END IF
IF BUTTON_PRESSED("quit") THEN
  IF .laun$="desktop" THEN EXIT
  IF .laun$="basic" THEN END
ENDIF
IF BUTTON_PRESSED("debug") THEN DEBUG PAUSE
sel=LIST_SELECTED("fsel")
IF sel>0 THEN
  IF sel>n1 THEN
     IF NOT trans THEN FIELD "namer" TEXT combi$(sel)
     trans=1
     IF FIELD_CHANGED ("namer") THEN trans=0
     IF sel<>tempsel THEN trans=0
     IF FIELD_TEXT$("namer")="" THEN
        fil$=combi$(sel)
     ELSE
        'FIELD "namer" TEXT combi$(sel)
        fil$=FIELD_TEXT$("namer")
     ENDIF
     tempsel=sel
    GOTO fil_lab5
    ELSE
    IF dirop<>1 THEN
      DIR$=directs$(sel) ! GOTO fil_lab2
    ELSE
      FIELD "namer" TEXT MID$(combi$(sel),6,45)
    ENDIF
    END IF
  END IF
  SLOWDOWN
GOTO fil_lab5

fil_lab6:
BUTTON "cancel" DELETE ! BUTTON "ok" DELETE ! BUTTON "clrfld" DELETE
BUTTON "rename" DELETE ! BUTTON "del" DELETE ! BUTTON "root" DELETE
BUTTON "back" DELETE ! BUTTON "+dir" DELETE ! BUTTON "-dir" DELETE
BUTTON "import" DELETE ! BUTTON "export" DELETE
FIELD "namer" DELETE ! LIST "fsel" DELETE
FIELD "filter" DELETE 
SPRITE "fbrow" AT xtop-2,ytop-2 ! SPRITE "fbrow" STAMP
SPRITE "fbrow" DELETE ! FIELD "feedback" DELETE
DRAW SIZE 1
/*IF impo THEN RETURN rets
IF expo THEN RETURN ret$*/
.path$=path$
draw image "gradiance.jpg" at 0,0
page "freq" hide
RETURN ret$
END DEF

'g'
' custom top toolbar

drawinfobar:                        ' Original code by Dav, modified by rbytes
'refresh on
tb$="Battery"
FILL ALPHA 0
hs=file_select$.headspace
aj=sw/5
rw=.rw!rh=.rh
ypos=3
SET BUTTONS CUSTOM
SET BUTTONS FONT SIZE 18*rw
'=== show device info
sv$=DEVICE_TYPE$()&" with iOS "&SYSTEM_VERSION()
'===show time
ampm$="AM" ! hr=CURRENT_HOUR()
MIN$=STR$(CURRENT_MINUTE())
IF LEN(MIN$)=1 THEN MIN$="0"&MIN$
IF hr>11 THEN ampm$="PM"
IF hr>12 THEN hr=hr-12
IF hr=0 THEN hr=12
tm$=STR$(hr)&":"&MIN$&" "&ampm$
tx=((sw/2)-TEXT_WIDTH(tm$)/2)
'===show app name
app$="Blender Frame V1.5"
'===show battery condition
bat$=STR$(BATTERY_LEVEL())&"%"
lev=BATTERY_LEVEL()
tat=BATTERY_STATE ()
IF tat THEN tat$="~" ELSE tat$=""

FILL COLOR 0,0,0
DRAW COLOR 0,0,0
BUTTON "sdebug" TEXT CHR$(8545) AT 5,ypos-7*rh
BUTTON "sdev" TEXT sv$ AT 29*rw+corr,ypos-7*rh
BUTTON "sapp" TEXT app$ AT -hs+ sw/2-TEXT_WIDTH(bat$)/2-30*rw+corr,ypos-7*rh
BUTTON "sbat" TEXT bat$ AT -hs+ sw-aj-TEXT_WIDTH(bat$)-63*rw+corr,ypos-7*rh
BUTTON "stat" TEXT tat$ AT -hs+ sw-aj-TEXT_WIDTH(bat$)+52*rw+corr,ypos-7*rh
BUTTON "stime" TEXT tm$ AT -hs+ tx-aj+corr,ypos-7*rh
BUTTON "squit" TEXT "X" AT sw-33,ypos-7*rh
DRAW COLOR 1,1,1
BUTTON "debug" TEXT CHR$(8545) AT 4,ypos-7*rh-1
BUTTON "dev" TEXT sv$ AT 28*rw+corr,ypos-7*rh-1
BUTTON "app" TEXT app$ AT -hs+ sw/2-TEXT_WIDTH(bat$)/2-31*rw+corr,ypos-7*rh-1
BUTTON "bat" TEXT bat$ AT -hs+ sw-aj-TEXT_WIDTH(bat$)-64*rw+corr,ypos-7*rh-1
BUTTON "tat" TEXT tat$ AT -hs+ sw-aj-TEXT_WIDTH(bat$)+51*rw+corr,ypos-7*rh-1
BUTTON "time" TEXT tm$ AT -hs+ tx-aj-1+corr,ypos-7*rh-1
BUTTON "quit" TEXT "X" AT sw-34,ypos-7*rh-1

'=== draw battery graphics
FILL ALPHA 1
DRAW ALPHA 1
DRAW SIZE 1
SHADOW OFFSET 0,0
SPRITE TB$ BEGIN sw/8,20
FILL COLOR 0,0,0
DRAW COLOR 0,0,0
DRAW RECT 45*rw,ypos+2 TO 81*rw,ypos+14*rh
FILL RECT 45*rw,ypos+2 TO 42*rw+lev*levfactor,ypos+14*rh
FILL RECT 81*rw,ypos+7*rh TO 83*rw,ypos+11*rh
FILL COLOR 1,1,1
DRAW COLOR 1,1,1
levfactor=rw*.348

DRAW SIZE 1
DRAW RECT 44*rw,ypos TO 80*rw,ypos+12*rh
FILL RECT 44*rw,ypos TO 44*rw+lev*levfactor,ypos+12*rh
FILL RECT 80*rw,ypos+3*rh TO 82*rw,ypos+9*rh
SPRITE TB$ END
SPRITE TB$ AT 790*rw,14*rw
SPRITE TB$ SHOW
tat=BATTERY_STATE ()
IF tat THEN tat$="~" ELSE tat$=""         ' Show ~ if battery is charging
BUTTON "stat" TEXT tat$
DRAW COLOR 1,1,1
BUTTON "tat" TEXT tat$

'DRAW COLOR 0,0,0
'FILL COLOR 1,1,1
SET BUTTONS FONT SIZE 22*rw
'refresh off
RETURN
''
Attachments
0591CE77-11B0-4A1A-ABA3-C0CF5816DCC2.png
0591CE77-11B0-4A1A-ABA3-C0CF5816DCC2.png (4.26 MiB) Viewed 1191 times
2088E002-A770-4F6E-8FEE-AAAB588184D1.png
2088E002-A770-4F6E-8FEE-AAAB588184D1.png (2.17 MiB) Viewed 1193 times
7D9D6A4F-9248-4C1D-BB18-AFC10CEBF8AB.png
7D9D6A4F-9248-4C1D-BB18-AFC10CEBF8AB.png (97.95 KiB) Viewed 1193 times
3D8D0E91-8CFA-41AF-A5D6-07149B7F635B.png
3D8D0E91-8CFA-41AF-A5D6-07149B7F635B.png (347.45 KiB) Viewed 1193 times
5F9BB2C0-AD96-4BDD-A823-FDBC7CECF05D.png
5F9BB2C0-AD96-4BDD-A823-FDBC7CECF05D.png (1.47 MiB) Viewed 1193 times
####### Living the colorful life #######

Post Reply