Author Topic: Fractions Of An Inch  (Read 1817 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 322
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Fractions Of An Inch
« on: November 01, 2021 »
Divided into 128 segments and their millimeter lengths.

I once did this on paper with a calculator.

Code: [Select]
denominator=128
dim loop(denominator)
dim topnum(denominator)
dim count(denominator)
dim botnum(denominator)

for a=1 to denominator
topnum(a)=a
count(a)=1
botnum(a)=denominator
next a

open window 640,512
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
col=1
gap=0

for a=1 to denominator
loop(a)=topnum(a)/2

if frac(topnum(a)/2)=0 then
count(a)=count(a)*2
topnum(a)=loop(a)
else
col=col+1

if topnum(a)<10 then
align=10
elseif topnum(a)>99 then
align=-10
else
align=0
endif

if botnum(a)/count(a)<=8 then
setrgb 1,256,0,0
else
setrgb 1,256,256,256
endif

text 10+gap+align,15*col,str$(topnum(a))+"/"+str$(botnum(a)/count(a))
endif

text 80+gap,15*col,str$((a/denominator)*25.4,"##.##")

if col>32 then
gap=gap+160
col=1
endif

next a

until (1=0)
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.