aspect-ratio

How to scale a texture in webgl?

拜拜、爱过 提交于 2021-02-19 07:43:49
问题 I have a texture of size 800x600. How do I scale it on a webgl <canvas> at another size and keep the original aspect ratio? Assuming that the drawing buffer and the canvas have the same dimensions. 回答1: Given the WebGL only cares about clipsapce coordinates you can just draw a 2 unit quad (-1 to +1) and scale it by the aspect of the canvas vs the aspect of the image. In other words const canvasAspect = canvas.clientWidth / canvas.clientHeight; const imageAspect = image.width / image.height;

How to scale a texture in webgl?

和自甴很熟 提交于 2021-02-19 07:43:30
问题 I have a texture of size 800x600. How do I scale it on a webgl <canvas> at another size and keep the original aspect ratio? Assuming that the drawing buffer and the canvas have the same dimensions. 回答1: Given the WebGL only cares about clipsapce coordinates you can just draw a 2 unit quad (-1 to +1) and scale it by the aspect of the canvas vs the aspect of the image. In other words const canvasAspect = canvas.clientWidth / canvas.clientHeight; const imageAspect = image.width / image.height;

How to scale a texture in webgl?

百般思念 提交于 2021-02-19 07:43:15
问题 I have a texture of size 800x600. How do I scale it on a webgl <canvas> at another size and keep the original aspect ratio? Assuming that the drawing buffer and the canvas have the same dimensions. 回答1: Given the WebGL only cares about clipsapce coordinates you can just draw a 2 unit quad (-1 to +1) and scale it by the aspect of the canvas vs the aspect of the image. In other words const canvasAspect = canvas.clientWidth / canvas.clientHeight; const imageAspect = image.width / image.height;

How can I change the aspect ratio constraint value from code?

为君一笑 提交于 2021-02-07 20:23:11
问题 I have given an aspect ratio constraint of 1:2 for an imageView in my xib. I have created an IBOutlet for the constraint. Now I need to change the aspect ratio to 1:1 for certain criteria. I want to know whether there is any way to change the constraint's multiplier value other than removing the old constraint and putting in a new one?? 回答1: I think its not possible other than the 'remove and replace constraint' method. 回答2: The multiplier is a get only property. So you can change only

How can I change the aspect ratio constraint value from code?

别等时光非礼了梦想. 提交于 2021-02-07 20:21:07
问题 I have given an aspect ratio constraint of 1:2 for an imageView in my xib. I have created an IBOutlet for the constraint. Now I need to change the aspect ratio to 1:1 for certain criteria. I want to know whether there is any way to change the constraint's multiplier value other than removing the old constraint and putting in a new one?? 回答1: I think its not possible other than the 'remove and replace constraint' method. 回答2: The multiplier is a get only property. So you can change only

ConstraintLayout: Unable to scale image to fit a ratio in RecyclerView

独自空忆成欢 提交于 2021-02-07 05:27:08
问题 I have a recycler view with StaggeredGridLayoutManager. Within in I have custom items/views. Each item is defined as a ConstraintLayout where there is an image which is supposed to have a constant aspect ratio. But the image is to still be able to scale to fit the width of each span. And then the height should be adjusted according to the ratio. But somehow the images are not maintaining the aspect ratio. Here are the xml files and code to create the recycler view: item.xml <?xml version="1.0

ConstraintLayout: Unable to scale image to fit a ratio in RecyclerView

喜夏-厌秋 提交于 2021-02-07 05:27:05
问题 I have a recycler view with StaggeredGridLayoutManager. Within in I have custom items/views. Each item is defined as a ConstraintLayout where there is an image which is supposed to have a constant aspect ratio. But the image is to still be able to scale to fit the width of each span. And then the height should be adjusted according to the ratio. But somehow the images are not maintaining the aspect ratio. Here are the xml files and code to create the recycler view: item.xml <?xml version="1.0

Aspect ratio in semi-log plot with Matplotlib

≡放荡痞女 提交于 2021-02-04 18:55:51
问题 When I plot a function in matplotlib, the plot is framed by a rectangle. I want the ratio of the length and height of this rectangle to be given by the golden mean ,i.e., dx/dy=1.618033... If the x and y scale are linear I found this solution using google import numpy as np import matplotlib.pyplot as pl golden_mean = (np.sqrt(5)-1.0)/2.0 dy=pl.gca().get_ylim()[1]-pl.gca().get_ylim()[0] dx=pl.gca().get_xlim()[1]-pl.gca().get_xlim()[0] pl.gca().set_aspect((dx/dy)*golden_mean,adjustable='box')

Plot a perfect sphere with equal axes by parametric plot in Sympy

有些话、适合烂在心里 提交于 2021-01-29 10:10:20
问题 I would like to know how using plot3d_parametric_surface in Sympy we can plot a perfect sphere. By perfect I mean with equal axes. The result with this function has an oval shape! from sympy import * from sympy.plotting.plot import plot3d_parametric_surface from sympy.abc import theta , phi plot3d_parametric_surface(sin(phi)*cos(theta) , sin(phi)*sin(theta), cos(phi), (phi,0,pi),(theta,0,2*pi)) I tried to implement the answers in the matplotlib (equal unit length): with 'equal' aspect ratio z

MigLayout: how to resize the height proportionally to the width (keeping the aspect ratio)?

南笙酒味 提交于 2021-01-28 18:50:20
问题 I'm arranging images in a grid with MigLayout. I could get the width to take the whole space available in the column, but then I want the height to grow accordingly so the proportion of the image still fixed. What is the best approach for this? Could I do that with an expression in the constraint or I have to override the getPreferredSize()? Thanks! 回答1: After a lot of researching, I realize that there is no nice way of doing this with Swing. The problem is not only coming from MigLayout but