If Then Paint

cnc canvas painter

Similar projects worth following
Most people who can turn a blank canvas into a beautiful mix of colors and shapes have spent years of their life devoted to the craft. This project is about equipping the average maker with the ability to create canvas paintings like a seasoned craftsman. Upload an image, define the painting parameters, and watch the cnc machine create your custom painting.

The Product

A canvas painting cnc machine and the software needed to operate it.

The Potential

  • A canvas painting machine for makers and artists.
  • A sign making tool for small businesses.
  • A canvas painting learning tool for young artists.
  • A platform for new canvas painting innovations.

History and Motivation

I began to develop a cnc machine specifically for canvas painting after competing in the 2017 competition. There were two main reasons why I started - 1) during the competition, I recognized that several advanced software and mechanical innovations were required before cnc painting would be more accessible to a larger, less technical audience and 2) I was eager for a project that would stretch my software and mechanical design skills.

Development has continued on and off for the last two and a half years. I have considered transitioning to many other projects but I always come back to the cnc painter. Its challenges and potential are very exciting. 

R&D Phases

  1. Proof of concept. This initial R&D phase will prove out all the canvas painting technologies.
  2. Market driven redesign. Not all of the proof of concept technologies will be viable for a marketable product. During this R&D, the system design will be refined to better align with market requirements.
  3. Design for manufacturing. At this point all of the R&D work specific to canvas painting has been completed and the system has been redesigned to better fit market needs. This phase involves further refinements to make the system easier and ultimately cheaper to manufacture.

Proof of Concept Design Principles

For simplicity and practicality the proof of concept prototype adheres to the following design principles:

  • No feedback control. This decreases the complexity of the motion controller and software, but increases the complexity of the mechanical design. Without feedback, the mechanics used for painting have to be predictable and repeatable.
  • Common off the shelf and rapid prototyping components only. I live in an apartment so don't have immediate access to tools for fabricating parts. I also have a full time job. If the part can't arrive in the mail or be built in less than an hour, I am not interested.
  • Unsupervised operation. Would anyone use 3D printers if you had to check them every five minutes? Of course not. It needs to complete a painting without taking up any user bandwidth.

CNC Canvas Painting Technologies

The following technologies are needed to complete the proof of concept phase of the project:

  • six degrees of freedom brush position control -> development complete
  • generate paint strokes from a bitmap image -> development complete
  • automated tool change -> in progress
  • automated brush cleaning -> development complete
  • automated paint dispensing -> in progress
  • automated paint storage -> in progress
  • automated paint mixing -> brainstorming


Solid model .step file of the 6 axis cnc painting machine.

