stdPaths.jsnc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. std = {
  2. "safetyHeight": 3,
  3. "rapids": 1300,
  4. "cutting": 1300,
  5. "plunge": 800,
  6. }
  7. std.pathStart = function(p={}){
  8. p.__proto__ = std;
  9. G90
  10. G0 Z0 F$p.plunge;
  11. }
  12. std.pathEnd = function(p={}){
  13. p.__proto__ = std;
  14. G90
  15. G0 Z6 F$p.plunge;
  16. }
  17. std.circle = function(radius, p={}){
  18. p.__proto__ = std;
  19. G91
  20. G0 X${-1*radius} F$std.rapids
  21. p.pathStart();
  22. G91
  23. G2 X0 Y0 I$radius J0 F$std.cutting
  24. p.pathEnd();
  25. G91
  26. G0 X${radius} F$std.rapids
  27. }
  28. std.circleR = function(radius, p={}){
  29. p.__proto__ = std;
  30. p.pathStart();
  31. G91
  32. G2 X0 Y0 I$radius J0 F$std.cutting
  33. p.pathEnd();
  34. }
  35. std.circleL = function(radius, p={}){
  36. p.__proto__ = std;
  37. p.pathStart();
  38. G91
  39. G3 X0 Y0 I$radius J0 F$std.cutting
  40. p.pathEnd();
  41. }
  42. over = function(x=0,y=0,z=0){
  43. G0 X$x Y$y Z$z F$std.rapids
  44. }
  45. //------------------------------------------------------------------------------
  46. //letters
  47. //------------------------------------------------------------------------------
  48. function draw(cutHeight){
  49. G90
  50. G1 Z$cutHeight F$std.plunge
  51. G1 F$std.cutting
  52. G91
  53. }
  54. function safe(){
  55. G90
  56. G0 Z$std.safetyHeight F$std.rapids
  57. G91
  58. }
  59. function letterStart(scale){
  60. G91
  61. G0 F$std.rapids
  62. G1 F$std.cutting
  63. safe();
  64. let spacing = 4.3219 - (1.4427 * Math.log(10*scale))
  65. spacing = (spacing < 1) ? 1 : spacing;
  66. G0 X${(spacing * scale).toFixed(4)}
  67. }
  68. std.letters = {};
  69. std.text = function text(text, scale=1, cutHeight=0){
  70. for(let i = 0; i < text.length; i++){
  71. let c = text[i];
  72. if(c in std.letters){
  73. std.letters[c](scale,cutHeight);
  74. }
  75. else{
  76. G91
  77. safe();
  78. G0 X${10 * scale}
  79. G90
  80. }
  81. }
  82. }
  83. std.letters.A = function A(scale=1, cutHeight=0){
  84. letterStart(scale);
  85. draw(cutHeight);
  86. G1 Y${ 8 * scale }
  87. G1 X${ 2 * scale } Y${ 2 * scale }
  88. G1 X${ 2 * scale }
  89. G1 X${ 2 * scale } Y${ -2 * scale }
  90. G1 Y${ -8 * scale }
  91. safe();
  92. G0 X${ -6 * scale } Y${ 5 * scale }
  93. draw(cutHeight);
  94. G1 X${6 * scale}
  95. safe();
  96. G0 Y${-5 * scale}
  97. G90
  98. }
  99. std.letters.B = function B(scale=1, cutHeight=0){
  100. letterStart(scale);
  101. draw(cutHeight)
  102. G1 Y${10 * scale}
  103. G1 X${5 * scale}
  104. G1 X${1 * scale} Y${-1 * scale}
  105. G1 Y${-3 * scale}
  106. G1 X${-1 * scale} Y${-1 * scale}
  107. G1 X${1 * scale} Y${-1 * scale}
  108. G1 Y${-3 * scale}
  109. G1 X${-1 * scale} Y${-1 * scale}
  110. G1 X${-5 * scale}
  111. safe()
  112. G0 Y${5 * scale}
  113. draw(cutHeight)
  114. G1 X${5 * scale}
  115. safe()
  116. G0 X${1 * scale} Y${-5 * scale}
  117. G90
  118. }
  119. std.letters.C = function C(scale=1, cutHeight=0){
  120. letterStart(scale);
  121. G0 X${ 6 * scale } Y${ 10 * scale }
  122. draw(cutHeight);
  123. G1 X${-5 * scale}
  124. G1 X${-1 * scale} Y${-1 * scale}
  125. G1 Y${-8 * scale}
  126. G1 X${ 1 * scale} Y${-1 * scale}
  127. G1 X${ 5 * scale}
  128. safe();
  129. G90
  130. }
  131. std.letters.D = function D(scale=1, cutHeight=0){
  132. letterStart(scale);
  133. draw(cutHeight)
  134. G1 Y${10 * scale}
  135. G1 X${ 5 * scale}
  136. G1 X${ 1 * scale} Y${-1 * scale}
  137. G1 Y${-8 * scale}
  138. G1 X${-1 * scale} Y${-1 * scale}
  139. G1 X${-5 * scale}
  140. safe();
  141. G0 X${6 * scale}
  142. G90
  143. }
  144. std.letters.E = function E(scale=1, cutHeight=0){
  145. letterStart(scale);
  146. G0 X${6 * scale} Y${10 * scale}
  147. draw(cutHeight);
  148. G1 X${ -6 * scale}
  149. G1 Y${-10 * scale}
  150. G1 X${ 6 * scale}
  151. safe();
  152. G0 X${-6 * scale} Y${5 * scale}
  153. draw(cutHeight);
  154. G1 X${3 * scale}
  155. safe();
  156. G0 X${3 * scale} Y${-5 * scale}
  157. G90
  158. }
  159. std.letters.F = function F(scale=1, cutHeight=0){
  160. letterStart(scale);
  161. G0 X${6 * scale} Y${10 * scale}
  162. draw(cutHeight);
  163. G1 X${ -6 * scale}
  164. G1 Y${-10 * scale}
  165. safe();
  166. G0 Y${5 * scale}
  167. draw(cutHeight);
  168. G1 X${3 * scale}
  169. safe();
  170. G0 X${3 * scale} Y${-5 * scale}
  171. G90
  172. }
  173. std.letters.G = function G(scale=1, cutHeight=0){
  174. letterStart(scale);
  175. G0 X${ 6 * scale } Y${ 10 * scale }
  176. draw(cutHeight);
  177. G1 X${-5 * scale}
  178. G1 X${-1 * scale} Y${-1 * scale}
  179. G1 Y${-8 * scale}
  180. G1 X${ 1 * scale} Y${-1 * scale}
  181. G1 X${ 4 * scale}
  182. G1 X${ 1 * scale} Y${ 1 * scale}
  183. G1 Y${ 4 * scale}
  184. G1 X${-2 * scale}
  185. safe();
  186. G0 X${2 * scale} Y${-5 * scale}
  187. G90
  188. }
  189. std.letters.H = function H(scale=1, cutHeight=0){
  190. letterStart(scale);
  191. draw(cutHeight);
  192. G1 Y${ 10 * scale }
  193. safe();
  194. G0 Y${ -5 * scale }
  195. draw(cutHeight);
  196. G1 X${ 5 * scale }
  197. safe();
  198. G0 Y${ 5 * scale }
  199. draw(cutHeight);
  200. G1 Y${ -10 * scale }
  201. safe();
  202. G90
  203. }
  204. std.letters.I = function I(scale=1, cutHeight=0){
  205. letterStart(scale)
  206. draw(cutHeight);
  207. G1 X${ 5 * scale }
  208. safe();
  209. G0 X${ -2.5 * scale }
  210. draw(cutHeight);
  211. G1 Y${ 10 * scale }
  212. safe();
  213. G0 X${ -2.5 * scale }
  214. draw(cutHeight);
  215. G1 X${ 5 * scale }
  216. safe();
  217. G0 Y${ -10 * scale }
  218. }
  219. std.letters.J = function J(scale=1, cutHeight=0){
  220. letterStart(scale);
  221. G0 Y${3 * scale}
  222. draw(cutHeight);
  223. G1 Y${ -2 * scale }
  224. G1 X${ 1 * scale } Y${ -1 * scale }
  225. G1 X${ 3 * scale }
  226. G1 X${ 1 * scale } Y${ 1 * scale }
  227. G1 Y${ 9 * scale }
  228. G1 X${ -3 * scale }
  229. safe();
  230. G0 X${ 3 * scale } Y${ -10 * scale }
  231. G90
  232. }
  233. std.letters.K = function K(scale=1, cutHeight=0){
  234. letterStart(scale);
  235. draw(cutHeight);
  236. G1 Y${ 10 * scale }
  237. safe();
  238. G0 Y${ -6 * scale }
  239. draw(cutHeight);
  240. G1 X${ 6 * scale } Y${ 6 * scale }
  241. safe();
  242. G0 X${ -5 * scale } Y${ -5 * scale }
  243. draw(cutHeight);
  244. G1 X${ 5 * scale } Y${ -5 * scale }
  245. safe();
  246. G90
  247. }
  248. std.letters.L = function L(scale=1, cutHeight=0){
  249. letterStart(scale);
  250. G0 Y${ 10 * scale }
  251. draw(cutHeight);
  252. G1 Y${ -10 * scale }
  253. G1 X${ 5 * scale }
  254. safe();
  255. G90
  256. }
  257. std.letters.M = function M(scale=1, cutHeight=0){
  258. letterStart(scale);
  259. draw(cutHeight);
  260. G1 Y${ 10 * scale }
  261. G1 X${ 3 * scale } Y${ -3 * scale }
  262. G1 X${ 3 * scale } Y${ 3 * scale }
  263. G1 Y${ -10 * scale }
  264. safe();
  265. G90
  266. }
  267. std.letters.N = function N(scale=1, cutHeight=1){
  268. letterStart(scale);
  269. draw(cutHeight);
  270. G1 Y${ 10 * scale }
  271. safe();
  272. draw(cutHeight);
  273. G1 X${ 6 * scale } Y${ -10 * scale }
  274. draw(cutHeight);
  275. G1 Y${ 10 * scale }
  276. safe();
  277. G0 Y${ -10 * scale }
  278. G90
  279. }
  280. std.letters.O = function O(scale=1, cutHeight=1){
  281. letterStart(scale);
  282. G0 X${ 1 * scale }
  283. draw(cutHeight);
  284. G1 X${ -1 * scale } Y${ 1 * scale }
  285. G1 Y${ 8 * scale }
  286. G1 X${ 1 * scale } Y${ 1 * scale }
  287. G1 X${ 4 * scale }
  288. G1 X${ 1 * scale } Y${ -1 * scale }
  289. G1 Y${ -8 * scale }
  290. G1 X${ -1 * scale } Y${ -1 * scale }
  291. G1 X${ -4 * scale }
  292. safe();
  293. G0 X${ 5 * scale }
  294. G90
  295. }
  296. std.letters.P = function P(scale=1, cutHeight=1){
  297. letterStart(scale);
  298. draw(cutHeight);
  299. G1 Y${10 * scale}
  300. G1 X${ 4 * scale }
  301. G1 X${ 1 * scale } Y${ -1 * scale }
  302. G1 Y${ -4 * scale }
  303. G1 X${ -1 * scale } Y${ -1 * scale }
  304. G1 X${ -4 * scale }
  305. safe();
  306. G0 X${ 5 * scale } Y${ -4 * scale }
  307. G90
  308. }
  309. std.letters.Q = function Q(scale=1, cutHeight=1){
  310. letterStart(scale);
  311. G0 X${ 1 * scale }
  312. draw(cutHeight);
  313. G1 X${ -1 * scale } Y${ 1 * scale }
  314. G1 Y${ 8 * scale }
  315. G1 X${ 1 * scale } Y${ 1 * scale }
  316. G1 X${ 4 * scale }
  317. G1 X${ 1 * scale } Y${ -1 * scale }
  318. G1 Y${ -7 * scale }
  319. G1 X${ -2 * scale } Y${ -2 * scale }
  320. G1 X${ -3 * scale }
  321. safe();
  322. G0 X${ 3 * scale } Y${ 2 * scale }
  323. draw(cutHeight);
  324. G1 X${ 2 * scale } Y${ -2 * scale }
  325. safe();
  326. G90
  327. }
  328. std.letters.R = function R(scale=1, cutHeight=1){
  329. letterStart(scale);
  330. draw(cutHeight);
  331. G1 Y${10 * scale}
  332. G1 X${ 4 * scale }
  333. G1 X${ 1 * scale } Y${ -1 * scale }
  334. G1 Y${ -4 * scale }
  335. G1 X${ -1 * scale } Y${ -1 * scale }
  336. G1 X${ -4 * scale }
  337. safe();
  338. G0 X${ 1 * scale }
  339. draw(cutHeight);
  340. G1 X${ 4 * scale } Y${ -4 * scale }
  341. safe();
  342. G90
  343. }
  344. std.letters.S = function S(scale=1, cutHeight=1){
  345. letterStart(scale);
  346. draw(cutHeight);
  347. G1 X${ 4 * scale }
  348. G1 X${ 1 * scale } Y${ 1 * scale }
  349. G1 Y${ 3 * scale }
  350. G1 X${ -1 * scale } Y${ 1 * scale }
  351. G1 X${ -3 * scale }
  352. G1 X${ -1 * scale } Y${ 1 * scale }
  353. G1 Y${ 3 * scale }
  354. G1 X${ 1 * scale } Y${ 1 * scale }
  355. G1 X${ 4 * scale }
  356. safe();
  357. G0 Y${ -10 * scale }
  358. }
  359. std.letters.T = function T(scale=1, cutHeight=1){
  360. letterStart(scale);
  361. G0 Y${ 10 * scale }
  362. draw(cutHeight);
  363. G1 X${ 6 * scale }
  364. safe();
  365. G0 X${ -3 * scale }
  366. draw(cutHeight);
  367. G1 Y${ -10 * scale }
  368. safe();
  369. G0 X${ 3 * scale }
  370. G90
  371. }
  372. std.letters.U = function U(scale=1, cutHeight=1){
  373. letterStart(scale);
  374. G0 Y${ 10 * scale }
  375. draw(cutHeight);
  376. G1 Y${ -9 * scale }
  377. G1 X${ 1 * scale } Y${ -1 * scale }
  378. G1 X${ 4 * scale }
  379. G1 X${ 1 * scale } Y${ 1 * scale }
  380. G1 Y${ 9 * scale }
  381. safe();
  382. G0 Y${ -10 * scale }
  383. G90
  384. }
  385. std.letters.V = function V(scale=1, cutHeight=1){
  386. letterStart(scale);
  387. G0 Y${ 10 * scale }
  388. draw(cutHeight);
  389. G1 Y${ -7 * scale }
  390. G1 X${ 3 * scale } Y${ -3 * scale }
  391. G1 X${ 3 * scale } Y${ 3 * scale }
  392. G1 Y${ 7 * scale }
  393. safe();
  394. G0 Y${ -10 * scale }
  395. G90
  396. }
  397. std.letters.W = function W(scale=1, cutHeight=1){
  398. letterStart(scale);
  399. G0 Y${ 10 * scale }
  400. draw(cutHeight);
  401. G1 Y${ -9 * scale }
  402. G1 X${ 1 * scale } Y${ -1 * scale }
  403. G1 X${ 1.5 * scale }
  404. G1 X${ 1 * scale } Y${ 1 * scale }
  405. G1 X${ 1 * scale } Y${ -1 * scale }
  406. G1 X${ 1.5 * scale }
  407. G1 X${ 1 * scale } Y${ 1 * scale }
  408. G1 Y${ 9 * scale }
  409. safe();
  410. G0 X${ -3.5 * scale } Y${ -5 * scale }
  411. draw(cutHeight);
  412. G1 Y${ -4 * scale }
  413. safe();
  414. G0 X${ 3.5 * scale } Y${ -1 * scale }
  415. G90
  416. }
  417. std.letters.X = function X(scale=1, cutHeight=1){
  418. letterStart(scale);
  419. draw(cutHeight);
  420. G1 Y${ 3 * scale }
  421. G1 X${ 2 * scale } Y${ 2 * scale }
  422. G1 X${ -2 * scale } Y${ 2 * scale }
  423. G1 Y${ 3 * scale }
  424. safe();
  425. G0 X${ 2 * scale } Y${ -5 * scale }
  426. draw(cutHeight);
  427. G1 X${ 1 * scale }
  428. G1 X${ 2 * scale } Y${ 2 * scale }
  429. G1 Y${ 3 * scale }
  430. safe();
  431. G0 X${ -2 * scale } Y${ -5 * scale }
  432. draw(cutHeight);
  433. G1 X${ 2 * scale } Y${ -2 * scale }
  434. G1 Y${ -3 * scale }
  435. safe();
  436. G90
  437. }
  438. std.letters.Y = function Y(scale=1, cutHeight=1){
  439. letterStart(scale);
  440. G0 X${ 3 * scale }
  441. draw(cutHeight);
  442. G1 Y${ 5 * scale }
  443. G1 X${ -1 * scale }
  444. G1 X${ -2 * scale } Y${ 2 * scale }
  445. G1 Y${ 3 * scale }
  446. safe();
  447. G0 X${ 3 * scale } Y${ -5 * scale }
  448. draw(cutHeight);
  449. G1 X${ 1 * scale }
  450. G1 X${ 2 * scale } Y${ 2 * scale }
  451. G1 Y${ 3 * scale }
  452. safe();
  453. G0 Y${ -10 * scale }
  454. G90
  455. }
  456. std.letters.Z = function Z(scale=1, cutHeight=1){
  457. letterStart(scale);
  458. G0 Y${ 10 * scale }
  459. draw(cutHeight);
  460. G1 X${ 6 * scale }
  461. G1 X${ -6 * scale } Y${ -10 * scale }
  462. G1 X${ 6 * scale }
  463. safe();
  464. G90
  465. }
  466. std.letters[' '] = function space(scale=1, cutHeight){
  467. safe();
  468. G91
  469. G0 X${scale * 6}
  470. G90
  471. }
  472. std.letters['.'] = function period(scale=1, cutHeight=0){
  473. safe();
  474. G91
  475. G0 X${1.5 * scale} Y${ 0.5 * scale }
  476. draw(cutHeight);
  477. safe();
  478. G0 X${ 1 * scale } Y${ -0.5 * scale }
  479. G90
  480. }
  481. std.letters['\n'] = function newline(scale=1, cutHeight=0){
  482. safe();
  483. G0 Y${ -12 * scale }
  484. G90
  485. G0 X0
  486. G90
  487. }