Krpano 热点箭头动画

根据官方文档examples里的animated-hotspots中代码可以看到热点动画的原理就是做一个很长的图片,不断切换显示的位置。

以下是官方的代码:

	<!-- 关键动画代码 -->
	<action name="do_crop_animation" scope="local" args="framewidth, frameheight, framerate">
		<!-- define local variables -->
		calc(local.xframes, (caller.imagewidth /framewidth) BOR 0);
		calc(local.frames, xframes * ((caller.imageheight / frameheight) BOR 0));
		def(local.frame, integer, 0);
		
		<!-- set the first frame -->
		calc(caller.crop, '0|0|' + framewidth + '|' + frameheight);
		
		<!-- do the animation -->
		setinterval(calc('crop_anim_' + caller.name), calc(1.0 / framerate),
			if(caller.loaded,
				inc(frame);
				if(frame GE frames, if(caller.onlastframe !== null, callwith(caller, onlastframe() ) ); set(frame,0); );
				mod(xpos, frame, xframes);
				div(ypos, frame, xframes);
				Math.floor(ypos);
				mul(xpos, framewidth);
				mul(ypos, frameheight);
				calc(caller.crop, xpos + '|' + ypos + '|' + framewidth + '|' + frameheight);
			  ,
				<!-- stop the interval when the hotspot gets removed -->
				clearinterval(calc('crop_anim_' + caller.name));
			);
		);
	</action>
	<!-- 关键动画代码 -->

	<!-- example hotspots -->
	<hotspot name="spot1" url="animatedhotspot_white.png" onloaded="do_crop_animation(64,64, 60);"   ath="-15" atv="-12" onclick="looktohotspot(get(name),65);" />
	<!-- 这里url换上你自己图片地址就行,do_crop_animation(64,64, 60)这里前2个数字是图片显示出来大小,最后一个是切换频率 -->

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值