CNC Line Art




Introduction: CNC Line Art

About: 55+ years in electronics, computers, and teaching ... now retired.

This instructable explains how to create a color drawing on a CNC plotter.

Color photos comprise overlayed patterns of CMYK ink dots on white paper [1]

We can replicate this effect on a plotter if we extract and convert the CMYK information in a photo into four separate continuous-line drawings and assign a different pen color to each image. [2]

The software for converting the CMYK image information in your photos to g-code is provided.

A suitable plotter is described in the following instructables:

Excluding the plotter, the estimated cost of materials for this project is $5.



The insets in photo 1 show the cyan, magenta, yellow, and black (CMYK) color information.

The magenta continuous line drawing is shown on the left.


The right-hand dithered image in photo 2 is made entirely from thousands of black and white dots.

To reduce the number of pen-lifts we convert the image into a series of continuous lines by joining the adjacent dots.

Each line in my algorithm has a maximum of 1000 coordinates.

Step 1: Material

The following consumables are required:

  • 1 only Cyan pen
  • 1 only Magenta pen
  • 1 only Yellow pen
  • 1 only Black pen
  • Drawing paper

Excluding the plotter, the estimated cost of materials for this project is $5.

Step 2: Theory

The small insets in the above photos show the Cyan, Magenta, Yellow and BlacK (mono) grayscale information in the color photo.

The included software extracts this information and converts each into a series of continuous line drawings.

The left-hand images show the continuous line plotter drawings obtained when using a matching pen color.

A color drawing is obtained by superimposing all four images and changing the pen colors.

Step 3: Software

The following software is required:


  • Install Processing 3
  • Copy TSP_Art.pde into a Processing Sketch and save it without the .pde file extension. This creates a TSP_Art folder. (TSP stands for travelling sales person)
  • Copy GPP.pde into a Processing sketch and save it without the .pde file extension. This creates a GPP file folder. (GPP stands for Gcode Pre-Processor)

Step 4: Creating the G-code Files

Step 1

Resize a copy of your image using Fotosizer and place it in your TSP_Art folder.

The required print size is 1mm per pixel.

Alternately you can go for a large screen size and scale the g-code using the _gcodeScaleFactor parameter in the heading.

Step 2

Make the following changes to the heading in CNC_Art.pde

// ------------------------
//  declarations
// ------------------------
PrintWriter monoOutput;
PrintWriter cyanOutput;
PrintWriter magentaOutput;
PrintWriter yellowOutput;

PImage _source;

PImage _mono; 
PImage _cyan;
PImage _magenta;
PImage _yellow; 

int _resolution = 4; 
float _gcodeScaleFactor = 0.338;

int _width;
int _height;

// ----- trace() parameters
boolean recursionFlag;  //3x3 matrix scan
boolean lastCommandG00 = false;
int lastX = 0; 
int lastY = 0;
int recursionDepth; 

// ------------------------
//  setup()
// ------------------------
void setup() {

  // ----- screen dimensions
  size(1024, 768);  

  // ----- get source image
  _source = loadImage("flower.jpg");
  image(_source, _source.width, 0);                                       

  • Change the filename from “Flower.jpg” to that of your image.
  • Change the “size” dimensions from 1024, 768 to that of your image. My Flower.jpg image was 512 x 768 pixels. I used 1024 which is twice 512 so that you can see the before and after images.
  • Leave the resolution at 4 ... you can change that later.
  • The _gcodeScaleFactor sets your final print size. In my case 0.338 x 768pixels = 260mm which will fit on a sheet of A4 paper.
  • Click the top left arrow in Processing. A composite image will show on your screen. Your TSP_art folder should now contain the following gcode (text) files:
    • mono.ngc
    • cyan.ngc
    • magenta.ngc
    • yellow.ngc
  • Parse each of the above files through the attached g-code preprocessor. Detailed instructions for doing this are given in Step 5 of my instructable[1]



The attached GPP.pde file differs from that in the above instructable ... it adds an F6000 (feed) command at the start otherwise GRBL throws an error.

Step 5: Plotting an Image

Photo 1 shows the “mono” image in UGS (Universal G-code Sender)

Photo 2 shows the corresponding plotter image

Photo 3 shows the completed mono image

Photo4 shows the composite image obtained when all four CMYK images are overlaid and fine tipped pens are used.

Step 6: Adjusting the Continuous Line Images

The included software allows for creativity:

  • Photo 1 shows the image when the resolution is set to 8 and a fine tip pen is used.
  • Photo 2 shows the image when the resolution is set to 4 and a fine tip pen is used
  • Photo 3 shows the image when the resolution is set to 4 and a wide tip pen is used.
  • Photo 4 shows the image when the resolution is set to 1 and a fine tip pen is used.

The plot time and file sizes are inversely proportional to the resolution.

Four images at a resolution of 4 took approximately 5 hours.

Step 7: Summary

This instructable explains how to create color images using a CNC plotter.

Five freeware software packages are required.

The quality of of the finished drawings depends on the pen widths and drawing resolution you choose.

Excluding the plotter, the estimated cost of materials for this project is $5.

  Click here   to view my other instructables.

Be the First to Share


    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • Big and Small Contest

      Big and Small Contest
    • Make It Bridge

      Make It Bridge


    Sir, you are a wonderful person who really wants to spread knowledge to society. Thanks for that.


    Reply 1 year ago

    Thanks for commenting ;)


    1 year ago

    hi, this project is awsome.

    but, can i run this gcode in normal grbl firmware with z axis?


    Question 1 year ago on Step 5

    Hi Lingib,
    I'm working through this currently. I've went through the whole instructable but cannot for the life of me work out how to get the paths to be plotted as more of a line as opposed to many dots. My prints are just thousands of dots instead of lines. Any tips or help to adjust how the algorithm works to create lines are much appreciated!


    Answer 1 year ago

    Thank you for your interest in my project :)

    Are you able to attach a snipping-tool/screen-grab image of what you are seeing to your comment ... use a low resolution image no greater than say 500 pixels and set the resolution to 8.

    No need to print ... just view using UGS or use an online g-code viewer such as