Blender Frame

Post Reply
User avatar
rbytes
Posts: 1798
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:

Blender Frame

Post by rbytes » Sat Aug 11, 2018 9:27 pm

This program can create some interesting photo composites. When you first run it, one image will appear fullscreen as a backdrop or frame. The other will appear within it at .9 of fullscreen size. There will also be a default fade area indicated by a white rectangle. Press Start and a fade to transparency edge will be rendered on the smaller image and it will then be stamped on the larger one, now revealing a dissolve between them. Press Save to save the completed image and export it to the camera roll. Complete instructions are found at the head of the program.

There are dozens of other uses. Set the transition to 0 and you will get a hard edge between the images. Place the smaller image in a corner with the UL, LL, UR and LR buttons. With multiple passes you can have 4 or more smaller images within the fullscreen background image.

One current limitation to mention. This program expects the inner image to be of the typical 4:3 landscape ratio produced by iOS cameras. The full-screen image can be odd-shaped, but the width and height should both be greater than the pixel resolution of your device. Here are the default images:

starweb.jpg
starweb.jpg (1017.56 KiB) Viewed 1178 times
pylon.jpg
pylon.jpg (1.54 MiB) Viewed 1178 times

Code: Select all

/*
Blender Frame V1.5
Blends two images with a smooth fade transition.
One can be the frame, and the other can be a window within it.
Or the images can appear beside ir above and below each other.
With multiple passes you can create multiple windows!
Use landscape images with a 4:3 aspect ratio.
by rbytes, June 2018
**************************************************
V1.5 - File requester added to load desired images
V1.4 - Corner image preset buttons added
V1.3 - Position and size sliders added
V1.2 - Swap button added (swaps the two images)
V1.1 - Now runs on most iOS devices
Be careful not to stretch images beyond their original
dimensions, or their pixel structure will become noticeable.
iPad: 2048 x 1536; iPhone: horizontal size x 3/4*h vertical size
Valid image types are: JPG, PNG, BMP, GIF, TIF, ICO, CUR, XBM.
**************************************************
1. Load two images.
2. Image 1 will be drawn full-screen as the frame.
3. Image 2 will be drawn smaller, inside the frame.
4. Use Hor Pos and Ver Pos sliders to move the framed image where you want it.
5. Use the Transition Width slider to set the transition area width.
6. Use the Image 2 Scale slider to set the size of the inner image.
7. Press the UL, LL, UR, or LR buttons to place the image in a corner of the screen.
8. Press Start. The rendering will take ~ 15 seconds. Not bad to set 3 million pixels!
9. If the transition size is set to 0, there will be no fade and thus no render time.
10. If you wish, press Reset and try again with new settings.
11. Press Save. Your composite image is saved as "framed1.png" and exported to Photos.
12. You can rename the saved file and re-use it as a new frame. if you do this multiple times, you can add as many images as you wish at different locations within a frame.
13. The four image preset buttons, UL, LL, UR and LR, will place four images very accurately in the four quadrants of the background. These are processed one at a time, as described in point 12.
*/

SET TOOLBAR OFF
OPTION IMAGE POS CENTRAL
OPTION SPRITE POS CENTRAL
SET ORIENTATION LANDSCAPE
SET BUTTONS CUSTOM
SHADOW ON
SHADOW OFFSET 10,10
SHADOW BLUR 4
laun$=LAUNCHER$ ()
dev$=DEVICE_TYPE$()
GET SCREEN SIZE sw,sh
sh2=sw*.75
iostest=0
IF iostest THEN
  sw=568
  sh=320
  sh2=568*.75
  dev$=""
