You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letsettings={ppi: {x: 254,y: 254},// Pixel Per Inch (25.4 ppi == 1 ppm)toolDiameter: 0.1,// Tool diameter in millimetersrapidRate : 1500,// Rapid rate in mm/min (G0 F value) nullish value to disablefeedRate : 500,// Feed rate in mm/min (G1 F value)rateUnit : 'mm/min',// Rapid/Feed rate unit [mm/min, mm/sec]beamRange: {min: 0,max: 1},// Beam power range (Firmware value)beamPower: {min: 0,max: 100},// Beam power (S value) as percentage of beamRangemilling : false,// EXPERIMENTALzSafe : 5,// Safe Z for fast movezSurface : 0,// Usinable surface (white pixels)zDepth : -10,// Z depth (black pixels)passDepth: 1,// Pass depth in millimetersoffsets : {X: 0,Y: 0},// Global coordinates offsetstrimLine : true,// Trim trailing white pixelsjoinPixel: true,// Join consecutive pixels with same intensityburnWhite: true,// [true = G1 S0 | false = G0] on inner white pixelsverboseG : false,// Output verbose GCode (print each commands)diagonal : false,// Go diagonally (increase the distance between points)precision: {X: 2,Y: 2,S: 4},// Number of decimals for each commandsnonBlocking: true,// Use setTimeout to avoid blocking the UIfilters: {smoothing : 0,// Smoothing the input image ?brightness : 0,// Image brightness [-255 to +255]contrast : 0,// Image contrast [-255 to +255]gamma : 0,// Image gamma correction [0.01 to 7.99]grayscale : 'none',// Graysale algorithm [average, luma, luma-601, luma-709, luma-240, desaturation, decomposition-[min|max], [red|green|blue]-chanel]shadesOfGray: 256,// Number of shades of gray [2-256]invertColor : false// Invert color...},onProgress : null,// On progress callbacksonProgressContext: null,// On progress callback contextonDone : null,// On done callbackonDoneContext: null,// On done callback contextonAbort : null,// On abort callbackonAbortContext: null// On abort callback context}
Usages
importRasterToGcodefrom'lw.raster-to-gcode'// Create RasterToGcode objectletrasterToGcode=newRasterToGcode(settings)// Register events callbacksrasterToGcode.on('progress',function(event){console.log('onProgress:',event);// event = { gcode, percent }}).on('done',function(event){console.log('onDone:',event);// event = { gcode }});// <file> can be Image, File URL object or URL string (https://* or data:image/*)rasterToGcode.load(file).then(function(rtg){console.log('rasterToGcode:',rtg);// rtg === rasterToGcoderasterToGcode.run();// Return gcode array if nonBlocking = false}).catch(function(error){console.error('error:',error);});