数学相关:如果值小于一或大于一,如何获得不同的比例
这应该是一个很容易解决的问题,但我的大脑最近几天一直在煎熬。我有一个可以放大和缩小图像的滑块。我想放大像素级别并缩小到像素级别,但我必须将缩略图按钮置于滑块中心,比例为 1。
我现在拥有的是,
在代码中: // 如果比例值为 1,则图像按原始大小显示 var scale:Number = ZoomSlider.value/1000; sprite.scaleX = sprite.scaleY = 比例;
我将默认值设置为 5000,以便按钮位于中间居中,但这将比例设置为 5。我想要的是当我向左拖动(从初始值 5000 开始)时,它应该开始缩小直至达到最小比例 0.10。当我向右拖动时,它应该开始将比例增加到 10。
这个问题的关键是我必须将缩略图按钮居中于滑块中间,居中时比例为 1。
This should be an easy to solve but my brain has been fried the last few days. I have a slider that zooms in and zooms out a image. I want to zoom into the pixel level and zoom out to the pixel level but I have to have the thumbnail button be centered in the slider for a scale of 1.
What I have now is,
In code:
// if the scale value is 1 the image is shown at original size
var scale:Number = zoomSlider.value/1000;
sprite.scaleX = sprite.scaleY = scale;
I set the default value to 5000 so that the button is centered in the middle but that sets the scale to 5. What I want is when I drag left (from the initial value of 5000) it should start to scale down until it gets to the minimum scale of .10. When I drag right it should start to increase the scale to 10.
The key to this question is that I have to have the thumbnail button centered in the middle of the slider and when centered the scale is 1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望比例为 0 到 10,000(因为您指定中心为 5000),请使用
任何比例,保持比例按钮居中,并且< strong>图像缩放为1,将'scale'变量设置为最大Scale值的1/2。
If you want the scale for 0 to 10,000 (since you specified center to be 5000) as above, then use
Whatever be the Scale, To keep the Scale Button centered and Image scaled to 1, set the 'scale' variable to 1/2 of the max Scale value.