Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wif missing warp #4

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open

Wif missing warp #4

wants to merge 47 commits into from

Conversation

Neon22
Copy link
Collaborator

@Neon22 Neon22 commented Sep 7, 2021

pile of fixes because i just cant get git to work for me. sigh. too old I suppose.

  • wif files:

    • warp and weft colors might have unreferenced threads - so use default as defined in spec
    • Tieup section might have a much more general set of treadles than used in the WEAVING section. so ignore unreferenced.
  • cmd.py python 3 fix for crash when not implemented.

ignore my working directory
not all Warp colors or Weft are defined, in which case spec says to use deault.
Also fixed puython 3 unimplemented error in cmd.py
Also fixed wif files where Tieup is overspecified and has more in it than defined in WEAVING.
@Neon22 Neon22 mentioned this pull request Sep 7, 2021
Tieup sections may have more treadles than defined in WEAVING section.
Ignore the unused ones
Adding author, etc and source program and version
Added reading wif spacing value - ready for renderer.
In the course of this:
- enabled the json round trip to preserve spacing
- fixed saving wif to be ascii instead
changed wif save values form 1 to true where appropriate for readability/compatibility
- forced json to utf8 ascii
round tripped wif to json and back with rendering to ensure all working well. (Needs more changes to support default colors when missing)

Had to reorder some stuff to enable json to load and not complain about treddles and shafts and where contents is defined.
Also ability to use a file instead of commandline params

Also use infile directory if no directory supplied for outfile
wif files with liftplans were not rendering the shaft display.
Fix was to ensure draft made with liftplan being set.

Also first work on renderer - renaming markers and numbering to clarify they are colors.
small adjustment to color to accept color instances as well as tuples

Addition of Drawstyle class with settings for various visual modes of presenting the draft in render modes.

In render two major changes..
1 - fix problem where all drafts had weft and drawdown in reverse order. Threading was correct order. Problem is invisible if draft is symmetric.

2. Addition of styles
- several existing params renamed.
- blob, or solid markers, or solid color same as thread.
- option to not draw tick markers, and to have a mod  for numbering
- all colors in Color class
Note SVG not fixed only png at this stage
Now warp,weft,threading, treadling, tieup can all display markers as solids, blobs, X or O for lowering or rising shats, yarn color, or numbers (shaft)
They can also be mixed spo warps as numbers, tieup as rising, wefts as yarn color.
pyweaving render --floast 3 <wifname> <pngname> will now show floats as red
Render option for generating a forced liftplan added back in

Tartan generator fixed - mirrored, oneway, separate warp,weft descriptions added. Counts corrected.
Some work left to do on unique autogenerated filenames
Render funciont (png) rewritten to make layout defined in make_PIL_image so they are all relative.
So now we can add a title, or stats section, or stat buffers on eth end of threading (for example)

Also bugfix for floats.
title now appears at top of draft/
made of the title - if in the wif file and the filename.

Soon:
stats at bottom
possibly line stats on LHS
Addition of spacing. Autodetected if defined in wif file. ratio set in Drawstyle.
Most work in render.py
- preprocess to determine box spacings/ratios and store back in each thread as a yarn_width
- when drawing - use yarn_width if spacings available.
All measurement estimates needed updating to draw each section correctly.

drawdown was a bit tricky but we got there.

Also some error checking for missing file n cmd.py

wif .py has changes to support better spacings variances in wif files.
defines satin counts for all regular satins. Need to add irregular for 4,6
Then generate draft
mini stats show at the top of the image under Title and filename lines.
Also added heddle counts to LHS of Threading section.

Also refined the presentation if accuracy selected for yarn spacing as boxes too small for numbers.

Added some docs....
somewhere in there render without an outfile stopped working.
fixed here - also tartan generator needed similar fix
updated twill generator to take a twill shape string like:
1/3 2/2S for a combined twill and Z,S direction.

Also minor tweak to tartan doc - will still need to move

also minor error protection against poorly formed wif files.
Some weavit file missing fields. set a,fallback

A wif with extra shafts in Liftplan that do not exist. ignore high numbers.

Glassners program indexes some fields from zero - fix based on source program field. (Luminescence)

Also calculate and report in ministats on whether floating selvedges required.

Also refactor autoname feature for generators slightly and enable for twills.

Also count floats correctly

Also added twill direction to twill generator.
E.g. shape= "1/3 2/2S"

start extracting Creation date as a comment field from Fibreworks authored programs. Will probably use this trick for us.
Has required changes to RawConfigParser which seem safe.
Added Notes section below drawdown.

Changed Notes reading to go into a list (like everything else) instead of being a string with \n chars embedded.

Adds the Source file and version if any notes to report. else section is skipped.
Using autopng or autosvg when choosing the render option will create an image file with e the same name as the wif file.

Structure is in place to ensure its a unique name so will not overwrite an existing file. (coming)

Also fixed a debug print I forgot about
Config like this so we can read the creation date embedded in comments
        self.config = RawConfigParser(comment_prefixes='/', allow_no_value=True)

but because we override comments from ;,# to / we will have to parse comments outrselves.
We did this because creation date is embedded in fiberworks files as a comment in TEXT section.

We need to deal with special case where the config file starts with a comment line. (TempoFiber)
In this case the simple approach will fail when reading from the file.
So we need to read the file into a string and use self.config.read_string() instead of self.config.read()

Also fix bug in auto option to render
Added a file of tartan names drawn from weddlist - with permission.