ENDIF
rw=sw/1024!rh=sh/768!rh2=rw*.75
Image1$="starweb1.jpg"
Image2$="pylon.jpg"
L$="transition"!Q$="quit"
R$="scale"!W$="voriz"
S$="start"!T$="reset"
N$="notice"!E$="swap"
Y$="vert"!V$="save"
O$="load"
IF sw<1024 THEN corr=10 ELSE corr=0
GRAPHICS
GRAPHICS CLEAR
DRAW COLOR 0,0,0
SLIDER L$ VALUE .2 AT 45*rw,-corr+640*rh SIZE 300*rw       ' width of transition (prop)
SLIDER R$ VALUE .9 AT 680*rw,-corr+640*rh SIZE 300*rw      ' scale of inner image (size1)
SLIDER W$ VALUE .5 AT 360*rw,-corr+640*rh SIZE 300*rw      ' horizontal position of inner image
SLIDER Y$ VALUE .5 AT 360*rw,-corr+680*rh SIZE 300*rw      ' vertical position of inner image
FIELD L$ TEXT "Transition Width: "&fsize AT 140*rw-corr,660*rh SIZE 260*rw,30*rh RO
FIELD L$ FONT COLOR 1,1,1
FIELD L$ FONT SIZE 18*rw
FIELD L$ BACK ALPHA 0
FIELD R$ TEXT "Image 2 Scale: "&size1 AT 745*rw+corr,660*rh SIZE 260*rw,30*rh RO
FIELD R$ FONT COLOR 1,1,1
FIELD R$ FONT SIZE 18*rw
FIELD R$ BACK ALPHA 0
FIELD W$ TEXT "Hor Pos: "&horiz AT 455*rw,660*rh SIZE 200*rw,30*rh RO
FIELD W$ FONT COLOR 1,1,1
FIELD W$ FONT SIZE 18*rw
FIELD W$ BACK ALPHA 0
FIELD Y$ TEXT "Ver Pos: "&vert AT 455*rw,700*rh SIZE 200*rw,30*rh RO
FIELD Y$ FONT COLOR 1,1,1
FIELD Y$ FONT SIZE 18*rw
FIELD Y$ BACK ALPHA 0
note$="Creating edge transition "
FIELD N$ TEXT note$ AT 375*rw,590*rh SIZE 290*rw,30*rw          ' notice
FIELD N$ FONT COLOR 0,0,0
FIELD N$ BACK COLOR 1,1,.6
FIELD N$ FONT SIZE 18*rw
FIELD N$ HIDE
SET BUTTONS FONT SIZE 20*rw
BUTTON S$ TEXT "START" AT 60*rw,700*rh SIZE 80*rw,30*rw    ' start button
BUTTON T$ TEXT "RESET" AT 150*rw,700*rh SIZE 80*rw,30*rw   ' reset button
BUTTON E$ TEXT "SWAP" AT 240*rw,700*rh SIZE 80*rw,30*rw    ' reset button
BUTTON O$ TEXT "LOAD" AT 795*rw,700*rh SIZE 80*rw,30*rw    ' load button
BUTTON V$ TEXT "SAVE" AT 885*rw,700*rh SIZE 80*rw,30*rw    ' save button
BUTTON "ul" TEXT "UL" AT 330*rw,700*rh SIZE 40*rw,30*rw      ' UL button
BUTTON "ll" TEXT "LL" AT 665*rw,700*rh SIZE 40*rw,30*rw      ' UL button
BUTTON "ur" TEXT "UR" AT 705*rw,700*rh SIZE 40*rw,30*rw      ' UL button
BUTTON "lr" TEXT "LR" AT 745*rw,700*rh SIZE 40*rw,30*rw      ' UL button

RESET:
DRAW COLOR 1,1,1
REFRESH
REFRESH OFF
SLIDER L$ VALUE .2
SLIDER R$ VALUE .9
SLIDER W$ VALUE .5
SLIDER Y$ VALUE .5
fsize=128  ' width of the transition
size1=.9   ' scale of inner image
prop=.2    ' controls fsize
prop1=.8   ' 1-prop, controls transition width indicator
sc1=1      ' scale factor for image 1
sc2=.5     ' scale factor for image 2
cnt=0
horiz=sw/2
vert=sh/2
vert2=sh2/2
DRAW IMAGE Image1$ AT sw/2,sh2/2 SCALE sc1*rw
DRAW IMAGE Image2$ AT horiz,vert2 SCALE sc2*rw*size1
DRAW RECT horiz,vert2 SIZE sw/2*size1,sh2/2*size1
DRAW RECT horiz,vert2 SIZE sw/2*prop1*size1,sh2/2*prop1*size1
REFRESH
drawinfobar

