! pt&mm

Post Reply
User avatar
Dutchman
Posts: 148
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

! pt&mm

Post by Dutchman » Fri Nov 22, 2019 1:24 pm

! pt&mm {/Extensions/Console/! pt&mm}
Contains shorthand functions to convert between points on 'Screen' and millimeters on 'Display'

Code: Select all

' {/Extensions/Console/! pt&mm}
[ Shorthand conversion functions between points and mm ]
[––––––––––––––––––––––– Functions –––––––––––––––––––––––––
mm2pt(mm)
converts mm to points, multiplied with local 'Scaler'
default value of 'Scaler' is 1
–––
Intmm2pt(mm)
converts mm to points rounded to nearest integer
return value is multiplied with local 'Scaler'
default value of 'Scaler' is 1
–––
pt2mm(pnts)
converts points to mm, multiplied with local 'Scaler'
default value of 'Scaler' is 1
–––
End of function description –––––––––––]
'
[–––––––––––––––––––––– Implementation ––––––––––––––––––––––]
DEF mm2pt(mm) ' by Ton Nillesen, November 2019
IF Scaler=0 THEN Scaler=1
ratio=SCALER*72/25.4
RETURN mm*ratio
END DEF
'
DEF Intmm2pt(mm) ' by Ton Nillesen, November 2019
IF Scaler=0 THEN Scaler=1
ratio=SCALER*72/25.4
RETURN INT(mm*ratio+0.5)
END DEF
'
DEF Pt2mm(pnts) ' by Ton Nillesen, November 2019
IF Scaler=0 THEN Scaler=1
ratio=SCALER*72/25.4
RETURN pnts/ratio
END DEF
# pt&mm test.bb is a test and demo program
It is still a long way to go

Post Reply