So tartans' now a string in SRT format or a name. If name is not unique in our sample list then it will show similar names so user can select a unique name

Tartans's can also have a twill direction - S or Z

Also added ability of Color() class to take hex strings
A user directory '.pyweaving' will contain styles.json. A human modifiable file where styles can be created.
Each one is named and that name can be used when rendering to override the default. (which also comes from this file)
Still needs improvement to get the derived from field working so each style is minimal changes from another.

The styles.json is in /data but will be copied to .pyweaving first time and used from there.

Also small adj to Color class to take a hex color(#rrggbb) as input

Also adjusted fonts path to use get_project_root() mechanism instead of __here__
autofilename now increments a fileindex and will not overwrite existing render files

styles added by name to render , twill,tartan comands

Also allow copying of Drawstyles and minor comment, repr cleanup

Also cleanup bug when reading wif files that start with blank line
Creation date is extracted if found in TEXT as a comment. Also stored there if saved(converted).

Generated files set sourceprogram fields in wif.
creation date reported in Notes section during render.

Also cleaned up the Notes so they are all collected during process_draft and render only renders

Also shortened some tartan names and derived names and fixed the twill disorder. And handled poor tartan naming better
A motley collection of updates in one commit - sorry
Main commit is adding interlacing in drawdown as a style and adding shading to  drawdown styles

- Color now generates a shadow and highlight color if requested - for shading.
- Also will darken white and lighten black so shading can be seen if required.
- Used HSL color model but would have preferred LCH but too much code.

Drawdown styles now = solid/box/interlace all with shading option. E.g. solidshaded
-Interlace width added for interlace style in drawdown.
Interlace width enables simple(1) or larger(2) interweaving emphasis when drawn in the drawdown.

Extras:
- added render option structure which overrides drawdown colors to be warp black, weft white

- fix heddles offset calc if no ticks drawn in threading.
Also heddle report was vertically inverted :(

- twill generator - added repeats
- wif reader - fixed Glassner variant detection
- twill/tartan gen - fixed styles
- ignore empty lines in a gamp oriented draft when calculating float lengths

Added more styles to default install
- cleanup yarn_width to mandatory store drawn width for faster size calc whether spacing data in file or not.

Some svg renderer changes but all WIP
Optimize wif saving for smaller files by finding most used colors.

Tartans:
- Improve note about tartan sources
Twill:
- add source program info to Notes

Render:
- Simplify size calcs for threads with spacings.
- Tweak shaded style.
- Add option to not draw label on ticks
- Add compressed style
Neon22 and others added 19 commits February 11, 2022 00:29
SVG output is updated and also has shading in the drawdown. The SVG is quite compact as it hashes all drawn yarns in the drawdown and stores the minimum unique set into defs. Each cell then references one of these and its drawn in place.

Also:
If a style is selected which does not exist then a list of partial matching styles is presented at the CLI

Some cleanup of styles as vector shading options added.

Some classes now have __repr__ defined.

CSS is precalculated for all colours and shading highlights/shadows

box sizing has been refactored out of the Imagerender class.
Positional calcs refactored also in Renderers

Starting indicator position is cleaned up but still not autocalculating where it should really be for any given draft.
Added etection of no args and display help
Found some more wif files with odd constructions. comments embedded and missing tieup lines.
reconfigured to Python3
Also reorganised __init so that all is imported.
So Draft, Drawstyle, Color factored out into own files
Adding new feature to create a wif from an image of a drawdown.
- can cleanup noisy images a bit.
- can reduce to core draft if (say) has repeats in image
- added repeats file to facilitate this but wil be used later for detecting repeats and mirrors in drafts.

Some minor changes to presenting color and in Draft when adding a warp or weft thread out of order.

So two commands added:
- pyweaving image (which creates a draft from bitmap and can turn images into drafts. needs quite a few shafts - say 40.
- pyweaving drawdown which takes an image of a drawdown and has a --core option which will remove duplicate repeats.

minor addition to reporting which files get created..

cleaned up the generators in cmd.py to factor common code
attempting builds and cleaning up tox etc

Changes are to pass flake8
Adjustments to use:
 - pytest with coverage,
 - build docs (Sphinx)
 - move tests to directory above
 - modify setup to use cfg file instead of code
 - removing nose as test mech

And many doc strings added/edited
 - minor fixes to Color as revealed by test coverage

Moved Drawstyle initiation into package init
Addition of docstrings to most all of API
Added Color tests
Also fixed Color. Added as_drawn which is used in render.py when we modify the thread's Color because its either Black or White and so can't show a highlight (or shadow) if we selected shaded as an aspect of our style.
The recommended practice is to add a src directory inbetween pyweaving. This ensures testing is not accidentally picking up the working directory instead of testing the temp install directory code.

Alas coverage is not reporting properly
Changes to work out how to get everything running. tox configs etc.

However got bored and added a feature:
 find_colors. new command which uses k-means clustering to find the commonly used colors in an image. Writes a swatch file as well as printing out the found colors.

pyweaving colors foo.png --count 6 --size 20

where count is number of colors to find and size is the height of each color in a generated swatch png image file.
Replacing arial.ttf with Liberation Sans
Sep program canbe shortcut or placed in desktop/documents etc. Mouse L2 will initiate it.
Initially only colors,remap,render commands supported.
The GUI needs several files which need to be copied if not found the first time the GUI runs.
cleanup spacing, comments etc for tox pytest tests
Added help, some text changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant