Skip to content

Commit

Permalink
added pip package
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielle-ohlson committed Oct 15, 2021
1 parent 66045b3 commit c2f8002
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 11 deletions.
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ scripts/*
# except the following: (files that import libraries)
!/scripts/lib.py
!/scripts/__init__.py

# and any demo/example/debug files:
!/scripts/*-demo.py
!/scripts/*-example.py
!/scripts/*-debug.py
# !/scripts/stitch-tube.py


# ignore all user-created graphics, but...
graphics/*

# (keep demo/example/debug graphics)
!/graphics/*-demo.png
!/graphics/*-example.png
!/graphics/*-debug.png
# !/graphics/cactus-shape-example.png
# !/graphics/cactus-stitch-front-example.png
# !/graphics/cactus-stitch-back-example.png

# Distribution / packaging
build/
dist/
*.egg-info/
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ Different stitch pattern graphics can be provided for the front and back of the
TODO

# Workflow
Generate the graphics that you will be using for the knitted object. It is recommended that you place these graphics in the `graphics` sub-directory.\
Create a python file (e.g. `my-file.py`) in the `scripts` sub-directory and import the libraries by adding the following code to your file:
## Installation
From the command line, install the [package](https://pypi.org/project/knitout-kniterate-3D/1.0.0/) with pip:
```
from lib import knit3D, knitout
pip install knitout-kniterate-3D
```
(*NOTE:* the `lib.py` file makes it possible to import the relevant libraries located in the `src` folder directly from the `scripts` folder)

## Example Usage
Generate the graphics that you will be using for the knitted object. It is recommended that you place these graphics in the `graphics` sub-directory.\
After installing the package, create a python file (e.g. `my-file.py`) and add the following code to your file:
```
from knitout_kniterate_3D import knit3D, knitout
```
Then add the following code to initiate the knitout writer:
```
k = knitout.Writer('1 2 3 4 5 6')
Expand Down
48 changes: 48 additions & 0 deletions knitout_kniterate_3D/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# knitout-kniterate-3D
Code for producing [knitout](github.com/textiles-lab/knitout) files to do 3D knitting on the [kniterate](kniterate.com) knitting machine (and also optionally adding stitch patterns along the 3D surface).

# Graphic Specifications
## Overview
The program uses 2D raster (or bitmap) graphics (with full opacity!) to generate knitout files for 3D shapes that can then be converted to knitting machine instructions in k-code using the [knitout-to-kniterate-backend](github.com/textiles-lab/knitout-backend-kniterate). It also allows for incorpating stitch patterns to overlay onto the shape graphic (kind of like a cookie cutter).

You can use adobe photoshop or [photopea](photopea.com) (a fantastic & free in-browser photoshop alternative) to create these graphics.

For all of these graphics, an individual pixel is mapped to an individual stitch (so the height and width of the graphic respectively determine the row and needle count of the resulting knitted object). If the stitch pattern graphic is a different size from the shape graphic, it will be resized to match the latter.

## 3D Shapes
The graphic that represents the shape should have a white background and a flat black fill as the shape. This graphic will be used for both the front and the back of the shape (currently, the program does not support variation in these).

## Stitch Patterns
Optionally, the shape can be composed of a variety stitch patterns at different points along its 3D surface. This is acheived by processing user-provided 2D raster graphics that include blobs of unique colors to designate an area where a particular stitch pattern should be used when knitting the given shape. The specifications of each stitch pattern are based on the info you pass as arguments to the `shapeImgToKnitout` function.\
(*NOTE:* no two blobs separated by any white space can be the same color, even if they represent the exact stitch patterns).\
Different stitch pattern graphics can be provided for the front and back of the shape.

# Function Parameters
## `shapeImgToKnitout`
TODO

# Workflow
## Installation
From the command line, run:
```
pip install knitout-kniterate-3D
```

## Example Usage
Generate the graphics that you will be using for the knitted object. It is recommended that you place these graphics in the `graphics` sub-directory.\
After installing the package, create a python file (e.g. `my-file.py`) and add the following code to your file:
```
from knitout_kniterate_3D import knit3D, knitout
```
Then add the following code to initiate the knitout writer:
```
k = knitout.Writer('1 2 3 4 5 6')
```
Then, call the `shapeImgToKnitout` function from the `knit3D` library and pass any relevant information (see the function docstring in `knit3D.py` [located in the `src` sub-directory] for more information).
```
TODO
```
Finally, use the knitout writer to output the file:
```
k.write(f'{fileName}.k')
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion scripts/cactus-gripper-demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from lib import knitout, knit3D
# from lib import knitout, knit3D
from knitout_kniterate_3D import knit3D, knitout

k = knitout.Writer('1 2 3 4 5 6')

Expand Down
3 changes: 2 additions & 1 deletion scripts/donut-gripper-demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from lib import knitout, knit3D
# from lib import knitout, knit3D
from knitout_kniterate_3D import knit3D, knitout

k = knitout.Writer('1 2 3 4 5 6')

Expand Down
3 changes: 2 additions & 1 deletion scripts/lib.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys, os

sys.path.append('../src/')
# sys.path.append('../src/')
sys.path.append('../knitout_kniterate_3D/')

import knitout
import knit3D
Expand Down
3 changes: 2 additions & 1 deletion scripts/stitch-tube-demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from lib import knitout, knit3D
# from lib import knitout, knit3D
from knitout_kniterate_3D import knit3D, knitout

k = knitout.Writer('1 2 3 4 5 6')

Expand Down
23 changes: 23 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import setuptools

with open('README.md', 'r') as fh:
long_description = fh.read()

setuptools.setup(
name="knitout_kniterate_3D",
version="1.0.0",
author="Gabrielle Ohlson",
author_email="[email protected]",
description="Code for producing knitout files to do 3D knitting on the kniterate knitting machine (and also optionally adding stitch patterns along the 3D surface).",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/gabrielle-ohlson/knit3D",
# packages=setuptools.find_packages('knitout_kniterate_3D'),
packages=['knitout_kniterate_3D'],
install_requires=['numpy', 'Pillow'],
classifiers=(
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
),
)
Empty file added test.py
Empty file.

0 comments on commit c2f8002

Please sign in to comment.