' prepare layout
DO
  'if rw=1 then corner=.45 else corner=.35
  corner=.45

    'adjust sliders
  IF SLIDER_CHANGED(L$) OR SLIDER_CHANGED(R$) OR SLIDER_CHANGED(W$) OR SLIDER_CHANGED(Y$) THEN
    GRAPHICS CLEAR
    horiz=INT(sw*rw*SLIDER_VALUE(W$))        ' horizontal position of inner image
    vert2=INT(sh2*SLIDER_VALUE(Y$))          ' vertical position of inner image
    prop1=INT(100*(1-SLIDER_VALUE(L$)))/100  ' inverse fraction of transition
    prop= INT(100*(SLIDER_VALUE(L$)))/100    ' fraction of transition
    size1= INT(100*(SLIDER_VALUE(R$)))/100   ' scale of inner image
    fsize=INT(prop*640*rh2)
    FIELD L$ TEXT "Transition Width: "&fsize
    FIELD R$ TEXT "Image 2 Scale: "&size1
    FIELD W$ TEXT "Hor Pos: "&horiz
    FIELD Y$ TEXT "Ver Pos: "&vert2
    DRAW IMAGE Image1$ AT sw/2,sh2/2 SCALE sc1*rw
    DRAW IMAGE Image2$ AT horiz,vert2 SCALE sc2*rw*size1
    DRAW RECT horiz,vert2 SIZE sw/2*size1,sh2/2*size1
    DRAW RECT horiz,vert2 SIZE sw/2*prop1*size1,sh2/2*prop1*size1
    REFRESH
  ENDIF

  ' reset
  IF bp(T$) THEN
    GRAPHICS CLEAR
    GOTO RESET
  ENDIF

  ' go to debug screen
  IF BUTTON_PRESSED("debug") THEN DEBUG PAUSE
  
  ' update infobar with changes
  IF CURRENT_MINUTE()<>oldmin OR BATTERY_LEVEL()<>oldlev OR BATTERY_STATE()<>oldstat THEN
    oldmin=CURRENT_MINUTE()
    oldlev=BATTERY_LEVEL()
    oldstat=BATTERY_STATE()
    drawinfobar
  END IF

    ' frame upper left, 1/4 size
  if bp("ul") then
  vert=205!horiz=267
  fsize=64  ' width of the transition
  size1=.45  ' scale of inner image
  prop=.1   ' controls fsize
  prop1=.9  ' 1-prop, controls transition width indicator
  gosub setsliders
  gosub setfields
  gosub drawit
  refresh
  endif

  ' frame lower left, 1/4 size
  if bp("ll") then
  horiz=267! vert=568
  fsize=64  ' width of the transition
  size1=.45  ' scale of inner image
  prop=.1   ' controls fsize
  prop1=.9  ' 1-prop, controls transition width indicator
  gosub setsliders
  gosub setfields
  gosub drawit
  refresh
  endif

  ' frame upper right, 1/4 size
  if bp("ur") then
  horiz=760!vert=205
  fsize=64  ' width of the transition
  size1=.45  ' scale of inner image
  prop=.1   ' controls fsize
  prop1=.9  ' 1-prop, controls transition width indicator
  gosub setsliders
  gosub setfields
  gosub drawit
  refresh
  endif

  ' frame lower right, 1/4 size
  if bp("lr") then
  horiz=760!vert=568
  fsize=64  ' width of the transition
  size1=.45  ' scale of inner image
  prop=.1   ' controls fsize
  prop1=.9  ' 1-prop, controls transition width indicator
  gosub setsliders
  gosub setfields
  gosub drawit
  refresh
  endif

  ' swap
  IF bp(E$) THEN
    temp$=Image1$
    Image1$=Image2$
    Image2$=temp$
    temp=sc1
    sc1=sc2
    sc2=temp
    GRAPHICS CLEAR
    DRAW IMAGE Image1$ AT sw/2,sh/2 SCALE sc1*rw
    DRAW IMAGE Image2$ AT horiz,vert SCALE sc2*rw*size1
    DRAW RECT horiz,vert SIZE sw/2*rw*size1,sh/2*rh*size1
    DRAW RECT horiz,vert SIZE sw/2*rw*prop1*size1,sh/2*rh*prop1*size1
    REFRESH
  ENDIF

  IF bp("load") THEN
    REFRESH ON
    GRAPHICS CLEAR .5,.5,.5
    path$="/JPGs/"
    corr=50*rh ' corrects an unwanted horizontal shift in toolbar
    F$=file_select$(350*rw,20*rh,220*rw,254*rh,1,path$)
    imchek$=file_select$.im1name$
    IF imchek$<>"" THEN
      Image1$=imchek$
      GET IMAGE imchek$ SIZE hori,veri
      sc1=MAX(1024/hori,768/veri)
    ENDIF
    imchek$=file_select$.im2name$
    IF imchek$<>"" THEN
      Image2$=imchek$
      GET IMAGE imchek$ SIZE hori,veri
      sc2=MAX(1024/hori,768/veri)
    ENDIF
    GOTO RESET
  ENDIF
  IF bp(Q$) THEN
    GOTO ender
  END IF
  SLOWDOWN
