https://github.com/paulgb/penkit
Tools for pen plotting in Python
https://github.com/paulgb/penkit
Last synced: 7 months ago
JSON representation
Tools for pen plotting in Python
- Host: GitHub
- URL: https://github.com/paulgb/penkit
- Owner: paulgb
- License: mit
- Created: 2017-12-06T00:49:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-02-01T06:16:23.000Z (almost 5 years ago)
- Last Synced: 2025-05-07T18:08:12.221Z (7 months ago)
- Language: Jupyter Notebook
- Size: 6.22 MB
- Stars: 151
- Watchers: 10
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- awesome-plotters - penkit - A Python library for creating line-based SVG graphics. (Software / Vector Creation)
README
Penkit
======
**Penkit** is a library of utility functions generating `pen plots `__ from Python/numpy.
Installation
------------
Requirements: Python 2.7 or 3.x, `numpy`, `scipy`. Preview modules require `ipython` or `matplotlib`.
# pip install penkit
Documentation
-------------
- Download the `tutorial notebooks `_ or `run them on Binder `_
- `Module Documentation `_
Examples
--------
Grid Surface Projection
~~~~~~~~~~~~~~~~~~~~~~~
.. code:: python
from penkit.textures import make_grid_texture
from penkit.textures.util import rotate_texture
from penkit.surfaces import make_noise_surface
from penkit.write import write_plot
from penkit.projection import project_and_occlude_texture
# create a texture
grid_density = 68
texture = make_grid_texture(grid_density, grid_density, 100)
# rotate the texture
texture = rotate_texture(texture, rotation=65)
# create the surface
surface = make_noise_surface(blur=28, seed=12345) * 10
# project the texture onto the surface
proj = project_and_occlude_texture(texture, surface, angle=69)
# plot the result
write_plot([proj], 'examples/grid_surface.svg')
.. image:: examples/grid_surface.svg
:width: 400px
Hilbert Curve Surface Projection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: python
from penkit.fractal import hilbert_curve
from penkit.textures.util import fit_texture, rotate_texture
from penkit.surfaces import make_noise_surface
from penkit.projection import project_and_occlude_texture
from penkit.write import write_plot
# create a texture
texture = hilbert_curve(7)
# rotate the texture
texture = rotate_texture(texture, 30)
texture = fit_texture(texture)
# create the surface
surface = make_noise_surface(blur=30) * 5
# project the texture onto the surface
proj = project_and_occlude_texture(texture, surface, 50)
# plot the result
write_plot([proj], 'examples/hilbert_surface.svg')
.. image:: examples/hilbert_surface.svg
:width: 400px
----
.. image:: https://travis-ci.org/paulgb/penkit.svg?branch=master
:target: https://travis-ci.org/paulgb/penkit
.. image:: https://mybinder.org/badge.svg
:target: https://mybinder.org/v2/gh/paulgb/penkit.git/master?filepath=tutorial