Rotate inside group without shifting #246
-
I would like to rotate the circle with the "+" inside by 45 degrees, but if I add the rotate command, it will also move. What am I doing wrong here? (A solution that can be factored out into a function to make it a reusable symbol would be greatly appreciated) #import "@preview/cetz:0.1.2": canvas, draw, tree
#canvas(length: 1cm, {
import draw: *
line((0,0), (rel: (2, 0)))
group({
rotate(45deg)
circle((rel:(0,0)), radius: 0.3, anchor: "left", name: "circle")
line("circle.left", "circle.right")
line("circle.top", "circle.bottom")
}
)
}) |
Beta Was this translation helpful? Give feedback.
Answered by
johannes-wolf
Oct 10, 2023
Replies: 1 comment 6 replies
-
It is because the origin of the rotation is at (0,0) so you would have to translate everything first (you can use #import "@preview/cetz:0.1.2": canvas, draw, tree
#canvas(length: 1cm, {
import draw: *
line((0,0), (rel: (2, 0)))
group({
circle((), radius: 0.3, anchor: "left", name: "circle")
line("circle.top-left", "circle.bottom-right")
line("circle.top-right", "circle.bottom-left")
})
}) |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
JuliDi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is because the origin of the rotation is at (0,0) so you would have to translate everything first (you can use
set-origin(())
and then use(0,0)
as your circle position). BUT: It is way more easy not using rotation at all, but other anchors: