!This program will calculate the box counting dimension of a graphic object
!that is in a PICT file format; asks for filename and box size as inputs,
!then allows to click on the boxes, keeping count of how many (N).
!It outputs N and L, log(N) and log (1/L). To get a new output, run it again
!selecting a different box size L.
SET MODE "graphics"
ASK PIXELS hpix, vpix
SET WINDOW 0,ratio,0,1
!Lets import the picture to analyze its box counting dimension
OPEN #1: SCREEN 0,.4,.85,1
SET WINDOW 0,1,0,1
INPUT PROMPT "PICT FILENAME (Full path please):":filename$
BOX SHOW picture$ AT 0,0
!Ask for box size (L)
INPUT PROMPT "BOX SIZE? (0 to 1) :":L
!Done if clicked at x<.2, to output N vs. L result
PRINT "CLICK ->HERE<- WHEN DONE"
!Let's draw the boxes of size L
FOR i = 0 to ratio step L
FOR j = 0 to 1 step L
BOX LINES i,i+L,j,j+L
!Lets click on the boxes, color them red, and count the clicks
GET POINT x,y
IF x<.2 THEN EXIT DO
IF x>=.2 THEN
SET COLOR "red"
PLOT AREA: L*INT(x/L),L*INT(y/L);L*(INT(x/L)+1),L*INT(y/L);L*(INT(x/L)+1),L*(INT(y/L)+1);L*INT(x/L),L*(INT(y/L)+1);L*INT(x/L),L*INT(y/L)
!Lets print the N vs L results
PRINT "N =";count;"BOXES OF SIZE L =";L
PRINT "LOG(N) =";LOG10(count)
PRINT "LOG(1/L) =";LOG10(1/L)