TabletWeaving
Documentation for TabletWeaving.
Tablets
A tablet or card is a square piece of card stock.
It has a front and a back.
It has a hole on each of it's four corners.
When looking at the front of the card, the holes are labeled A, B, C, and D clockwise.
The edges of the card are numbered, with the edge from corner A to corner B numbered 1. The edge between B and C numbered 2, and so on around the card.
For weaving, one warp thread passes through each hole.
The four warp threads for a tablet pass from the warp beam, through the tablet, to the cloth beam. They can pass through the tablet from BackToFront
or FrontToBack
.
Which thread passes through which hole, and how the tablet is threaded, can not change once the loom is warped.
It's easier to think about how the stitches are formed if the tablets are facing (either back or front depending on threading) the weaver. For compactness though the cards are stacked so that the weaver is facing their edges. When stacked, each tablet can be oriented FrontToTheRight or FrontToTheLeft.
Which direction a tablet is facing when it is stacked can be changed during weaving.
For each new row, each tablet must be rotated, and its stacking may be flipped. These operations affect the locations of the labeled holes (and their warp threads) relative to the loom.
Tablet Structure
We represent each edge of a tablet by a TabletEdge
and each hole by a TabletHole
:
TabletWeaving.TabletHole
— TypeA TabletHole
represents one of the corner holes in a tablet.
TabletWeaving.TabletEdge
— TypeA TabletEdge
represents a single edge of a tablet.
The functions next
, previous
, and opposite
can be applied to a TabletHole
or a TabletEdge
to get the next, previous, or opposite one respectively.
TabletWeaving.next
— Functionnext(::TabletHole)::TabletHole
next(::TabletEdge)::TabletEdge
Return the next hole or edge from the argument, clockwise around a tablet.
TabletWeaving.previous
— Functionprevious(::TabletHole)::TabletHole
previous(::TabletEdge)::TabletEdge
Return the previous hole or edge from the argument, counterclockwise around a tablet.
TabletWeaving.opposite
— Functionopposite(::TabletHole)::TabletHole
opposite(::TabletEdge)::TabletEdge
Return the opposite hole or edge from the argument.
TabletWeaving.next_hole
— Functionnext_hole(::TabletEdge)
Return the hole following the specified edge.
TabletWeaving.previous_hole
— Functionprevious_hole(::TabletEdge)
Return the hole preceeding the specified edge.
Tablet Threading
How the warp threads pass through a tablet, the TabletThreading
, can either be BackToFront
or FrontToBack
.
for BackToFront
threading, warp threads pass from the warp beam through the tablet from back to front and then to the cloth beam.
For FrontToBack
threading, Warp threads pass from the warp beam through the tablet from front to back and then to the cloth beam.
These threadings also have a concise textual representation. BackToFront
can be represented by /
or z
. FrontToBack
can be represented by \\
or s
.
TabletWeaving.BackToFront
— TypeWarp threads pass from the warp beam through the tablet from back to front.
TabletWeaving.FrontToBack
— TypeWarp threads pass from the warp beam through the tablet from front to back.
TabletWeaving.threading_for_char
— Functionthreading_for_char(::AbstractChar)
Given an 's' or a 'z', return an instance of the the corresponding TabletThreading.
There seems to be some confusion in the tablet weaving community about which is which. In this code base, 'z' corresponds to BackToFront
threading.
TabletWeaving.threading_char
— Functionthreading_char(::TabletThreading)
Return the character ('s' or 'z' corresponding to the specified tablet threading. See threading_for_char
.
Tablet Stacking
If the tablets are arranged with a flat side facing the weaver this would take too much space and also cause other inconveniences. Instead, tablets are arrahged so that their flat faces face each other. This forms a horizontal stack from one side of the loom to the other.
When stacked like this, a tablet is said to be stacked FrontToTheRight
if it's front face faces towards the right side of the from the weaver's perspective. A tablet facing the opposite direction is said to be threaded FrontToTheLeft
.
For brevity in textual representations, FrontToTheRight
is represented with a →
right arrow and FrontToTheLeft
with a ←
left arrow.
TabletWeaving.TabletStacking
— TypeTabletStacking is the abstract supertype for which way a tablet is facing when stacked.
TabletWeaving.FrontToTheRight
— TypeIn FrontToTheRight
stacking, the tablet is stacked so that its front faces the weaver's right.
TabletWeaving.FrontToTheLeft
— TypeIn FrontToTheLeft
stacking, the tablet is stacked so that its front faces the weaver's left.
TabletWeaving.tablet_stacking_to_char
— Functiontablet_stacking_to_char(::TabletStacking)
Return an arrow showing which direction the front of a tablet is currently facing.
Tablet
TabletWeaving.Tablet
— TypeTablet
Tablet describes the setup and current state of a single tablet weaving card.
TabletWeaving.warp_color
— Functionwarp_color(::Tablet, ::TabletHole)
Return the color of the warp thread that passes through the specified hole of the specified tablet.
TabletWeaving.top_edge
— Functiontop_edge(::Tablet)::TabletEdge
Return the TabletEdge of the top edge of the tablet. This edge is easier to see on the loom than the shed edge. It is also unaffected by the tablet's stacking
.
We use a Vector
of Tablet
s to describe how the loom is set up for weaving. for convenience, we can add these vectors together for a wider pattern. We can also multiply them to repeat tablets.
Tablet Rotation
Prior to each new throw of the weft, the tablets are rotated to open a new shed.
In practice (the stacked arrangement), a card will be rotated forward or backward. Forward rotation moves the top corner of the card closest to the weaver away from the weaver towards the warp beam. Backward rotation moves the top corner furthest from the weaver toards the weaver.
Whether forward rotation turns the card in the ABCD or the DCBA direction depends on how the card is threaded and stacked.
TabletWeaving.RotationDirection
— TypeRotationDirection
RotationDirection
is the abstract supertype of all tablet rotations.
TabletWeaving.rotation
— Functionrotation(::Tablet, ::RotationDirection)
Return the change in the Tablet
's accumulated_rotation
if the specified `AbstractRotation is applied.
TabletWeaving.ABCD
— TypeThe ABCD rotation causes the A corner of the tablet to move to the location in space previously occupied by the B corner.
TabletWeaving.DCBA
— TypeThe DCBA rotation causes the A corner of the tablet to move to the location in space previously occupied by the D corner.
TabletWeaving.Clockwise
— TypeThe Clockwise
direction refers to how the tablet would move if its front or back face (depending on threading) were facing the weaver. Whether this results in ABCD or DCBA rotation depends on how the tablet is threaded.
TabletWeaving.CounterClockwise
— TypeThe CounterClockwise
direction refers to how the tablet would move if its front or back face (depending on threading) were facing the weaver. Whether the front or the back of the tablet is facing the weaver depends on whether the card is BackToFrontor
FrontToBack` threaded.
TabletWeaving.Forward
— TypeThe Forward rotation moves the top corner of the tablet closest to the weaver and the cloth beam to be the top corner farthest from the weaver.
TabletWeaving.Backward
— TypeThe Backward rotation moves the top corner of the tablet closest to the weaver and the cloth beam to be the bottom corner closest to the weaver.
Weaving
To weave, the weaver first rotates the tablets according to some pattern. Rotating the tablets opens a new shed. The shuttle is then passed through the new shed to finish weaving that row.
TabletWeaving.rotate!
— Functionrotate!(::Tablet, ::RotationDirection)
Rotate the tablet by one position in the specified direction.
TabletWeaving.shot!
— Functionshot!(::Tablet)
Apply the current rotation to the tablet and return the colors of the warp threads passing over the top and bottom of the fabric, and the crossing direction (as a StitchSlant
) when looking at the front/top face of the fabric. Note that the slant on the bottom face will be the other
of the slant on the top surface since the fabrick is flipped to see the other face.
Stitch Slant
Rotation of a tablet introduces twist int o the four threads passing through that tablet. That twist is locked in by the next weft thread. The twist causes one thread to cross over each surface and two threads to pass through from front to back or back to front. The stitches that cross over the front or back surface of the woven fabric will appear slightly slanted. We need vocabulary to describe the directions of those slants.
TabletWeaving.StitchSlant
— TypeStitchSlant is the abstract supertype for describing the angular slant of a woven stitch.
TabletWeaving.SStitch
— TypeSStitch describes how a woven stitch is slanted when it angles from the near right (for the corresponding weft) to tbe far left. An SStitch
is formed when the rotation of a tablet passes the thread to the weaver's left.
TabletWeaving.ZStitch
— TypeZStitch describes how a woven stitch is slanted when it angles from the near left (for the corresponding weft) to tbe far right. A ZStitch
is formed when the rotation of a tablet passes the thread to the weaver's right.
TabletWeaving.stitch_slant_to_char
— Functionstitch_slant_to_char(::StitchSlant)::Char
Return a single character which consisely represents the slant of a stitch.
TabletWeaving.stitch_slant_for_char
— Functionstitch_slant_for_char(::AbstractCharacter)::StitchSlant
Given an 's', 'z', slash or backslash character, return the so-identified StitchSlant.
Describing a Pattern
How should we describe tablet motion during weaving?
After each throw, each tablet must be rotated forward or backward to make a new shed. In the simplest patterns, all tablets are rotated in the same direction. For more complicated patterns however, tablets move in different directions for each shed. How can we represent these rotations for ease of execution by the weaver?
There is one set of tablet motions for each throw of the shuttle. We should have a row number. The weaver must keep track of which row they're working.
There is motion for each tablet. The motion of a single tablet can be concisely described by unicode arrows (🡑, 🡓) or by the edge number of the tablet that is facing the shed or on top. The latter is less error prone since an incorrect starting position for a tablet will be detected.
The simplest representation is a Vector
for the whole pattern. Each element would be a Vector
of digits from 1
to 4
indicating the edge of the tablet that's currently "on top".
Designing a Pattern
Simple Patterns
TabletWeaving.simple_rotation_plan
— Functionsimple_rotation_plan(row_count::Int, rotation_direction::RotationDirection)
Return a simple rotation plan function, as could be passed to tablet_weave
.
TabletWeaving.f4b4_rotation_plan
— Functionf4b4_rotation_plan(row_count::Int)
Return a rotation plan function that weaves the specified number of rows. All tablets in the first four rows will be rotated forward. All tablets in the next four rows are rotated backward, Rotation direction continues to alternate every four rows until the end of the pattern.
Going from an Image to a Pattern
We have an array of the "image" we want to weave. How do we translate that into a set of tablets, their warping, and their motions?
How do we execute that "plan" to produce a stitch image to see how the pattern turned out.
For a two color pattern, we can warp each tablet with one color in holes A and C and the other in holes B and D. Whatever the previous stitch, the tablet can be rotated to either color. The slant of the stitch can't be controlled though.
TabletWeaving.tablets_for_image
— Functiontablets_for_image(image)
Return a Vector
of the Tablet
s that could be used to weave the image, which should be a two dimensional array. If the tablets can't be determined then an error is thrown.
The first dimension of image
counts rows of weft. The second dimension counts columns of warp, and therefore, tablets.
tablets_for_image
does nothing about tablet threading, only colors.
The tablet weaving patterns I've seen all seem to have one threading on one side of the pattern and another threading on the other side, with the possible exception of the borders having different threading from the field.
We can introduce a function that sets one threading from the edge to the middle and switches to the other threading for the other half.
TabletWeaving.symetric_threading!
— Functionsymetric_threading!(Vector{<:Tablet};
leftthreading::TabletThreading = BackToFront())
Set the threading of the tablets to be bilaterally symetric.
TabletWeaving.alternating_threading!
— Functionalternating_threading!(tablets::Vector{<:Tablet};
leftthreading::TabletThreading = BackToFront())
Set the threading of each tablet so that each tablet has the opposite threading from its two neighbors.
TabletWeaving.TabletWeavingPattern
— TypeTabletWeavingPattern
TabletWeavingPattern represents a single tablet weaving project, from initial target image to tablets to pattern to images of the expected result.
Composition
We might want to combine a number of graphical elements in our weaving design. Some utilities are provided to support this.
safe_hcat
and safe_vcat
can be used to combine multiple images horizontally or vertically. These are just instances of (an instantiable subtype of) SwatchComposer
.
TabletWeaving.SwatchComposer
— Type(::SwatchComposer)(align::SwatchAlignment,
padvalue, swatches)
Return a single two dimensional array composed by juxtaposing the swatches according to align
. Swatches that are not compatible in size are padded with padvalue
.
HorizontalComposer
composes the swatches horizontally – along the length of the warp. safe_hcat
is an alias for this composer.
VerticalComposer
composes the swatches vertically – across the width of the warp. safe_vcat
is an alias for this composer.
TabletWeaving.HorizontalComposer
— TypeHorizontalComposer
Juxtaposes the swarches horizontally, along the length of the warp. See safe_hcat
.
TabletWeaving.safe_hcat
— Constantsafe_hcat
safe_hcat is an alias for calling a HorizontalComposer
.
TabletWeaving.VerticalComposer
— TypeVerticalComposer
Juxtaposes the swarches vertically, across the width of the warp. See safe_vcat
.
TabletWeaving.safe_vcat
— Constantsafe_vcat
safe_vcat is an alias for calling a VerticalComposer
.
TabletWeaving.SwatchAlignment
— Type(::SwatchAlignment)(::SwatchComposer, swatch::Array{Any, 2}, add,
padvalue)
Add padding to swatch
so that its size will be compatible with those of other swatches when performing the SwatchComposer. add
is the number of rows or columns to be added to swatch
. The value of each element added in the padding is specified by padvalue
.
TabletWeaving.AlignHeads
— TypeAlignHeads
An instantiable subtype of SwatchAlignment
that aligns the left or top edges of graphical elements when safe_hcat
or safe_vcat
is used. Padding is adddeed after the swatctch as needed.
TabletWeaving.AlignCenters
— TypeAlignCenters
An instantiable subtype of SwatchAlignment
that aligns the centers of graphical elements when safe_hcat
or safe_vcat
is used. Padding is added both before and after the swatch as needed.
TabletWeaving.AlignTails
— TypeAlignTails
An instantiable subtype of SwatchAlignment
that aligns the right or bottom edges of graphical elements when safe_hcat
or safe_vcat
is used. Padding is added before the swatch as needed.
TabletWeaving.insert_between
— Functioninsert_between(swatches, between)
Intersperse between
among swatches
.
swatches
is a vector of 2 dimenswional arrays that will be part of a tablet weaving pattern. A new vector is returned with between
inserted between each two adjacent arrays from swatches
.
Suitable for adding spacing between letters or lines of text, but can also be used to add spacing between arbitrary graphical elements.
Text
A simple dot matrix font is provided so that we can include text in our designs.
TabletWeaving.compose_line
— Functioncompose_line(line)
Return a bit image from a line of text. Uses the FONT_5x7
font.
TabletWeaving.FONT_5x7
— ConstantFONT_5x7
Contains 5 wide by 7 high dot matrix bitmap images of uppercase letters, digits and punctuation. Indexed by Char.
Everything Else
TabletWeaving.svg_stitch
— Functionsvg_stitch(stitch_width, stitch_length, stitch_diameter, slant::Char)
Generate the SVG for drawing a stitch.
stitch_width
is the width of the stitch on the SVG X and weaving weft axis.
stitch_diameter
is how wide the stitch is.
stitch_length
is the length of the stitch in the SVG Y and warp axis.
slant
is as returned by shot!
.
TabletWeaving.other
— Functionother(::TabletThreading)
Given a TabletThreading
, return the opposite one.
TabletWeaving.csscolor
— Functioncsscolor(color)
return (as a string) the CSS representation of the color.
TabletWeaving.count_warp_colors
— Functioncount_warp_colors(t)
Return a Dict keyed by color, the values of which are the number of times that color is used as a warp thread in the Tablet or tablets t
.
TabletWeaving.chart_tablets
— Functionchart_tablets(::Vector{<:Tablet})
Return an SVG chart describing how the tablets are threaded.
TabletWeaving.want_color
— Functionwant_color(::Tablet, color)
Return a Vector containing named tuples (of new edge, AbstractRotation, and change in tablet rotation) describing the possible rotations that will provide the specified color.
TabletWeaving.tablet_weave
— Functiontablet_weave(tablets::Vector{<:Tablet}, rotation_plan)
Simulate the weaving of an item that is warped according to tablets
and is woven according to rotation_plan
.
rotation_plan
is a function of three arguments:
a vector of the tablets;
the row number of the warp being formed;
the number of the tablet, counted from the weaver's left.
It should return a RotationDirection, or nothing
if the row number is past the end of the pattern.
tablet_weave
rotates the tablets according to the plan function, steping the row number until rotation_plan
returns nothing
.
tablet_weave
returns several values:
an array of the stitch color and slant, from which an image of the top face of the result can be made;
the same, but for the bottom face of the result;
a vector with one element per weft row, each element of which is a vector with
one element per tablet, giving the rotation that was applied to that tablet and its new top edge after applying that rotation, as a tuple.
TabletWeaving.chart_tablet
— Functionchart_tablet(::Tablet; size=5, x=0)
Return an SVG element that describes how the tablet is threaded.
TabletWeaving.longer_dimension_counts_weft
— Functionlonger_dimension_counts_weft(image)
Return an image with the dimensions possibly permuted such that each increment in the first dimension counts a new row of the weft. The second dimension indexes the color of the visible warp thread for that row.
TabletWeaving.TabletThreading
— TypeTabletThreading is the abstract supertype for the two ways that the warp threads can pass through a tablet.
Index
TabletWeaving.FONT_5x7
TabletWeaving.safe_hcat
TabletWeaving.safe_vcat
TabletWeaving.ABCD
TabletWeaving.AlignCenters
TabletWeaving.AlignHeads
TabletWeaving.AlignTails
TabletWeaving.BackToFront
TabletWeaving.Backward
TabletWeaving.Clockwise
TabletWeaving.CounterClockwise
TabletWeaving.DCBA
TabletWeaving.Forward
TabletWeaving.FrontToBack
TabletWeaving.FrontToTheLeft
TabletWeaving.FrontToTheRight
TabletWeaving.HorizontalComposer
TabletWeaving.RotationDirection
TabletWeaving.SStitch
TabletWeaving.StitchSlant
TabletWeaving.SwatchAlignment
TabletWeaving.SwatchComposer
TabletWeaving.Tablet
TabletWeaving.TabletEdge
TabletWeaving.TabletHole
TabletWeaving.TabletStacking
TabletWeaving.TabletThreading
TabletWeaving.TabletWeavingPattern
TabletWeaving.VerticalComposer
TabletWeaving.ZStitch
TabletWeaving.alternating_threading!
TabletWeaving.chart_tablet
TabletWeaving.chart_tablets
TabletWeaving.compose_line
TabletWeaving.count_warp_colors
TabletWeaving.csscolor
TabletWeaving.f4b4_rotation_plan
TabletWeaving.insert_between
TabletWeaving.longer_dimension_counts_weft
TabletWeaving.next
TabletWeaving.next_hole
TabletWeaving.opposite
TabletWeaving.other
TabletWeaving.previous
TabletWeaving.previous_hole
TabletWeaving.rotate!
TabletWeaving.rotation
TabletWeaving.shot!
TabletWeaving.simple_rotation_plan
TabletWeaving.stitch_slant_for_char
TabletWeaving.stitch_slant_to_char
TabletWeaving.svg_stitch
TabletWeaving.symetric_threading!
TabletWeaving.tablet_stacking_to_char
TabletWeaving.tablet_weave
TabletWeaving.tablets_for_image
TabletWeaving.threading_char
TabletWeaving.threading_for_char
TabletWeaving.top_edge
TabletWeaving.want_color
TabletWeaving.warp_color