Here is a program I wrote yesterday while watching the Olympics. The older group members should know how this works, while some of the younger members won’t know what this is. Slide your finger above the rule to move the C scale at a 1:1 ratio, while below the rule is a 1:10 ratio.
-- slide rule
-- use your finger to move the C scale
-- 1:1 ratio above the rule, 1:10 ratio below the rule
function setup()
supportedOrientations(LANDSCAPE_LEFT)
displayMode(FULLSCREEN)
lineCapMode(PROJECT)
yy=50
yz=50
end
function draw()
background(40, 40, 50)
c_scale()
d_scale()
end
function touched(t)
local d = 1
if t.y<400 then
d=10
end
if t.state==BEGAN then
xstart=yz-t.x/d
elseif t.state==MOVING then
yz=xstart+t.x/d
end
end
function d_scale()
fill(255,255,255,255)
stroke(255)
rect(10,330,980,70)
stroke(0)
strokeWidth(4)
for y=1,10 do
l=math.log10(y)*900
line(l+yy,370,l+yy,400)
end
for y=1,10, .5 do
l=math.log10(y)*900
line(l+yy,375,l+yy,400)
end
for y=1,10, .1 do
l=math.log10(y)*900
line(l+yy,380,l+yy,400)
end
for y=1,3, .02 do
l=math.log10(y)*900
line(l+yy,390,l+yy,400)
end
for y=3,8, .05 do
l=math.log10(y)*900
line(l+yy,390,l+yy,400)
end
fill(0)
--xx=math.log10(1)*900+yy
fontSize(20)
text("D",30,370)
text("D",970,370)
y3=355
y4=365
text("1",50,y3)
text("2",320,y3)
text("3",480,y3)
text("4",590,y3)
text("5",680,y3)
text("6",750,y3)
text("7",810,y3)
text("8",863,y3)
text("9",910,y3)
text("1",950,y3)
fontSize(12)
text(".5",210,y4)
text(".5",410,y4)
text(".5",540,y4)
text(".5",640,y4)
text(".5",720,y4)
text(".5",780,y4)
text(".5",840,y4)
text(".5",890,y4)
text(".5",930,y4)
fontSize(10)
text("dave1707",80,340)
fill(255)
fontSize(40)
text("Slide rule",WIDTH/2,700)
fontSize(20)
text("use your finger to move the C scale",WIDTH/2,650)
text("ratio of 1:1 above the rule, 1:10 below the rule",WIDTH/2,625)
end
function c_scale()
fill(255,255,255,255)
stroke(255)
rect(yz-40,400,980,70)
stroke(0)
strokeWidth(4)
for y=1,10 do
l=math.log10(y)*900
line(l+yz,400,l+yz,430)
end
for y=1,10, .5 do
l=math.log10(y)*900
line(l+yz,420,l+yz,425)
end
for y=1,10, .1 do
l=math.log10(y)*900
line(l+yz,400,l+yz,420)
end
for y=1,3, .02 do
l=math.log10(y)*900
line(l+yz,400,l+yz,410)
end
for y=3,8, .05 do
l=math.log10(y)*900
line(l+yz,400,l+yz,410)
end
fill(0)
--xx=math.log10(1)*900+yz
fontSize(20)
y1=445
y2=435
text("C",-20+yz,420)
text("C",920+yz,420)
text("1",yz,y1)
text("2",270+yz,y1)
text("3",430+yz,y1)
text("4",540+yz,y1)
text("5",620+yz,y1)
text("6",700+yz,y1)
text("7",760+yz,y1)
text("8",813+yz,y1)
text("9",860+yz,y1)
text("1",900+yz,y1)
fontSize(12)
text(".5",160+yz,y2)
text(".5",360+yz,y2)
text(".5",490+yz,y2)
text(".5",590+yz,y2)
text(".5",670+yz,y2)
text(".5",730+yz,y2)
text(".5",790+yz,y2)
text(".5",840+yz,y2)
text(".5",880+yz,y2)
end