step - 11.12 MB - 07/16/2019 at 00:32


  • generate paint strokes from a bitmap image

    John Opsahl2 days ago 0 comments

    After completing the six axis cnc mechanical design, I switched gear and focused on developing an algorithm that would generate paint strokes from any bitmap image. This log will describe the details of the algorithm and how I arrived at it. 

    At the start of development, I committed to the following requirements:

    • Must work on any bitmap image. This includes high detail images, low detail images, images with thousands of colors, images with only two colors, rectangular images, images of irregular shapes, etc.
    • Accommodate all brush profiles. This includes all brush types (filbert, round, flat, angle, etc.) and brush sizes.  Also, allow any number of brush profiles to be used for the painting or even a single color of the painting. 
    • Find the brush strokes that a human painter might choose. This is an attempt to find paint strokes along the "natural" contours of the image. I generalized this as the "window frame" problem. See details below.

    The purpose of the window frame problem is to define "human" painting style in a mathematical context. The window frame problem goes like this: Suppose you are asked to paint a rectangular window frame (like the one shown below) on canvas. Which brush size and paint strokes do you use?

    Regardless of which brush size you use, I propose that 99% of the time, you (and other humans) choose brush strokes that run parallel to the perimeter of the frame. The other 1% of the time you choose brush strokes that run at other angles relative to the perimeter of the frame and would most likely be doing so for artistic effect. The window frame problem is how do you develop an algorithm that will choose brush strokes that run parallel to the perimeter of the frame?

    Before I evaluate my brush stroke algorithm against the window frame problem let me explain at a high level how the algorithm works:

    1. Scan across an image (at an angle relative to the horizontal) using a pixel evaluation size that matches the selected brush profile. Brush profile being the area that a brush covers when it contacts the canvas.
    2. If a specified percentage of the pixels in evaluation of the scan (typically 90% or greater) match the current color being painted, mark those as valid areas.
    3. If several valid areas are adjacent to each other along the angle that the image was scanned, connect these valid points to form a brush stroke line.
    4. Repeat steps 1-3 for multiple scan angles between 0 and 180 degrees from the horizontal.
    5. Combine all possible brush stroke lines into a single list (call it brush_strokes_all and order in decreasing length.
    6. Take the first brush stroke line of brush_strokes_all list (i.e. the longest stroke line found during all scans) and put it in another list. Lets call the other list brush_strokes_final.
    7. Take the next brush stroke line of the list and determine if it overlaps any brush stroke lines currently in the brush_strokes_final list. If it doesn't overlap, add the brush stroke line to the brush_strokes_final list. If it does overlap, do nothing and move onto the next brush stroke line in brush_stroke_all.
    8. Repeat step 7 until all brush stroke lines of the brush_stroke_all have been evaluated. The brush_strokes_final is now a list of all the longest possible brush stroke lines that do not overlap.
    9. Void all areas of the image covered by the brush stroke lines in the brush_stroke_final list. 
    10. A few pixel areas the size of the brush profile may still be available at this point due to the no overlap rule. Rerun steps 1-9 until no new brush stroke lines can be created from the image. At this point that algorithm has captured all brush stroke lines needed to cover one color of the image.
    11. Repeat steps 1-10 for all paint colors.

    Step 7 is currently my best attempt at solving the window frame problem. It is still an approximate solution because the image would have to be scanned at 0 and 90 degrees from horizontal...

    Read more »

  • six degrees of freedom brush position control

    John Opsahl5 days ago 0 comments

    The first major challenge of this project was to develop a cnc machine that can orient a brush in any position relative to a horizontal canvas. There are two parts to this challenge -> 1) develop a cnc machine design capable of achieving six degrees of freedom, 2) identify a microcontroller and a gcode interpreter that can be used to operate the machine. 

    At the start of the six axis cnc machine design effort, I committed to the following mechanical design constraints:

    • Laser cut fabrication of 1/8in Baltic birch plywood for all structural components. 1/8in Baltic birch plywood is readily available through specialty lumber suppliers in Kansas City. It is a common material for laser cutting because of its relatively low price and high stiffness to thickness ratio. 1/8in Baltic birch seemed to be stiff enough based on my previous wall plotter project. 
    • A maximum laser cutter bed size of 300x600mm (12x24in). At the time, 300x600mm was the maximum bed size of the laser cutter at the Johnson County Central Resource Library in Overland Park, Kansas. Laser cutting is free at the library. Yes, I did all the laser cutting for this project at a library and it didn't cost me anything but taxes and time (guessing 10+ hours total). 
    • Tongue and groove with a 100mm zip tie method to fasten all structural components together. This fastening method worked really well for my wall plotter project, so I ran with it on this project as well.
    • 4x13x6mm v-bearings for all linear rails. Once again, this was a carry over from the wall plotter project. It is a cheap solution that gets the job done.

    I was able to get away with using a structural material with low stiffness (at least compared to other cnc machines) because the end effector of this application (i.e. a brush) is so light weight. The large electric motor at the end effector typical of cnc mills was not needed. In addition, cnc canvas painting is not a precision machining operation. A little wobble or flex in the machine structure during operation is acceptable. Maybe even desirable if it makes the painting look less robotic. 

    The development of the mechanical design began at the end effector, progressed to the three axis head, and finished with the three axis gantry. Hundreds of design decisions were made throughout the process. It doesn't seem practical to document all of those details here. In fact, it's probably even quicker if you just take a look at the design and use your best mechanical intuition to make a guess on why something was done one way and not the other. The tip I will give you is that at no point were aesthetics considered in the design. The form of all structural components is purely a result of function. A solid model .step file of the six axis cnc painter is attached to this project.

    Additional notes about the mechanical design:

    • A wire slip ring is used between the three axis head and three axis gantry to allow infinite rotation of the three axis head.
    • Wire management rails are used on the x, y, and z axes.
    • Limit switches are placed at both ends of each linear gantry axis for homing and preventing damage to the machine during operation. No limit switches are incorporated into the three axis head rotatory axes. Instead, each rotary axis has a physical method for setting the zero position.
    • Outside dimesions of the six axis cnc painting machine are approximately 710x710x915mm (28x28x36in)
    • Total workspace area when the brush is in the vertical position is approximately 300x400mm (12x16in)
    • Z-axis movement: 205mm
    • Three axis gantry accelerations should be adjusted so that the machine does not shake during operation.

    Identifying a microcontroller and gcode interpreter were the next part of this challenge. I initially started out using Mach3 and it worked great. But I really wanted a cheap open source option. I...

    Read more »

View all 2 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates