When I rotate the gate-not, it doesn't rendered properly #1

Open
opened 2024-10-12 06:38:40 +00:00 by Ajsoabk · 5 comments

As shown in the image below, the NAND gate is not rendered correctly, and at the same time, other components have similar problems, is there any other way to rotate the components correctly?

As shown in the image below, the NAND gate is not rendered correctly, and at the same time, other components have similar problems, is there any other way to rotate the components correctly?
Owner

Unfortunately, there is currently no easy way to rotate components
It is indeed an important missing feature which I'll look into implementing

Unfortunately, there is currently no easy way to rotate components It is indeed an important missing feature which I'll look into implementing
HEL added the
feature request
label 2024-10-12 15:00:05 +00:00
Author

I found the input port of the rotated gate could render properly, so I changed the logic of output port by emulating the logic of input port, as shown below (the blue circles are intersections that I use to anchor the output), it works fine with NOT gate and AND gate
image

But it failed with XOR gate and OR gate, the circle of the inverted output port is inside of those two gates, which is not right. When I dive into the problem, I found a hidden line which is used to locate the "north" and "south" anchors, the hidden line only appears in the draw-shape function of OR and XOR, so it disturbs the size of intersections, as shown below
image

It seems that the logic of "draw" and "determine the anchors" is not well delineated:

  1. The draw_shape function is not only used for "draw", but also used for determine the "north" and "south" anchor, while the gate function is used for determine the "east", "west", "output" and other input anchors
  2. The draw_shape function is specific to each gate, while the gate function is called by every gate

So I recommended to determine the "east", "west" and "output" anchors within the draw_shape function, while leave the implementation of input anchors within the gate function.

I found the input port of the rotated gate could render properly, so I changed the logic of output port by emulating the logic of input port, as shown below (the blue circles are intersections that I use to anchor the output), it works fine with NOT gate and AND gate <img width="1285" alt="image" src="attachments/c2e49ac5-6698-437c-b043-e4fc3136efa1"> But it failed with XOR gate and OR gate, the circle of the inverted output port is inside of those two gates, which is not right. When I dive into the problem, I found a hidden line which is used to locate the "north" and "south" anchors, the hidden line only appears in the `draw-shape` function of OR and XOR, so it disturbs the size of intersections, as shown below <img width="1418" alt="image" src="attachments/707d9a97-15cb-4f34-b5e2-56675bbd7aad"> It seems that the logic of "draw" and "determine the anchors" is not well delineated: 1. The `draw_shape` function is not only used for "draw", but also used for determine the "north" and "south" anchor, while the `gate` function is used for determine the "east", "west", "output" and other input anchors 2. The `draw_shape` function is specific to each gate, while the `gate` function is called by every gate So I recommended to determine the "east", "west" and "output" anchors within the `draw_shape` function, while leave the implementation of input anchors within the `gate` function.
205 KiB
194 KiB

oh yeah it is not good to have draw and rotation mixed but I wouldn't know hot not to mix it with this architecture, I handle rotations here if you are interested

https://typst.app/project/pCiRocNZmVsfnFaeKR9rLn

oh yeah it is not good to have draw and rotation mixed but I wouldn't know hot not to mix it with this architecture, I handle rotations here if you are interested https://typst.app/project/pCiRocNZmVsfnFaeKR9rLn

I think the best way to add rotation is here

#let elmt(

I think the best way to add rotation is here https://git.kb28.ch/HEL/circuiteria/src/commit/2bb7e3b5a98577297a53d4aefb8732e3dd761f4a/src/elements/element.typ#L47
Owner

Yes, the pipeline here is not ideal, everything is mixed together
I'd like to make it more modular and better use CeTZ' features so that it'd be easier to add new components

Yes, the pipeline here is not ideal, everything is mixed together I'd like to make it more modular and better use CeTZ' features so that it'd be easier to add new components
Sign in to join this conversation.
No description provided.