-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
issue with size and positioning of canvas (not expected and inconsistent behavior) #16
Comments
I went looking in the code and found that if in this line: Line 262 in eb03959
I substitute |
Hi! Thanks for taking interest in nanim! :) I looked at your PR quickly and love the RenderingOptions, make much more sense than what I was doing. Will take a closer look later and might merge :) It is deffinately a bug if the rendered video is different from the window animation. I only have access to test on an intel mac, so thanks for reporting behaviour on the M1! When I render your example with the command you provided, I get the same expected result in both the live window and the video: I'll boot up in MacOS later and see what the behaviour is like over there. In the meantime, here is some info about the coordinate system: The Coordinate System of NanimThe coordinate system of Nanim is a bit "weird", but it is intentional and has its logic. I have not yet documented it, so here's a start: No matter what size of canvas you use, coordinates will always map from 0 to 1000 in a square with 500, 500 in the center. If the canvas is not a perfect square, (500, 500) will still remain the center of the canvas, and unit "1000" will represent pixel position The reason I did this was that I usually render videos at many different resolutions and want them all to "look the same" - even if the ratio changes! Here is an example: import nanim
proc myScene(): Scene =
let
scene = newScene()
square = newSquare(1000) # Fills the height/width of the inner square, no matter canvas size
square.moveTo(500, 500) # Puts square in center, no matter the canvas size
square.stroke(newColor("#db235d"), 10)
square.fill(newColor("#00000000"))
scene.add(square)
return scene
when isMainModule:
render(myScene) Notice now, when I resize the canvas (either by dragging the window or by passing --height:XX, --width:XX and/or --ratio:XX), the square will always fill the smallest of the width and the height and remain in the center: This all stems from the fact that I scale the canvas using this function: Line 361 in eb03959
I should probably both document this behaviour and also add an option to use exact pixels as unit instead. BTW: Sorry for the circles looking a bit weird with dots and artefacts.. I'm working on fixing that. You can fix it in the meantime by using |
Here is the video rendered using your command next to the live rendering on my mac. Sadly, I don't get the same behaviour on my Intel Macbook Air from 2016 in Big Sur (11.1) :/ That being said, I tried your "Wrong Fix", and it doesn't change anything for me, so I would be OK with applying it to the rendering procs in rendering.nim |
hi, nanim looks great, thanks for making this!
I am having trouble understanding the size and positioning of the canvas and it seems to me it is not what I would expect and inconsistent between what is shown in the rendering video and the final result in mp4. I might be missing something.
as an ad hoc example that allows me to understand better the issue (the issue presents itself for me also on the examples in repo), here is what I am running:
I run with
nim c -r example.nim --video --debug:false
and output in terminal is:here are two screenshots that I take when the circle has moved in the bottom right corner. Note that in both screenshots the behavior is not as expected above:
when rendering plays in a window:
when reproducing the mp4 file:
this is on a recent Mac Air M1 with Nim 1.6 and latest nanim
The text was updated successfully, but these errors were encountered: