aspect-ratio

OpenGL stretched shapes - aspect ratio

风格不统一 提交于 2019-11-27 11:59:06
I got my openGL view at a size of (lets say..) 800(width)x600(height). Then i got a 2D object of coords: 0.0 , 0.0 0.1 , 0.0 0.1 , 0.1 0.0 , 0.1 this, as you understand is supposed to be a square (based on analogy). But on my openGL view prints this stretched. Now, i understand why this is happening. Its basically because im working on the default matrix of -1,1. And since my resolution of 800x600 doesnt have an aspect ratio of 1, my shape is getting stretched. Now im more interested on how to fix this. Ive read about functions like glFrustum, glOrtho, glViewPort which are happening on the

Resize a WPF window, but maintain proportions?

╄→гoц情女王★ 提交于 2019-11-27 08:25:53
I have a user resizable WPF Window that I want to constrain the resizing so the aspect ratio of the window stays constant. Ideally I would like to constrain mouse location when the window is being resized by dragging a corner to positions that maintain the proper aspect ration. If an edge is resized with the mouse, the other dimension should change at the same time. Is there a simple way to do this or a good on-line example that anyone knows of? If no better solutions come up, I'll post what I've done after I've refined it a bit. Mike Fuchs I've found a good answer by Nir here . There are

How to define fixed aspect-ratio for scatter-plot

一世执手 提交于 2019-11-27 07:57:41
I am plotting correlation coefficients (values = 0.0:1.0) for two isotopes measured in each individual from two populations. I would like to have a fixed aspect-ratio for my scatter-plot so that the x- and y-axis are exactly the same size no matter the graphics device. Suggestions? This is my first plot in R, any comments on refinements to my code is appreciated? Finally, is it worth investing in learning the basic plotting techniques or should I jump right to ggplot2 or lattice? My plot script: ## Create dataset WW_corr <- structure(list(South_N15 = c(0.7976495, 0.1796725, 0.5338347, 0

Square DIV where height is equal to viewport

只愿长相守 提交于 2019-11-27 07:23:41
I need to create a DIV where width=height , and height=100% of the viewport (which, obviously, is variable). In other words, a perfectly square DIV that calculates it's dimensions based on the height of the viewport . Elements within that DIV will take their dimensions as percentages of the parent-DIV's height & width. It seems to me like this should be simple to do in CSS , but I've gotten stuck with it! Any pointers would be much appreciated. You can do this with jquery (or pure javascript if you prefer). With jquery: <div id="square"> </div> $(document).ready(function(){ var height = $

Maintain aspect ratio of a div according to height [duplicate]

为君一笑 提交于 2019-11-27 06:58:43
问题 This question already has answers here : Maintain div aspect ratio according to height (5 answers) Closed 3 years ago . I have to maintain the aspect ratio of a div with respect to the height on window resize. I can maintain the aspect ratio(x:y) with regard to the width(X%) using padding-bottom; or padding-top; . So from the analogy, I tried using padding-left; .wrapper{ height: Y%, position: relative; } .wrapper:after{ padding-left: Y(x/y)%; display:block; } But the percentage value of

Android Convert Px to Dp (Video Aspect Ratio) [duplicate]

这一生的挚爱 提交于 2019-11-27 06:49:55
Possible Duplicate: converting pixels to dp in android I'm trying to convert pixels to dp. What is the formula? Lets convert 640 and 480 into dp. The docs say this The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160) But I don't think that is what I need (and I don't know how to use this). I guess I just need the forumla. I have the code ready: DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); switch(metrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: int sixForty = ? int fourEighty = ? break; case

How Can I Only Allow Uniform Resizing in a WPF Window?

和自甴很熟 提交于 2019-11-27 05:22:55
问题 I don't want my window to be resized either "only horizontally" or "only vertically." Is there a property I can set on my window that can enforce this, or is there a nifty code-behind trick I can use? 回答1: You can reserve aspect ratio of contents using WPF's ViewBox with control with fixed width and height inside. Let's give this a try. You can change "Stretch" attribute of ViewBox to experience different results. Here is my screeen shot: <Window x:Class="TestWPF.Window1" xmlns="http:/

How to deal with different aspect ratios in libGDX?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 02:41:50
I have implemented some screens using libGDX that would obviously use the Screen class provided by the libGDX framework. However, the implementation for these screens works only with pre-defined screen sizes. For example, if the sprite was meant for a 640 x 480 size screen (4:3 Aspect ratio), it won't work as intended on other screen sizes because the sprites go par the screen boundaries and are not scaled to the screen size at all. Moreover, if simple scaling would have been provided by the libGDX, the issue I am facing would have still been there because that would cause the aspect ratio of

Make a <div> square when there is a dynamically changing width based on percentage [duplicate]

一个人想着一个人 提交于 2019-11-27 02:30:31
问题 This question already has answers here : Maintain the aspect ratio of a div with CSS (23 answers) Closed 4 years ago . I am working on a web app that will generate an NxN grid based on the user's selection of N. I want the total width of the grid to be relative (ie 100% of the available space) so that users can print on various paper sizes. I can easily calculate the width of the squares in the grid by % (ie: 100%/N), but I am having issues calculating the height. The height of a web page is

How do I keep the aspect ratio on image buttons in android?

穿精又带淫゛_ 提交于 2019-11-27 00:56:51
I have 5 square ImageButtons that I want to have lined up side by side on the bottom of the screen. I have each one set (different id's) as: <ImageButton android:id="@+id/box1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:adjustViewBounds="true" android:scaleType="fitXY" android:layout_weight="1" android:layout_margin="1dp" /> and I have the background assigned in main java like this: int[] imageIds = new int[] {R.id.box1,R.id.box2,R.id.box3,R.id.box4,R.id.box5}; for(int i = 0; i<5; i++){ imageButtons[i] = (ImageButton)