|
// Map text to circular arcs |
|
// Ed Nisley KE4ZNU – 2019-06 |
|
|
|
//—– |
|
// Command line parameters |
|
|
|
// -D OuterDia=number |
|
|
|
if (!isdefined("OuterDia")) { |
|
OuterDia = 120mm – 2mm; // CD = 120, 3.5 inch drive = 95 |
|
} |
|
|
|
OuterRad = OuterDia / 2.0; |
|
comment("Outer Diameter: ",OuterDia); |
|
comment(" Radius: ",OuterRad); |
|
|
|
|
|
//—– |
|
// Library routines |
|
|
|
include("tracepath.inc.gcmc"); |
|
include("engrave.inc.gcmc"); |
|
|
|
//—– |
|
// Bend text around an arc |
|
|
|
function ArcText(TextPath,Center,Radius,BaseAngle,Align) { |
|
|
|
PathLength = TextPath[-1].x – TextPath[1].x; |
|
Circumf = 2*pi()*Radius; |
|
TextAngle = to_deg(360 * PathLength / Circumf); |
|
|
|
AlignAngle = BaseAngle + (Align == "Left" ? 0 : |
|
Align == "Center" ? -TextAngle / 2 : |
|
Align == "Right" ? -TextAngle : |
|
0); |
|
|
|
ArcPath = {}; |
|
|
|
foreach(TextPath; pt) { |
|
if (!isundef(pt.x) && !isundef(pt.y) && isundef(pt.z)) { // XY motion, no Z |
|
r = Radius – pt.y; |
|
a = 360deg * (pt.x / Circumf) + AlignAngle; |
|
ArcPath += {[r*cos(a) + Center.x, r*sin(a) + Center.y,-]}; |
|
} |
|
elif (isundef(pt.x) && isundef(pt.y) && !isundef(pt.z)) { // no XY, Z up/down |
|
ArcPath += {pt}; |
|
} |
|
else { |
|
error("Point is not pure XY or pure Z: " + to_string(pt)); |
|
} |
|
} |
|
|
|
return ArcPath; |
|
|
|
} |
|
|
|
//—– |
|
// Set up for drawing |
|
|
|
TravelZ = 1.0mm; // no clamps above workpiece! |
|
PlotZ = -1.0mm; // tune for best results |
|
|
|
TextSpeed = 100mm; // minimal shaking |
|
DrawSpeed = 500mm; // smooth curve drawing |
|
|
|
TextFont = FONT_HSANS_1_RS; |
|
TextSize = [2.0mm,2.0mm]; |
|
TextLeading = 5.0mm; // line spacing |
|
|
|
DiskCenter = [0mm,0mm]; // middle of the platter |
|
|
|
if (1) { |
|
comment("Circles begin"); |
|
|
|
TextRadius = OuterRad; |
|
|
|
for (r = OuterRad; r >= 25mm; r -= TextLeading) { |
|
feedrate(DrawSpeed); |
|
goto([-,-,TravelZ]); |
|
goto([r,0,-]); |
|
move([-,-,PlotZ]); |
|
circle_cw([0,0]); |
|
goto([-,-,TravelZ]); |
|
tp = scale(typeset("Radius: " + to_string(r),TextFont),TextSize); |
|
tpa = ArcText(tp,DiskCenter,r,115deg,"Left"); |
|
feedrate(TextSpeed); |
|
engrave(tpa,TravelZ,PlotZ); |
|
} |
|
} |
|
|
|
if (1) { |
|
comment("Depth variations begin"); |
|
|
|
TextRadius = OuterRad; |
|
feedrate(TextSpeed); |
|
|
|
for (pz = 0.0mm; pz >= -0.6mm; pz -= 0.10mm) { |
|
comment(" depth: " + to_string(pz)); |
|
ts = "Depth: " + to_string(pz) + " at " + to_string(TextSpeed) + "/s"; |
|
tp = scale(typeset(ts,TextFont),TextSize); |
|
tpa = ArcText(tp,DiskCenter,TextRadius,-5deg,"Right"); |
|
engrave(tpa,TravelZ,pz); |
|
TextRadius -= TextLeading; |
|
} |
|
} |
|
|
|
if (1) { |
|
comment("Feedrate variations begin"); |
|
|
|
TextRadius = OuterRad; |
|
|
|
for (ps = 50mm; ps <= 350mm; ps += 50mm) { |
|
feedrate(ps); |
|
comment(" speed: " + to_string(ps) + "/s"); |
|
ts = "Speed: " + to_string(ps) + "/s at " + to_string(PlotZ); |
|
tp = scale(typeset(ts,TextFont),TextSize); |
|
tpa = ArcText(tp,DiskCenter,TextRadius,5deg,"Left"); |
|
engrave(tpa,TravelZ,PlotZ); |
|
TextRadius -= TextLeading; |
|
} |
|
} |
|
|
|
if (1) { |
|
comment("Off-center text arcs begin"); |
|
|
|
feedrate(TextSpeed); |
|
tc = [-40mm/sqrt(2),-40mm/sqrt(2)]; // center point |
|
|
|
r = 8mm; |
|
s = [1.5mm,1.5mm]; |
|
ts = "Radius: " + to_string(r) + " Size: " + to_string(s); |
|
tp = scale(typeset(ts,TextFont),s); |
|
tpa = ArcText(tp,tc,r,0deg,"Center"); |
|
engrave(tpa,TravelZ,PlotZ); |
|
|
|
r = 5mm; |
|
s = [1.0mm,1.0mm]; |
|
ts = "Radius: " + to_string(r) + " Size: " + to_string(s); |
|
tp = scale(typeset(ts,TextFont),s); |
|
tpa = ArcText(tp,tc,r,0deg,"Center"); |
|
engrave(tpa,TravelZ,PlotZ); |
|
|
|
r = 15mm; |
|
s = [3.0mm,3.0mm]; |
|
ts = "Radius: " + to_string(r) + " Size: " + to_string(s); |
|
tp = scale(typeset(ts,TextFont),s); |
|
tpa = ArcText(tp,tc,r,0deg,"Center"); |
|
engrave(tpa,TravelZ,PlotZ); |
|
|
|
} |
|
|
|
if (1) { |
|
comment("Attribution begins"); |
|
tp = scale(typeset("Ed Nisley – KE4ZNU – softsolder.com",TextFont),TextSize); |
|
tpa = ArcText(tp,DiskCenter,15mm,0deg,"Center"); |
|
feedrate(TextSpeed); |
|
engrave(tpa,TravelZ,PlotZ); |
|
} |
|
|
|
goto([-,-,10mm]); |
|
goto([0mm,0mm,-]); |
|
|
|
comment("Done!"); |