Author Topic: Fraction Display  (Read 2089 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 319
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Fraction Display
« on: January 27, 2014 »
It's been a while. So hard to come up with original ideas.
Here's something that got into my head.
Displaying fractions of an inch, as in imperial drill size range.

Code: [Select]
open window 640,512
denominator=128 rem this number is parts per inch
'second number shows mm equivalent
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
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)<=1 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.