Closed mantielero closed 4 years ago
With gr_setwsviewport()
, you can set the metric size. You should always use this function in conjunction with gr_setwswindow()
to set the correct aspect ratio.
Example (A4 format):
gr_setwsviewport(0, 0.297, 0, 0.21)
gr_setwswindow(0, 1, 0, 0.21/0.297)
or (in portrait orientation):
gr_setwsviewport(0, 0.21, 0, 0.297)
gr_setwswindow(0, 0.21/0.297, 0, 1)
Thanks a lot. And what about inqdspsize
?
inqdspsize
returns the display size (in metric and pixel coordinates).
(0.5965504497563073, 0.33555962798792294, 2560, 1440)
=> 59.7 x 0.34 cm with a pixel resolution of 2560 x 1440
I am currently investigating some strange behavior of gr_inqdspsize()
with gksqt, after that I will document it.
Thanks for you work on bringing GR to Nim!
Probably this is what was confusing me. I am working on the screen
After running inqdspsize
I had:
mwidth: 0.2856 width: 1280
dpi: 113.8375350140056
This means that it should be 0.28cm in the screen. If I take a ruler, it is something like 8cm.
If I do gr_setwsviewport
with mwidth=0.20
I get a window with 20cm in the screen, so it looks like inqdspsize
is not returning proper mwidth
.
Another topic that I don't really understand gr_setwswindow
purpose. I guess that it is not only to set the aspect ratio. But I don't understand what it does.
For instance, if I have gr_setwsviewport(0, 0.1, 0, 0.1)
(a 10x10 cm window), what happens if I do: gr_setwswindow(0.5,1.0,0.0,1.0)
. It looks like the image is displaced in the viewport, not deformed.
Addtionaly, if I do: gr_setwsviewport(0.5, 0.1, 0.5, 0.1)
, shouldn't the window measure 5 x 5 cm?
I have documented the function in the code this will be part of the online documentation with the next release.
gksqt
did not report the display size before that commit, so you might have to use the current develop
branch or wait until the next release for gr_inqdspsize
to return correct values when using gksqt
.
I have created some bindings for the Nim programming language. But I am having issues when I try to use the library (I am not very familiar with GR).
There are some functions that are undocumented in the C api. For instance, I am struggling to put the appropriate size for the window.
I have checked this and this. But inqdspsize is undocumented.