AllYarnsAreBeautiful / ayab-desktop

The AYAB Software
http://ayab-knitting.com
GNU General Public License v3.0
60 stars 31 forks source link

[BUG] Default view should knit the image as you see it on the screen #613

Closed Adrienne200 closed 4 months ago

Adrienne200 commented 8 months ago

AYAB software version: 0.99 RC2 Computer/OS: Windows 7 Knitting machine: KH910 AYAB hardware: Shield or interface

Following from the conversation in #604, I'm looking at the simplest case, all default settings, open an asymmetrical image, what should it look like? On the screen, and which needles should knit? I think this should be the WYSIWYG case, open the image so it looks exactly as you saved it, and knit it out so that the image as you see it appears on the side facing you as you knit, the purl side.

Steps to reproduce the behavior:

  1. AYAB 1.0 RC2 (with the firmware reflashed and the correct machine set in the Prefs)
  2. Open the test image uC3, and bring needles L15 - R15 into work.
  3. Leave all the settings at default, (Knit Side Image is unchecked)
  4. Start AYAB as usual, waiting for the beep after crossing the left turn mark.
  5. Observe which way round the image appears on the actual knitting, which side does the tail of the mu character appear?

Expected behavior: The UI as shown in the screenshot is, I believe, correct as it stands for the non-KSI case, but I want it to finish the job by having the actual knitting also match the image as you look at it, so the tail of the mu character should appear on the left, the yellow side, but it currently appears on the right.

unmirroring

t0mpr1c3 commented 8 months ago

Thanks for this.

One supplementary question: what do we want "align left" and "align right" to mean?

In the current version of the software (Jan 2, commit 8bdb8a6), with the "knit side" box unchecked, looking at the purl side:

I'm not sure what the original Brother software does, but the current behaviour seems wrong. If "align left" means "align on the LHS of the screen", then that should happen whether or not the "knit side image" checkbox is checked. If "align left" means "align in the LHS of the finished garment", then that is the reverse of what is happening at the moment.

Adrienne200 commented 7 months ago

The behavior is still the same in 0.99.0-rc4 (Mac)

(The Alignment feature is separate. This is about the basic behavior with the default center alignment.)

citizenkate commented 7 months ago

@Adrienne200 I believe my observed issue (below) is the same as this one, but I would appreciate your eyes / brain on this. If my issue is something else, I can raise a new one.

AYAB software version: 0.99 RC4 Computer/OS: Apple (M1) Ventura 13.4 Knitting machine: KH965 AYAB hardware: Interface

Steps:

  1. AYAB 1.0 RC4 (with the firmware reflashed and the correct machine set in the Prefs)
  2. Load my custom text-based image (ayab2.png, attached) Thinking: My uploaded image contains letters and numbers and reads properly, so I intuit I must reverse it for it to show properly on the knit side.
  3. Under Image Actions, choose Horizontal Flip. Thinking: I see the image now looks backwards in the view panel. When I select the "Knit side image" checkbox, the image looks correct, suggesting that my text will read properly when viewed from the knit side.
  4. knit

Expected result: My knitting will read "AYAB 1.0" when viewed from the knit side. Actual result: My knitting reads backwards from the knit side.

ayab2

backwards-knitting

Adrienne200 commented 6 months ago

Still backwards in release build rc6. The UI is the way I want it, but I want the actual knitting to exactly match the screen. With all settings at default, the image that I'm looking at on the right side of the screen should appear on the right side of the knitting machine, the green side of the image should be on the green needles. The purl side matches the screen.

jonathanperret commented 4 months ago

I've traced through the code trying to see where the image was reversed. In the default case we definitely want (well, since it was decided to get rid of the confusing default flipping) the leftmost pixel to drive the leftmost needle, so no flipping should be necessary.

I think I found the culprit here:

https://github.com/AllYarnsAreBeautiful/ayab-desktop/blob/5037932d909a7af5a5cdcba37736a0665f2cf76a/src/main/python/main/ayab/engine/engine.py#L125-L126

When preparing the pattern from the image, we do need to flip the image vertically, as the comment indicates, but here we have a 180 degree rotation instead, which ends up also flipping the image horizontally.

Changing this ROTATE_180 to FLIP_TOP_BOTTOM is all that's needed to avoid that unnecessary transformation. In my simulation-only testing I believe the generated serial output is now correct.

However, this visually flips the "knit progress" panel, which currently reverses the bits from the sent pattern:

https://github.com/AllYarnsAreBeautiful/ayab-desktop/blob/5037932d909a7af5a5cdcba37736a0665f2cf76a/src/main/python/main/ayab/knitprogress.py#L123

Removing the above line results in a correct progress display.

I'll try to make a proper PR for these minimal changes by tomorrow unless someone beats me to it.

I'll note that in my testing, left/right alignment options appeared to be reversed (selecting right alignment does move the image visually to the right but knits it to the left), and it is quite easy to break the progress panel by playing with these options. But that's another set of issues, which the proposed changes above do not impact, ang which will need looking into separately.