Giter VIP home page Giter VIP logo

tsp_art_tools's Introduction

Art Tools for GoCupi

Summary

This repository contains code that assists in converting images to be used by the gocupi Polar plotter (www.gocupi.com)

Gocupi can draw ANY IMAGE! As long as the image is an SVG with only straight lines. :) This presents some challenges if you want to draw a photo or complicated art. These scripts are part of the process to get an image converted over to something gocupi can understand.

The basic steps are:

  • Convert your image to a bunch of dots using Gimp. A process called Stippling. It looks like this:
  • Connect those dots with straight lines to create shading and weight to your drawing. (That is what these scripts do!) Looks like this:
  • Cleanup stray lines using Gimp again. Final looks like this:
  • Draw with gocupi! Looks like this:

Quickstart

  1. Install the necessary dependencies
  2. Stipple your image using Gimp
  3. Run python3 tspart.py ./path/to/your/image.jpg
    This will generate image.svg in your image path
  4. OPTIONAL Remove unnecessary lines in Gimp
  5. Use gocupi svg 200 image.svg to create your image

Installation

This package has no python dependencies but it does require an external package to create the paths. This package does the hard math of figuring out the best path in between the dots.

OS X:

Install homebrew (https://brew.sh/) run brew install homebrew/science/concorde

Windows:

While binary executables are available for concorde and linkern for Windows, they require a minimal cygwin install. See http://www.tsp.gatech.edu/concorde/downloads/downloads.htm

Overview of scripts

tspart.py

Python script to accept as input a black and white bitmap file in PBM format and produce as output a SVG file (TSP art) arrived at by using the fast, heuristic TSP solver linkern.

In addition to PBM files, a simple format allowing (x, y) or (x, y, radius) coordinates is also supported. (E.g., the format output by some stippling software.) See the comments in tspbitcity.py for further details.

tspbitcity.py

Python class used by tspart.py. This is the class which reads in a PBM file and can generate a TSPLIB format file for concorde and linkern. Also, using a TSP tour, it can generate an SVG file.

If run as a standalone Python script, tspbitcity.py will generate a TSPLIB file from a PBM file.

tspsolution.py

Python class used by tspart.py. This class reads a solution file from either concorde or linkern and determines the "tour". This "tour" is then used by tspart.py to generate the output SVG file.

Stippling Instructions

  1. Load your image into Gimp
  2. Convert to grayscale: Image > Mode > Grayscale
  3. Wash out the image a. Colors > Levels... b. Set the "All Channels" under "Output Levels" to 180 - 245
  4. Dither the image a. Image > Mode > Indexed... b. Select "Use black and white (1-bit palette) under "Colormap" c. Select "Floyd-Steinberg (normal) under "Color dithering" d. Click "Convert" button
  5. Save the file as a PBM format file; choose "raw" when asked

If step 4 produces too many points, then start over (edit undo) until your back to the grayscale image. Then try scaling the image down to 50%, 25%, or more with Image > Scale Image....

Also see this great video here: https://youtu.be/TKy2fxsmssg?t=7m29s

tsp_art_tools's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

scottvr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.