-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
[bug] Previously defined coordinates shouldn't be affected by group()
-scoped axis transformations
#601
Comments
From the manual
Well, maybe I misunderstood, but |
In fact, I can retrieve draw.get-ctx(ctx => {
let (ctx, a) = coordinate.resolve(ctx, test)
draw.content(test, [#a], frame: "rect", stroke: none, fill: white)
draw.rotate(45deg, origin: a)
draw.circle(a, radius: (0.7, 0.2), anchor: "center")
}) However, I still don't know if this is the expected behavior. Please, let me know if this is indeed a bug or not |
I don't really get what you mean, it looks correct to me. What are you expecting? |
I was expecting that #import "@preview/cetz:0.2.2": canvas, plot, draw, coordinate, vector
#set page(width: auto, height: auto, margin: .5cm)
#canvas({
draw.rect((0,0), (1,1), name: "rect")
let test = (rel: (0deg, 2), to: "rect.north-east")
draw.group({
draw.rotate(45deg, origin: test)
draw.circle(test, radius: (0.7, 0.2), anchor: "center")
draw.get-ctx(ctx => {
let (ctx, a) = coordinate.resolve(ctx, test)
draw.content(test, [#a], frame: "rect", stroke: none, fill: white)
})
})
}) produces but it produced The whole point is that |
|
Oh, I am confused. |
The problem here is, that
Or use
Tikz has |
This behavior is counterintuitive.
If we agree that it is sensible that draw.rotate(45deg, origin: (rel: (0deg, 2), to: "rect.north-east")) // rotation
let test = (rel: (0deg, 2), to: "rect.north-east") // defining `test` on the rotated axis |
group()
is not scoping transformations properly when relative coordinates are usedgroup()
-scoped axis transformations
It is set before any rotation, but It would work if you call For cetz to be able to resolve and return coordinates, Typst would need to allow to set some sort of writable global context, which it does not. |
:( |
I think the best thing to do is allowing anchors at the root scope (without a group). That would allow defining coordinates with the current transformation taken into account. |
I am not sure how your idea would work. I just tried to help Cetz saying that it is reasonable However, I assure that creating anchors like |
Hi there! A potentially interesting aspect about this issue: #import "@preview/cetz:0.2.2": canvas, draw, coordinate
#import draw: *
#set page(width: auto, height: auto, margin: .5cm)
#canvas({
rect((0,0), (1,1), name: "rect")
let test = "rect.north-east"
group({
rotate(45deg)
circle(test, radius: (0.7, 0.2), anchor: "center")
get-ctx(ctx => {
let (ctx, a) = coordinate.resolve(ctx, test)
content(test, [#a], frame: "rect", stroke: none, fill: white)
})
})
}) To my surprise, removing the relative shift in Please, let me try to propose a solution for this: isn't possible to work with two contexts? One to apply any transformation inside and the other for anything outside |
Consider the following MWE:
This produces
The command
draw.rotate(45deg, origin: test)
shouldn't affecttest
since the rotation is scoped withingroup()
androtate()
is being applied aftertest
is defined. Therefore, uncommentingrotate()
should lead to a rotation incircle()
around its center.However, by uncommenting it, we somehow obtain
This new (and wrong) position is the because
rotate()
is changing the x-y axis used to determinetest
, which shouldn't happen.The text was updated successfully, but these errors were encountered: