wallento / wavedrompy

WaveDrom compatible python command line
Other
94 stars 21 forks source link

Data Labels Misaligned, Depending on Maximum Phase of signal #13

Closed MutantPlatypus closed 4 years ago

MutantPlatypus commented 4 years ago

With d570c47, data labels are all shifted a little bit based on the most extreme phase shift. This wasn't an issue before, so I'll roll back through the commits to see which introduced this.

{ "signal": [
  { "name": "0",   "wave": "lh===...........", "node": "..a", "data": ["abcd", "1234"], "phase":0},
  { "name": "0.1", "wave": "lh===...........", "node": "..b", "data": ["abcd", "1234"], "phase":-0.1},
  { "name": "0.2", "wave": "lh===...........", "node": "..c", "data": ["abcd", "1234"], "phase":-0.2},
  { "name": "0.3", "wave": "lh===...........", "node": "..d", "data": ["abcd", "1234"], "phase":-0.3},
  { "name": "0.4", "wave": "lh===...........", "node": "..e", "data": ["abcd", "1234"], "phase":-0.4},
  { "name": "0.5", "wave": "lh===...........", "node": "..f", "data": ["abcd", "1234"], "phase":-0.5},
  { "name": "0.6", "wave": "lh===...........", "node": "..g", "data": ["abcd", "1234"], "phase":-0.6},
  { "name": "0.7", "wave": "lh===...........", "node": "..h", "data": ["abcd", "1234"], "phase":-0.7},
  { "name": "0.8", "wave": "lh===...........", "node": "..i", "data": ["abcd", "1234"], "phase":-0.8},
  { "name": "0.9", "wave": "lh===...........", "node": "..j", "data": ["abcd", "1234"], "phase":-0.9},
  { "name": "10",  "wave": "lh===...........", "node": "..k", "data": ["abcd", "1234"], "phase":-10}
  ],
  "edge": [
    "a-b",
    "b-c",
    "c-d",
    "d-e",
    "e-f",
    "f-g",
    "g-h",
    "h-i",
    "i-j",
    "j-k"
  ]
}

Renders as: image

To show the dependency on the phase: demo+5 demo-0 demo-5 demo-10

I used the below as a template to render the tests:

import cairosvg, wavedrom

svg = wavedrom.render("""
{ "signal": [
  { "name": "+5",  "wave": "l.....h===...........", "node": "........k", "data": ["abcd", "1234"], "phase":5}
  ]
}
""")

svg.saveas('demo+5.svg')

cairosvg.svg2png(svg.tostring(), write_to='.\demo+5.png', output_width=920, output_height=30)
MutantPlatypus commented 4 years ago

I see you made a commit while I was writing this. It's still an issue with 7054629fdf9f65613c961c4bb744d7e41d77b43a.

demo+5 demo-0 demo-5 demo-10

MutantPlatypus commented 4 years ago

Only had to go back one commit. It works in 55ca3f0dc34ce0e19bc83d0811b460183414962d: demo+5 demo-0 demo-5 demo-10

So d570c47 introduced this.

wallento commented 4 years ago

Thanks for reporting and tracking it down!

Fixed in a457b1b