I would like to draw two perpendicular lines on the current device. They should have the same visible length on the device, regardless of the aspect ratio of the output and the size of the device.
Is it even possible? In principle, this is the problem of drawing a perfect circle on the screen.
You can get the current coordinates of the graphics window. Thanks to Josh O'Brien for providing me this code some time ago. First you create a window (or draw something), then run this line:
myasp <- with(par(),(pin[2]/pin[1])/(diff(usr[3:4])/diff(usr[1:2])))
Then use this aspect information to adjust the lengths of the lines you are going to build.
,
library(grid) grid.circle() vp <- viewport(width=unit(0.5, "snpc"), height=unit(0.5, "snpc")) grid.rect(vp=vp, gp=gpar(lty=2)) grid.segments(x0=c(0,0), x1=c(1,1), y0=c(0,1), y1=c(1,0), default.units="npc", vp=vp)
You may be interested in the functions grconvertXand grconvertY. Using them, you can specify the coordinates in inches or other units, and from this calculate the coordinates of the user to draw your line.
grconvertX
grconvertY
Source: https://habr.com/ru/post/1529001/More articles:MVC 5 Code Первые строительные леса с простыми отношениями - c#Kalman prediction and correction are the same as the initial values - c #Are new objects constantly normal? - c #Executing class variables in a subclass - pythonHow to get siteroot path in Azure launch task instead of matching? - command-linehow to show or hide the counter according to ajax response in ember.js controller? - javascriptКакой лучший способ реализации отношений "многие ко многим", которые содержат мета, RESTfully? - httpPhpDocumentor 2 stuck when "Transform parsed a project in artifacts" - phpdocHow to find a useless link that prevents dealloc in objective-c / Xcode? - iosWhat is the best way to support legacy methods that are being replaced by new ones? - androidAll Articles