Skip to content

core algorithm to generate a String art from a portrait

License

Notifications You must be signed in to change notification settings

arglin/linetoart-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

linetoart-core

core algorithm to generate the String Art from a portrait.

This artwork is created by crossing one single string around fixed number of nails which form a shape like a circle, square etc.

how to use

L2ASolver solver = L2ASolverFactory.getSolver(L2ASolverMethods.GREEDY_LAZY_DEPTH);

/**
 * if the image is not a square, then it will take the center square part to process
 * @param image image to be processed, make sure the image size is at least 500*500
 * @param nailNum the total nail number to form the portrait
 * @return Solution
 */
L2ASolution solution = solver.solve(image, 300);

/**
 * the path that forms the portrait, each item represents the nail index(starts from 0)
 */
List<Integer> path = solution.getPath();

/**
 * the net that forms the portrait, each key-value represents the connected nail indexs of the key nail
 */
Map<Integer, Set<Integer>> net = solution.getNet();

/**
 * get all nails information
 */
Nail[] nails = solution.getAllNails();

smaple

image image

version

v1.0

  • initial version of linetoart-core

About

core algorithm to generate a String art from a portrait

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages