把图片排列成如图样式,图片数量不固定,图片大小固定,求算法,谢谢
rotation已能算出,就是y的大小不知道怎么算出来
for(var i:int = 0; i < length; i++){
img = new Image();
img.source = "card/bg.png";
img.smoothBitmapContent = true;
img.x = i * 20;
r0 = -(length - (i * 2));
img.rotation=r0;
cbox.addElement(img);
}
貌似用Flex的,我用按钮代替图片写了个Demo
[code="java"]<?xml version="1.0"?>
layout="absolute"
creationComplete="init()">
mx:Script
<![CDATA[
import mx.controls.Button;
private var buttonList:Array;
private static const buttonNum:int=20;
private static const oPoint:Point=new Point(500, 900);
private static const startAngle:Number=-125;
private static const paddingAngle:Number=3;
private static const radius:Number=800;
private function init():void
{
buttonList=new Array();
var b:Button;
for (var i:int=0; i < buttonNum; i++)
{
b=new Button();
b.toolTip="Hi" + i.toString();
b.width=100;
b.height=200;
buttonList.push(b);
this.addChild(b);
var p:Point=new Point(oPoint.x + radius * Math.cos((startAngle + i * paddingAngle) * Math.PI / 180), oPoint.y + radius * Math.sin((startAngle + i * paddingAngle) * Math.PI / 180));
b.x=p.x;
b.y=p.y;
b.rotation=90 + (startAngle + i * paddingAngle);
}
}
]]>
</mx:Script>
/mx:Application[/code]
数量不固定那图形的形状也就不固定了会缺边少角的 起码得有一定的数量比例
还是没明白给个样了或者图片看看
这个效果在IE下是很难实现的。为什么不考虑用AS做呢?
没搞过flex,你这个x,y是指图片左上角的坐标吧,x怎么是线性的呢?
既然写死的可以,那么定义下变量,根据自己的需求肯定是可以达到你控制的算法了。你可以在发牌的时候加上移动的效果,把这N个图片的移动效果放进Sequence中便有了连续发牌的效果,我试了,不过没有动力继续学习试验了。
是的,就是这玩意。