UNTIL bp(S$)  ' loop until Start button pressed

REFRESH ON
FIELD N$ SHOW
SPRITE "stamp" BEGIN sw,sh
DRAW IMAGE Image2$ AT sw/2,sh/2 SCALE sc2*rw
IF prop<>0 THEN
FOR y=0 TO sh*2
  A3=1
  IF y<fsize THEN A3=y/fsize                ' feather top
  IF y>sh*2-fsize THEN A3=(sh*2-y)/fsize    ' feather bottom
  FOR x=0 TO sw*2
    A2=1        
    GET PIXEL x,y COLOR R,G,B,A
    IF x<fsize THEN A2=x/fsize              ' feather left side
    IF x>sw*2-fsize THEN A2=(sw*2-x)/fsize  ' feather right side
    DRAW PIXEL x,y COLOR R,G,B,A2*A3
  NEXT x
  IF y>=(((sw*2)*.75)/6)*cnt THEN
    note$&="*"
    FIELD N$ TEXT note$
    cnt+=1
  ENDIF
NEXT y
ENDIF
SPRITE "stamp" END
SPRITE "stamp" AT horiz,vert SCALE size1
DRAW IMAGE Image1$ AT sw/2,sh/2 SCALE sc1*rw
SPRITE "stamp" STAMP
note$="             Frame Completed"
FIELD N$ TEXT note$
FIELD N$ BACK COLOR .6,1,.6

DO
  ' save
  IF bp(V$) THEN
    NOTES SET "88:v127tc3e3$f3g3$"
    NOTES PLAY
    GRAPHICS SAVE 0,0, 1024,768 TO "framed1.png"
    ALBUM EXPORT "framed1.png"
  ENDIF

  ' reset
  IF bp(T$) THEN
    FIELD N$ HIDE
    note$="Creating edge transition "
    FIELD N$ TEXT note$
    SLIDER L$ VALUE .2
    SLIDER R$ VALUE .1
    SLIDER W$ VALUE .5
    SLIDER Y$ VALUE .5
    GRAPHICS CLEAR
    GOTO RESET
  ENDIF

  ' end
  IF bp(Q$) THEN
    ender:
    IF laun$="desktop" THEN
      IF FILE_EXISTS("/launch") THEN
        RUN "/-Launch.sb"
      ELSE
        EXIT
      ENDIF
    ENDIF
    END
  END IF
  SLOWDOWN
UNTIL 0

drawit:
  draw image Image1$ at sw/2,sh/2 scale sc1*rw
  draw image Image2$ at horiz,vert scale sc2*rw*size1
  DRAW RECT horiz,vert SIZE sw/2*rw*size1,sh/2*rh*size1
  DRAW RECT horiz,vert SIZE sw/2*rw*prop1*size1,sh/2*rh*prop1*size1
return

setfields:
  FIELD L$ TEXT "Transition Width: "&fsize
  FIELD R$ TEXT "Image 2 Scale: "&size1
  FIELD W$ TEXT "Hor Pos: "&horiz
  FIELD Y$ TEXT "Ver Pos: "&vert
