API Reference¶
Core Data Model¶
-
class
pyweaving.
Color
(rgb)[source]¶ A color type. Internally stored as RGB, and does not support transparency.
-
css
¶
-
-
class
pyweaving.
Draft
(num_shafts, num_treadles=0, liftplan=False, rising_shed=True, start_at_lowest_thread=True, date=None, title=u'', author=u'', address=u'', email=u'', telephone=u'', fax=u'', notes=u'')[source]¶ The core representation of a weaving draft.
-
add_weft_thread
(color=None, index=None, shafts=None, treadles=None)[source]¶ Add a weft thread to this draft.
-
advance
()[source]¶ - Given a base draft, make it ‘advance’. Essentially:
- 1. Repeat the draft N times, where N is the number of shafts, in both the warp and weft directions. 2. On each successive repeat, offset the threading by 1 additional shaft and the treadling by one additional treadle.
-
all_threads_attached
()[source]¶ Check whether all threads (weft and warp) will be “attached” to the fabric, instead of just falling off.
-
compute_drawdown_at
(position)[source]¶ Return the thread that is on top (visible) at the specified zero-indexed position.
-
compute_floats
()[source]¶ Return an iterator over every float, yielding a tuple for each one:
(start, end, visible, length, thread)
FIXME: This ignores the back side of the fabric. Should it?
-
compute_longest_floats
()[source]¶ Return a tuple indicating the longest floats for warp, weft.
FIXME This might be producing incorrect results.
-
compute_warp_crossings
()[source]¶ Iterate over each warp row and compute the total number of thread crossings in that row.
-
compute_weft_crossings
()[source]¶ Iterate over each weft row and compute the total number of thread crossings in that row. Useful for determining sett.
-
flip_warpwise
()[source]¶ Flip/mirror along the warp axis: e.g. looking at the front of the loom, the near side of the fabric becomes the far, and the far becomes the near.
-
flip_weftwise
()[source]¶ Flip/mirror along the weft axis: e.g. looking at the front of the loom, the left side of the fabric becomes the right, and the right becomes the left.
-
classmethod
from_json
(s)[source]¶ Construct a new Draft instance from its JSON representation. Counterpart to
.to_json()
.
-
invert_shed
()[source]¶ Convert from rising shed to sinking shed, or vice versa. Note that this will actually update the threading/tie-up to preserve the same drawdown: if this is not desired, simply change the .rising_shed attribute.
-
make_selvedges_continuous
(add_new_shafts=False)[source]¶ Make the selvedge threads “continuous”: that is, threaded and treadled such that they are picked up on every pick. This method will try to use the liftplan/tieup and switch selvedge threads to alternate shafts. If that is impossible and
add_new_shafts
new shafts will be added to handle the selvedge threads.FIXME This method works, but it does not necessarily produce the subjectively “best” solution in terms of aesthetics and structure. For example, it may result in longer floats than necessary.
-
reduce_active_treadles
()[source]¶ Optimize to use the fewest number of active treadles on any given pick, because not every weaver is an octopus. Note that this may mean using more total treadles.
Cannot be called on a liftplan draft.
-
reduce_shafts
()[source]¶ Optimize to use the fewest number of shafts, to attempt to make a complex draft possible to weave on a loom with fewer shafts. Note that this may make the threading more complex or less periodic.
-
reduce_treadles
()[source]¶ Optimize to use the fewest number of total treadles, to attempt to make a complex draft possible to weave on a loom with a smaller number of treadles. Note that this may require that more treadles are active on any given pick.
Cannot be called on a liftplan draft.
-
selvedge_continuous
(low)[source]¶ Check whether the selvedge corresponding to the lowest-number thread is continuous.
-
selvedges_continuous
()[source]¶ Check whether or not both selvedge threads are “continuous” (will be picked up on every pick).
-
sort_threading
()[source]¶ Reorder the shaft assignment in threading so that it follows as sequential of an order as possible.
For a liftplan draft, will change the threading and liftplan.
For a treadled draft, will change the threading and tieup, won’t change the treadling.
-
sort_treadles
()[source]¶ Reorder the treadle assignment in tieup so that it follows as sequential of an order as possible in treadling.
Will change the tieup and treadling, won’t change the threading. If sorting both threading and treadles, call
.sort_threading()
before calling.sort_treadles()
.Cannot be called on a liftplan draft.
-
WIF Import / Export¶
-
class
pyweaving.wif.
WIFReader
(filename)[source]¶ A reader for a specific WIF file.
-
allowed_units
= (u'decipoints', u'inches', u'centimeters')¶
-
Draft Rendering¶
-
class
pyweaving.render.
ImageRenderer
(draft, liftplan=None, margin_pixels=20, scale=10, foreground=(127, 127, 127), background=(255, 255, 255), markers=(0, 0, 0), numbering=(200, 0, 0))[source]¶
-
pyweaving.render.
SVG
¶
Instructions¶
-
pyweaving.instructions.
describe_interval
(secs)[source]¶ Return a string describing the supplied number of seconds in human-readable time, e.g. “107 hours, 42 minutes”.
-
pyweaving.instructions.
print_shafts
(draft, connected)[source]¶ Print the shaft lift state, as for a table loom.
-
pyweaving.instructions.
threading
(draft, repeats=1, color_table={0: u'red', 1: u'yellow', 2: u'blue', 3: u'white', 4: u'red', 5: u'yellow', 6: u'blue', 7: u'white', 8: u'red', 9: u'yellow', 10: u'blue', 11: u'white', 12: u'red', 13: u'yellow', 14: u'blue', 15: u'white', 16: u'red', 17: u'yellow', 18: u'blue', 19: u'white', 20: u'red', 21: u'yellow', 22: u'blue', 23: u'white', 24: u'red', 25: u'yellow', 26: u'blue', 27: u'white', 28: u'red', 29: u'yellow', 30: u'blue', 31: u'white', 32: u'red', 33: u'yellow', 34: u'blue', 35: u'white', 36: u'red', 37: u'yellow', 38: u'blue', 39: u'white', 40: u'red', 41: u'yellow', 42: u'blue', 43: u'white', 44: u'red', 45: u'yellow', 46: u'blue', 47: u'white', 48: u'red', 49: u'yellow', 50: u'blue', 51: u'white', 52: u'red', 53: u'yellow', 54: u'blue', 55: u'white', 56: u'red', 57: u'yellow', 58: u'blue', 59: u'white', 60: u'red', 61: u'yellow', 62: u'blue', 63: u'white'})[source]¶ Print threading instructions.
Utility Generators¶
-
pyweaving.generators.twill.
twill
(size=2, warp_color=(0, 0, 100), weft_color=(255, 255, 255))[source]¶