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

A slice with a midstick on top of it has a background #1

Closed
SekoiaTree opened this issue Feb 23, 2024 · 4 comments
Closed

A slice with a midstick on top of it has a background #1

SekoiaTree opened this issue Feb 23, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@SekoiaTree
Copy link

SekoiaTree commented Feb 23, 2024

A slice with a background color, combined with a midstick, will have an extra background color.

Minimal example:

#import "@preview/quill:0.2.0" : *
#quantum-circuit({
  let group = gategroup.with(stroke: (dash: "dotted", thickness: 1pt), fill: aqua)
  quantum-circuit(
    row-spacing: 6pt,
    column-spacing: 16pt,
    group(2, 1, label: "Wow"), $H$, [\ ],
    setwire(0), midstick($dots.v$), [\ ],
  ) 
})

image

Workaround: redefine draw-unboxed-gate and midstick.

  let draw-unboxed-gate(gate, draw-params) = box(
    inset: draw-params.padding, 
    fill: if gate.fill != none {gate.fill} else { none }, 
    gate.content
  )
  let midstick(content, label: none) = gate(content, draw-function: draw-unboxed-gate, label: label)
@Mc-Zen Mc-Zen added the bug Something isn't working label Feb 23, 2024
@Mc-Zen
Copy link
Owner

Mc-Zen commented Feb 23, 2024

Hi @SekoiaTree ,

The reason for it being non-transparent is so that the underlying wires are overdrawn. To illustrate, let's add some wires:
image

Initially, I spent a lot of effort to allow transparent gates and everything but it turned out very tricky with many special cases. It seemed better to not allow transparent gates. For gates, this seems okay to me but I have to admit that I did not think of your case with midstick.

I see two solutions:

  1. We can add a fill parameter to midstick(), so you can pass the same background color to it. To use it now, just add the following code to your file:
#let midstick(content, fill: none, label: none) = gate(content, draw-function: draw-functions.draw-unboxed-gate, label: label, fill: fill)

and use it with midstick(fill: aqua, ...)

  1. The other option is to rewrite a lot of the internals and make transparent gates and co. happen. This is a large effort for not too many benefits but I won't quite say that it will not happen ;)

Thanks for pointing this out!

@SekoiaTree
Copy link
Author

SekoiaTree commented Feb 23, 2024

I don't know hugely much of the internals, but can't you "just" have slice pass its own background color as the default setting for the fill?

Edit: Ah, there's no concept of "on top of", so a gate can't know it's on top of a slice.

@Mc-Zen
Copy link
Owner

Mc-Zen commented Feb 23, 2024

Precisely. Just like similar packages in LaTeX, gategroup does not actually "group" the elements that it covers. It is just drawn below.

@Mc-Zen
Copy link
Owner

Mc-Zen commented Mar 11, 2024

With 6ebf10, a fill parameter has been added to midstick. With the new release (v0.2.1), this feature is available (package pull request pending).

@Mc-Zen Mc-Zen closed this as completed Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants