Tag: animation

NSLayoutConstraints是可以animation的吗?

我正在尝试对一些视图进行animation处理,以使它们被景观中的巨型键盘所阻挡。 如果我简单地为框架设置animation效果,效果会很好,但是其他人则认为这样做会适得其反,而我应该更新NSLayoutConstraints。 但是,他们似乎不是可以animation的。 有没有人得到他们的成功? //heightFromTop is an NSLayoutConstraint referenced from IB [UIView animateWithDuration:0.25 animations:^{ self.heightFromTop.constant= 550.f; }]; 结果是立即跳到有问题的高度。

如何使线条animation更stream畅?

我正在Java中制作一个简单的animation,我正在尽可能地使它变得stream畅。 我只使用每个Shape对象的* .Double内部类,并在Graphics2D对象上设置抗锯齿。 只要我只使用fill()方法,但是如果我也使用draw()方法在同一个Shape的周围绘制线条,这一切都可以工作,这些线条的animation是逐个像素的。 canvas上的每个矩形都具有此方法来绘制自己。 它每隔20ms移动一次,整个canvas使用Timer和TimerListener重新绘制。 import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class AnimationTest { public static void main(String[] args) { JFrame frm = new JFrame("Test"); frm.setBounds(200, 200, 400, 400); frm.setResizable(false); frm.setLocationRelativeTo(null); AnimationCanvas a = new AnimationCanvas(); frm.add(a); frm.setVisible(true); a.startAnimation(); } } class AnimationCanvas extends JPanel { SimpleSquare[] squares = new SimpleSquare[2]; […]

在Android中引起帧中的帧animationOutOfMemoryError

我有很多图像作为我的资源/可绘制文件夹中的帧(比方说约200)。 而使用这个图像,我想运行一个animation。 最长的animation是80帧。 我成功地能够点击一些点击button来运行animation,但是对于一些animation,它给了我OutOfMemoryError,说VM不能提供这样的内存。 它超出了VM预算。 我计算了所有图像的大小约10MB。 每个图像的大小是320×480像素。 我尝试使用Google,发现我需要使用System.gc()方法显式调用垃圾收集器。 我已经做到了,但仍然有一些内存错误。 任何人都可以请帮助我在这个。 一些代码: – ImageView img = (ImageView)findViewById(R.id.xxx); img.setBackgroundResource(R.anim.angry_tail_animation); AnimationDrawable mailAnimation = (AnimationDrawable) img.getBackground(); MediaPlayer player = MediaPlayer.create(this.getApplicationContext(), R.raw.angry); if(mailAnimation.isRunning()) { mailAnimation.stop(); mailAnimation.start(); if (player.isPlaying()) { player.stop(); player.start(); } else { player.start(); } } else { mailAnimation.start(); if (player.isPlaying()) { player.stop(); player.start(); } else { player.start(); } […]

有没有办法暂停CABasicAnimation?

我有一个iPhone的基本旋转animation。 有什么办法可以“暂停”animation,以保持视图的位置? 我想这样做的一个方法是导致animation“完成”,而不是调用“删除”,我怎么办呢? CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2]; rotationAnimation.duration = 100; rotationAnimation.cumulative = YES; rotationAnimation.repeatCount = HUGE_VALF; rotationAnimation.removedOnCompletion = NO; rotationAnimation.fillMode = kCAFillModeForwards; [myView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

如何通过JavaScript重新触发WebKit CSSanimation?

所以,我有这个-webkit-animation规则: @-webkit-keyframes shake { 0% { left: 0; } 25% { left: 12px; } 50% { left: 0; } 75% { left: -12px; } 100% { left:0; } } 还有一些CSS在我的box上定义了一些animation规则: #box{ -webkit-animation-duration: .02s; -webkit-animation-iteration-count: 10; -webkit-animation-timing-function: linear; } 我可以像这样shake #box : document.getElementById("box").style.webkitAnimationName = "shake"; 但是我以后再也不能动摇了。 这只能震动一次: someElem.onclick = function(){ document.getElementById("box").style.webkitAnimationName = "shake"; } 如何通过JavaScript重新触发CSSanimation而不使用超时或多animation?

相对于translateZ(0)的CSS性能

许多博客都表示,通过使用transform: translateZ(0)来加速animation和转换,可以“欺骗”GPU来认为元素是3D。 我想知道如果以下面的方式应用这种变换,会产生什么样的影响: * { -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0); }

如何在Android中调用另一个活动时提供animation?

我有两个活动A和B.我想有缩小animation时,活动A调用B和最大化animation时,活动B调用A.我不需要这个animationXML文件。 当我们在Android中调用另一个Activity时,会给出它的默认animation,然后调用缩小animation。 我想要的是,默认animation不应该发生,我想要的animation应该发生。 我们可以在调用另一个活动时给予animation吗?

从圆圈或圆环画出细分

我一直在试图找出一种方法来绘制段如下图所示: 我想: 绘制段 包括渐变 包括阴影 从0到n的angular度animation绘图 我一直在尝试使用CGContextAddArc和类似的调用来做到这一点,但没有得到很大的进展。 谁能帮忙?

在Tkinter帆布移动球

这是一个非常基本的程序,我想要做两个移动的球,但其中只有一个实际上移动。 我也尝试了一些变化,但不能得到第二个球移动; 另一个相关的问题 – 有些人使用move(object)方法来实现这一点,而其他人做一个delete(object) ,然后重绘它。 我应该使用哪一个,为什么? 这是我的代码,只是animation/移动一个球: from Tkinter import * class Ball: def __init__(self, canvas, x1, y1, x2, y2): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 self.canvas = canvas self.ball = canvas.create_oval(self.x1, self.y1, self.x2, self.y2, fill="red") def move_ball(self): while True: self.canvas.move(self.ball, 2, 1) self.canvas.after(20) self.canvas.update() # initialize root […]

使用requestAnimationFrame控制fps?

看起来像requestAnimationFrame是现在animation事件的事实上的方式。 它在大多数情况下工作得非常好,但现在我正在尝试做一些canvasanimation,我想知道:有没有办法确保它以某个fps运行? 我明白,RAF的目的是始终如一地保持stream畅的animation效果,而且我可能会冒着制作animation波涛汹涌的风险,但是现在它似乎以非常不同的速度运行,而且我想知道是否有办法打击不知何故。 我会使用setInterval但我想要优化,RAF提供(尤其是自动停止时,标签在焦点)。 如果有人想看我的代码,这是非常多的: animateFlash: function() { ctx_fg.clearRect(0,0,canvasWidth,canvasHeight); ctx_fg.fillStyle = 'rgba(177,39,116,1)'; ctx_fg.strokeStyle = 'none'; ctx_fg.beginPath(); for(var i in nodes) { nodes[i].drawFlash(); } ctx_fg.fill(); ctx_fg.closePath(); var instance = this; var rafID = requestAnimationFrame(function(){ instance.animateFlash(); }) var unfinishedNodes = nodes.filter(function(elem){ return elem.timer < timerMax; }); if(unfinishedNodes.length === 0) { console.log("done"); cancelAnimationFrame(rafID); instance.animate(); } } Node.drawFlash()只是一些基于计数器variables确定半径的代码,然后绘制一个圆圈。 谢谢!