是否有内置命令可以在 Octave 中调整/缩放单色图像(例如由浮点数组表示)?
如果不是,那么对于具有一定量插值(比方说双线性)的基本算法的快速实现是什么?我实际上只需要对我的图像进行下采样(将其缩小),这可能会简化问题。
我正在尝试在 SVG 和 d3 中使用 scale() 转换。我知道它通过增加坐标比例来工作,但它似乎也在翻译我的对象。当我有一个位于 (100,100) 的矩形并执行 scale(2) 时,矩形的大小加倍并移动到 (0,0)。如何让它在缩放时停止从 (100,100) 移动到 (0,0)。以下是我的代码:
var mysvg = d3.select("#viz")
.append("svg")
.attr("width", 500)
.attr("height", 500)
.attr("class","mylist");
var node = mysvg.selectAll("g.node")
.data(mydata)
.enter().append("g")
.attr("class","node")
.attr("transform", function(d) { return "translate(" + d.xpos + "," + d.ypos + ")"; });
node.append("rect")
.attr("width",tileWidth)
.attr("height",tileWidth)
.attr("fill","orange")
.attr("rx",10)
.attr("ry",10);
node.append("text")
.attr("transform",function(d) { return "translate(" + tileWidth/2 + "," + tileWidth/2 +")" })
.attr("text-anchor", "middle")
.attr("dy", ".3em")
.attr("font-family","serif")
.text(function(d) { return d.symbol; });
node.on("mouseover",function(){ d3.select(this).transition().attr("transform","scale(1.2)") });
node.on("mouseout",function(){ d3.select(this).transition().attr("transform","scale(1)") …Run Code Online (Sandbox Code Playgroud) 我有一个SVG图像,指定一个特定的高度和宽度.创建SVG图像中的所有对象以使用此宽度和高度.像这样的东西:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="600" height="600">
<g>
<circle cx="300" cy="300" r="295" fill="red" stroke="black" stroke-width="10"/>
</g>
</svg>
Run Code Online (Sandbox Code Playgroud)
这使得一个600像素的红色圆圈带有黑色边框:

如何缩放此SVG图像(比如200x200)而不必更新并更新其中包含的所有对象(在本例中只是红色圆圈)?
这是带有评论的小提琴:http : //jsfiddle.net/7xw1m1qd/1/
html例如:
<div class="droppable"></div>
<div class="drag"></div>
Run Code Online (Sandbox Code Playgroud)
以JS为例:
$('.drag').draggable({});
$('.droppable').droppable({
out: function() {
$('.drag').css('background-color', 'red');
},
drop: function() {
$('.drag').css('background-color', 'green');
},
});
Run Code Online (Sandbox Code Playgroud)
以 CSS 为例:
.droppable {
width: 200px;
height: 200px;
transform: scale(2);
-webkit-transform: scale(2);
-ms-transform: scale(2);
background-color: #C3C3C3;
}
.drag {
background-color: black;
width: 20px;
height: 20px;
z-index: 10;
position: absolute;
top: 10px;
left: 350px;
}
Run Code Online (Sandbox Code Playgroud)
问题是:如果 droppable 被缩放(通过变换:缩放),它仍然使用 droppable 的原始尺寸,所以我只能在 droppable 的原始边界中放置元素。
我发现了一些类似的问题,但没有找到有效的解决方案。
我试图在一个视图上运行一些动画(一个接一个) AnimationSet
从规模1 --> 0和比0 --> 1
AnimationSet animationSet = new AnimationSet(true);
animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
ScaleAnimation animation1 = new ScaleAnimation(1f, 0f, 1f, 0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation1.setDuration(500);
ScaleAnimation animation2 = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation2.setDuration(500);
animation2.setStartOffset(500);
animationSet.addAnimation(animation1);
animationSet.addAnimation(animation2);
mFloatingActionButton.startAnimation(animationSet);
Run Code Online (Sandbox Code Playgroud)
视图刚刚消失,一秒后再次出现.没有动画.
如果我删除setStartOffset(...)我可以看到动画,但不是我想要的那个.
我在这里错过了什么?
我想在两个轴上显示对数刻度的等高线图。我找到了这个很好的例子来执行这个任务:
http://plnkr.co/edit/f1VThUpkHxUzxOBXmTCr?p=preview
但是,当我将刻度更改为对数刻度时
var x = d3.scale.log()
.range([0, width]);
Run Code Online (Sandbox Code Playgroud)
代替
var x = d3.scale.linear()
.range([0, width]);
Run Code Online (Sandbox Code Playgroud)
轴只是消失了。我认为问题在于 log(0) = -infinity 但是如果我从 1 开始它不会改变任何东西。
问题是什么?
我想知道是否可以使用 spritekit 缩放父节点而不缩放其子节点?因为在游戏过程中我只想对节点的一部分(在我的例子中是其父节点)运行缩放操作。因此,如果有人可以提供帮助,我会很高兴。
当形状旋转时,用于通过角手柄缩放矩形的正确数学公式是什么?
更新:
问题更多地是关于手柄上的鼠标按下事件背后的数学原理以及形状的实际大小。当手柄在旋转形状上移动时,用于计算形状位置和缩放大小的适当数学是什么?
我创建了一个项目的小提琴来展示一个例子:https : //jsfiddle.net/8b5zLupf/38/
小提琴中画布上的灰色形状可以移动和缩放,但由于形状已旋转,因此缩放形状并在缩放时保持形状位置的数学计算不正确。
项目将缩放,但不会通过相反的点锁定形状并均匀缩放。
我用来缩放具有方面的形状的代码区域如下:
resizeShapeWithAspect: function(currentHandle, shape, mouse)
{
var self = this;
var getModifyAspect = function(max, min, value)
{
var ratio = max / min;
return value * ratio;
};
var modify = {
width: 0,
height: 10
};
var direction = null,
objPos = shape.position,
ratio = this.getAspect(shape.width, shape.height);
switch (currentHandle)
{
case 'topleft':
modify.width = shape.width + (objPos.x - mouse.x);
modify.height = shape.height + (objPos.y - mouse.y);
this.scale(shape, modify);
/* we …Run Code Online (Sandbox Code Playgroud) 我正在尝试在不同时间点用多个图像叠加视频。这里的问题是图像可能比视频大,但它们应该缩小(保持纵横比)并且缺失的空间应该用黑色填充。
这是我到目前为止所拥有的:
-i 'input_video.mp4'
-i 'input_image_1.jpg'
-i 'input_image_2.jpg'
-i 'input_image3.jpg'
-i 'input_image4.jpg'
-filter_complex "[0][1] overlay=0:0:enable='between(t,0.0,2.0)'[s1];
[s1][2] overlay=0:0:enable='between(t,7.0,9.0)'[s2];
[s2][3] overlay=0:0:enable='between(t,18.0,20.0)'[s3];
[s3][4] overlay=0:0:enable='between(t,20.0,22.0)'[s4];"
-vf 'scale=min(iw*540/ih,960):min(540,ih*960/iw),
pad=960:540:(960-iw)/2:(540-ih)/2'
-pix_fmt yuv420p -c:a copy
'output_image.mp4'
Run Code Online (Sandbox Code Playgroud)
scale 和 pad 中的值是动态导出的,对应于视频高度和视频宽度。
然而,FFmpeg 抱怨这个突击队-filter_complex不能-vf在同一个突击队中使用。我不想首先缩小图像或从中创建视频文件,然后覆盖这些视频。
任何指示表示赞赏。
我正在尝试以中心裁剪方式显示视频(就像在 ImageView 上一样)。
我也希望我能找到如何以其他方式进行扩展,就像在这个库上所做的那样。
我用它来达到这个目的:
player!!.videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,它不进行中心裁剪。
查看文档,我看到了这一点:
“请注意,缩放模式仅适用于启用基于 MediaCodec 的视频渲染器且输出表面归 SurfaceView 所有的情况。”
所以我尝试在 XML 文件中设置它:
app:surface_type="surface_view"
Run Code Online (Sandbox Code Playgroud)
但这也没有帮助。我也没有看到它在代码中可用。
我尝试搜索此类的任何带有“渲染器”或“编解码器”的内容,但不存在。
这是我使用的代码(基于此:https://github.com/yusufcakmak/ExoPlayerSample):
class MainActivity : AppCompatActivity() {
val VIDEO_URL = "https://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4"
private var player: SimpleExoPlayer? = null
private var window: Timeline.Window? = null
private var mediaDataSourceFactory: DataSource.Factory? = null
private var trackSelector: DefaultTrackSelector? = null
private var shouldAutoPlay: Boolean = false
private var bandwidthMeter: BandwidthMeter? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) …Run Code Online (Sandbox Code Playgroud)