Generally, movement in a CNC, FDM-Printer, laser cutter, and Plotter has the XY plane decoupled from the Z-axis in most operations. As a result, the path in the XY plane is in 2D. But how to get to a path? Well, we have 2 variants:
Pixel
Most pictures store information as Pixels: each pixel on a grid has a color assigned to it. Scaling the picture does alter the grid size. These pictures are very hard to plot, unless you have your machine interpret each pixel of a given color as a specific movement operation. For example, each pixel of black color in a monochrome picture could be translated as a square-movement of a certain size, using the top-left corner of the square for the operation's reference. In G-code, drawing a line around the Pixel X=10 Y=10 with a grid size of 1 mm looks like this:
G90 ; absolute mode!
G1 X10 Y10
G1 X1 E1
G1 Y1 E1
G1 X-1 E1
G1 Y-1 E1
Vector
proper 2D-Pathes are stored only in Vector graphics. If you can, Vector graphics can contain the exact path you want your machine to follow. A typical format is .svg
. It contains already the start position of path and how to follow it. Going from Vector Graphic to G-code just needs you to add G1 before each part of the path instruction and E commands at the end to operate whatever tool you due - be it spinning the drill in a CNC, extruding filament in a printer, turning on a laser or pushing down the printhead in a plotter.