Skip to main content

A knitting chart visualization tool

Project description

KnitVis

logo

A Python toolkit for visualizing and designing double knitting patterns.

Overview

KnitVis helps knitters design and visualize double knitting projects. It provides tools to:

  • Create and manipulate knitting charts and canvases
  • Visualize patterns as they would appear in the final knitted piece
  • Track progress during the knitting process
  • Convert between different pattern representations
  • Support for colorwork in double knitting projects

preview

Installation

pip install knitvis

Features

  • Knitting Chart Generation: Convert patterns to knitting charts with symbols for knit and purl stitches
  • Colorwork Support: Define custom color palettes for your projects
  • Progress Tracking: Log your knitting progress with row and section tracking
  • Pattern Visualization: See how your pattern will look when knitted
  • JSON Import/Export: Save and load your patterns in JSON format
  • GUI: Powerful PyQt GUI with support of backgrounds and multiple editing modes
  • Double Knitting Canvas: Create and manipulate binary patterns for double knitting projects

Usage Examples

Basic Usage

"""
Basic KnitVis usage example: Heart pattern

This example demonstrates how to:
1. Create a simple knitted heart pattern
2. Define custom colors for the pattern
3. Render it as a realistic knitted fabric 
4. Also display the standard chart representation
"""

from knitvis.chart import KnittingChart
import numpy as np
import matplotlib.pyplot as plt

# Define a simple heart pattern using a boolean array
heart_colors = np.array([
    [0, 0, 0, 0, 0, 0, 1],
    [0, 0, 1, 0, 1, 0, 0],
    [0, 1, 1, 1, 1, 1, 0],
    [0, 1, 1, 1, 1, 1, 0],
    [0, 0, 1, 1, 1, 0, 0],
    [0, 0, 0, 1, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0],
], dtype=bool)

# Create a pattern with all knit stitches
pattern = np.zeros(heart_colors.shape, dtype=int)

# Define colors for the pattern
colors = np.zeros((*pattern.shape, 3), dtype=int)
colors.fill(180)  # Fill with gray (180,180,180)

# Set heart sections to red
for i in range(pattern.shape[0]):
    for j in range(pattern.shape[1]):
        if heart_colors[i, j]:
            colors[i, j] = [220, 50, 50]  # Red for heart

# Create the knitting chart with our pattern and colors
chart = KnittingChart(pattern, colors)

# Render the pattern as realistic knitted fabric
fig = chart.render_fabric()

# Also show the original chart representation
chart.display_chart()

# Show the visualizations
plt.show()

Loading Patterns from JSON

from knitvis import KnittingChart

# Load a chart from a JSON file
chart = KnittingChart.from_json("my_pattern.json")

# Do something with the chart

GUI

python3 knitvis/gui/main.py

gui

Documentation

For more detailed documentation and examples, see the sample notebooks in the project repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

knitvis-0.1.0.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

knitvis-0.1.0-py3-none-any.whl (53.7 kB view details)

Uploaded Python 3

File details

Details for the file knitvis-0.1.0.tar.gz.

File metadata

  • Download URL: knitvis-0.1.0.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.6 Linux/6.8.0-52-generic

File hashes

Hashes for knitvis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a89a4a0c462af2ebc641cfa31e4b33bbebb22877e9b3e3e84f2e08e262250384
MD5 1d5ff6847f23b336497508823e83b1e8
BLAKE2b-256 191f5d15a6e56357559cc747db6373bda6ab9c9ceed155c0208549af3d31f314

See more details on using hashes here.

File details

Details for the file knitvis-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: knitvis-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 53.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.6 Linux/6.8.0-52-generic

File hashes

Hashes for knitvis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af0a6c3d9b4ed7fb2caca8d765c554a3a571670dc019bfa24e4716e1543cf4ab
MD5 f186fee389bf45c488589240bd4ddb8c
BLAKE2b-256 7624065f74442a950a6ca331ed491279aca6dd1725725b572c346e78243b3974

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page