{"id":25338348,"url":"https://github.com/lavolpecheprogramma/gcode-file","last_synced_at":"2025-10-29T09:31:13.119Z","repository":{"id":57245436,"uuid":"228070869","full_name":"lavolpecheprogramma/gcode-file","owner":"lavolpecheprogramma","description":"Create and save a gcode file in browser via javascript","archived":false,"fork":false,"pushed_at":"2024-04-08T09:16:06.000Z","size":41,"stargazers_count":10,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T19:52:36.874Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lavolpecheprogramma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-14T18:36:20.000Z","updated_at":"2024-01-14T12:35:07.000Z","dependencies_parsed_at":"2022-09-01T04:31:27.960Z","dependency_job_id":null,"html_url":"https://github.com/lavolpecheprogramma/gcode-file","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavolpecheprogramma%2Fgcode-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavolpecheprogramma%2Fgcode-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavolpecheprogramma%2Fgcode-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavolpecheprogramma%2Fgcode-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lavolpecheprogramma","download_url":"https://codeload.github.com/lavolpecheprogramma/gcode-file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238798461,"owners_count":19532276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-14T07:00:56.659Z","updated_at":"2025-10-29T09:31:07.798Z","avatar_url":"https://github.com/lavolpecheprogramma.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gcode-file\n\nCreate and save a gcode file in browser via javascript\n\n### Installation\n\nYou can grab it as an `npm` package\n```bash\nnpm i --save @gcode-file\n```\n\n### Example\n\n```\nconst { createPath, pathsToPolylines } = require('canvas-sketch-util/penplot');\nconst GCodeFile = require('gcode-file');\nconst gCode = new GCodeFile({\n\tfeedRate: 8000, // G1 movement (drawing speed)\n  seekRate: 8000, // G0 movement (no drawing speed)\n\tonCommand: 'M03S20',\n\toffCommand: 'M03S0',\n\tpowerDelay: 0.2,\n\tfileName: 'sketch',\n\tpaperSize: [210, 297], // A4 size in mm\n\tmargin: 10, // or [10, 10] (top/bottom and left/right margin) or [10,10,10,10] (top/left/bottom/right)\n\tflipX: false,\n\tflipY: false\n})\n\n// ... your canvas setup ...\ngCode.updateCoordsArea(canvas.width, canvas.height);\n\nconst p = createPath();\np.moveTo(10, 10);\np.lineTo(100, 100);\n\n// Converting path to polylines...')\nconst lines = pathsToPolylines([p]);\n\nconsole.log('Add data to gcode file...')\ngCode.addPolylines(lines)\n\nwindow.addEventListener('keydown', function(){\n  if((event.ctrlKey || event.metaKey) \u0026\u0026 event.which == 83) {\n    event.preventDefault();\n    \n    console.log('Download file...')\n    gCode.downloadFile()\n    return false;\n  }\n})\n```\n\n## Methods\n\n### updateConfig(newConfig)\nAccepts an object with the new config (or a part of it). It is useful if you modify your sketch size or print settings at runtime with a gui for example.\n\n### updateCoordsArea(width, height)\nUpdate the dimension of your drawing area. It is necessary to know how map the coordinates of your paths to the paper dimension.\n\n### moveTo(x, y)\nWrap all the command to move the plot without draw\n\n### drawLine(x, y)\nWrap all the command to move the plot drawing\n\n### addPolylines(polylines)\nAccepts an array on polylines and generate all the commands to draw the polylines.\n\n### addLayer(name)\nAdd layer that will be saved on separate file.\n\n### downloadFile()\nGenerate and download the gcode file\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flavolpecheprogramma%2Fgcode-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flavolpecheprogramma%2Fgcode-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flavolpecheprogramma%2Fgcode-file/lists"}