ts 绘制多边形
2024-09-29 19:12:51
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 }
最新文章
- linux下安装memcache(php版本5.3)
- 世界上最小的发行版之一Tiny Core
- HDU 5927 Auxiliary Set (dfs)
- VC6.0设置选项解读(转)
- iOS实现白板、画板功能,有趣的涂鸦工具,已封装,简单快捷使用
- poj-2287---Tian Ji -- The Horse Racing
- CentOS下使用命令行Web浏览器Links
- vue 通知 走马灯效果
- 在ASP.NET MVC里对Web Page网页进行权限控制
- docker 8 docker的镜像命令
- mysql5.5.48的my.cnf配置
- pytest的fixture和conftest
- 九个问题从入门到熟悉HTTPS
- flynn 开源paas 平台安装试用
- 【知识总结】Activiti工作流学习入门
- 深入理解javascript作用域系列第一篇
- Django 框架之 Models
- asp.net 输入框在chrome中无法关闭自动提示
- CentOS7搭建 Hadoop + HBase + Zookeeper集群
- 笨办法学Python(三十七)