let bg = this.createBitmapByName("123_png");
this.addChild(bg)
bg.x = this.stage.width / 2
bg.y = this.stage.height / 2
bg.anchorOffsetX = bg.width / 2
bg.anchorOffsetY = bg.height / 2
let infoList = [5, 2, 7, 9, 4, 1]
let list = this.getPolyPoint(infoList, bg)
var shp: egret.Shape = new egret.Shape();
shp.graphics.lineStyle(2, 0x00ff00);
shp.graphics.beginFill(0xff0000, 1)
for (let i in list) {
if (Number(i) == 0)
shp.graphics.moveTo(list[i].x, list[i].y);
else
shp.graphics.lineTo(list[i].x, list[i].y);
}
shp.graphics.endFill();
this.addChild(shp)
for (let i in list) {
var circle:egret.Shape = new egret.Shape();
circle.graphics.beginFill( 0x00ff00, 1);
circle.graphics.drawCircle( list[i].x, list[i].y, 5);
circle.graphics.endFill();
this.addChild(circle);
}
public getPolyPoint(infoList, item){
let list = []
let x = this.stage.width / 2
let y = this.stage.height / 2
for (let i = 1; i <= 7; i++) {
let info = infoList[i - 1]
if (info == undefined)
info = infoList[0]
let point = new egret.Point
let w = item.width / 2 * (info * 0.1)
let h = item.height / 2 * (info * 0.1)
let w1 = w / 2
switch (i) {
case 2:
point.x = x + w1
point.y = y - h
break
case 3:
point.x = x + w
point.y = y
break
case 4:
point.x = x + w1
point.y = y + h
break
case 5:
point.x = x - w1
point.y = y + h
break
case 6:
point.x = x - w
point.y = y
break
default:
point.x = x - w1
point.y = y - h
break
}
list.push(point)
}
return list
}