RETURN

setsliders:
  SLIDER W$ VALUE horiz/(sw*rw)
  SLIDER Y$ VALUE vert/(sh*rh)
  SLIDER L$ VALUE prop
  SLIDER R$ VALUE 1-size1
RETURN

DEF bp(a$) = BUTTON_PRESSED(a$)

'b'
' file browser/selector            Thanks to Henko for the original code
' 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*.413 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
DRAW RECT 20*rw, sh/2 TO 463*rw,sh-51*rw
DRAW RECT sw/1.875, sh/2 TO sw-34*rw,sh-51*rw
BUTTON "cancel" title "MAIN" 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
BUTTON "im1" title "Image 1" AT sw*.186,sh*.47 SIZE 90*rw,40*rh
FILL COLOR 1,1,1
im1=1
BUTTON "im2" title "Image 2" AT sw*.71,sh*.48 SIZE 90*rw,40*rh
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("im1") THEN
   FILL COLOR 1,.5,.5
   BUTTON "im1" title "Image 1" AT sw*.186,sh*.47 SIZE 90*rw,40*rh
   FILL COLOR 1,1,1
   BUTTON "im2" title "Image 2" AT sw*.71,sh*.48 SIZE 90*rw,40*rh
   im1=1!im2=0
ENDIF
IF BUTTON_PRESSED("im2") THEN
   FILL COLOR 1,.5,.5
   BUTTON "im2" title "Image 2" AT sw*.71,sh*.48 SIZE 90*rw,40*rh
   FILL COLOR 1,1,1
   BUTTON "im1" title "Image 1" AT sw*.186,sh*.47 SIZE 90*rw,40*rh
   im1=0!im2=1
ENDIF
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
    GET IMAGE ret$ SIZE hor,ver
    IF im1 THEN
      im1name$=ret$
      ir1=MAX(1024/hor,768/ver)
      SPRITE "i1" LOAD ret$
      SPRITE "i1" AT sw*.236,sh*.717 SCALE MIN(440/hor,330/ver)
      SPRITE "i1" SHOW
     
    ELSE
      im2name$=ret$
      ir2=MAX(1024/hor,768/ver)
      SPRITE "i2" LOAD ret$
      SPRITE "i2" AT sw*.75,sh*.717 SCALE MIN(440/hor,330/ver)
      SPRITE "i2" SHOW
    ENDIF
    ' use formula to set sprite scale to fit preview window
    ' change formula to scale sprite to full screen in MAIN
    GOTO fil_lab21
  END IF
END IF

IF filter$<>filterhold$ 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
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
GRAPHICS CLEAR .7, .7, .7
IF type =2 THEN
  DRAW FONT SIZE 40*.rw
  DRAW TEXT "SAVING" AT sw/2-TEXT_WIDTH("SAVING")/2+10, sh/2
ENDIF
.path$=path$
.act=1
PAGE "freq" HIDE
PAGE "" SET
PAGE "" SHOW
RETURN ret$
END DEF

'g'
' custom top toolbar

DEF drawinfobar()                        ' Thanks to Dav for the original code
if .act then corr=50
tb$="Battery"
FILL ALPHA 0
hs=file_select$.headspace
sw=.sw!sh=.sh
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
end def
''
Attachments
93F47003-A7CA-4715-8307-B3604BF375AF.png
93F47003-A7CA-4715-8307-B3604BF375AF.png (5.17 MiB) Viewed 1187 times
1AD3B486-DCC0-4DFC-942C-B9580DE41EE1.png
1AD3B486-DCC0-4DFC-942C-B9580DE41EE1.png (5.49 MiB) Viewed 1187 times
8DB4FA20-41E5-4D74-9519-5BE6D45E500A.png
8DB4FA20-41E5-4D74-9519-5BE6D45E500A.png (6.24 MiB) Viewed 1187 times
A1C8C1D3-591E-4401-9F66-C6A52CA299A4.png
A1C8C1D3-591E-4401-9F66-C6A52CA299A4.png (7.2 MiB) Viewed 1187 times
####### Living the colorful life #######

Post Reply