我想要生成一个随机的三角形坐标,它显示了flash 8.0中actionscript 2.0中每个角落的弧线。如何显示actionscript 2.0中随机三角形的坐标?
1
A
回答
2
这看起来很像你previous question(也很像this other question),但这里有云:
import flash.geom.Point;
function randomPoint():Point { //return a random point on the stage
var p:Point = new Point(Math.floor(Math.random()*(Stage.width-300)), Math.floor(Math.random()*Stage.height));
return p;
}
function drawTriangle(mc:MovieClip, q1:Point, q2:Point, q3:Point):Void {//draws a triangle through 3 points
var stroke=2;//line weight of triangle
mc.lineStyle(stroke, 0x000000, 100, true, "none", "round", "round");
mc.moveTo(q1.x, q1.y);
mc.lineTo(q2.x, q2.y);
mc.lineTo(q3.x, q3.y);
mc.lineTo(q1.x, q1.y);
}
function drawCircle(target_mc:MovieClip, x:Number, y:Number):Void {
//draws a red circle, centred on (x,y)
var radius:Number=18;
var k1:Number=Math.tan(Math.PI/8) * radius;
var k2:Number=Math.sin(Math.PI/4) * radius;
with (target_mc) {
lineStyle(2, 0xFF0000, 100, true, "none", "round", "round");
moveTo(x + radius, y);
curveTo(radius + x, k1 + y, k2 + x, k2 + y);
curveTo(k1 + x, radius + y, x, radius + y);
curveTo(-k1 + x, radius+ y, -k2 + x, k2 + y);
curveTo(-radius + x, k1 + y, -radius + x, y);
curveTo(-radius + x, -k1 + y, -k2 + x, -k2 + y);
curveTo(-k1 + x, -radius + y, x, -radius + y);
curveTo(k1 + x, -radius + y, k2 + x, -k2 + y);
curveTo(radius + x, -k1 + y, radius + x, y);
}
}
function arcTriangle():MovieClip { //main function to draw a triangle with corner arcs
//make a new movieclip t which will hold our triangle parts
var depth=this.getNextHighestDepth();
var t:MovieClip = this.createEmptyMovieClip("t"+depth, depth);
//define 3 random points (stored as properties of t)
t.p1=randomPoint();
t.p2=randomPoint();
t.p3=randomPoint();
//draw a triangle
t.createEmptyMovieClip("triangle", 0);
drawTriangle(t.triangle, t.p1, t.p2, t.p3);
//draw a filled triangle to use as a mask
t.createEmptyMovieClip("mask", 1);
t.mask.beginFill(0xF0F0F0);
drawTriangle(t.mask, t.p1, t.p2, t.p3);
t.mask.endFill();
t.mask._alpha=0;
//add a red circle to each corner
t.createEmptyMovieClip("arcHolder", 2);
drawCircle(t.arcHolder,t.p1.x,t.p1.y);
drawCircle(t.arcHolder,t.p2.x,t.p2.y);
drawCircle(t.arcHolder,t.p3.x,t.p3.y);
//mask the circles so only the interior arcs are visible
t.arcHolder.setMask(t.mask);
//show the coordinates (from bottom-left corner of the stage) for each point
t.createTextField("text1",3,t.p1.x,t.p1.y,300,100);
t.text1.text="("+t.p1.x+", "+(Stage.height-t.p1.y)+")";
t.createTextField("text2",4,t.p2.x,t.p2.y,300,100);
t.text2.text="("+t.p2.x+", "+(Stage.height-t.p2.y)+")";
t.createTextField("text3",5,t.p3.x,t.p3.y,300,100);
t.text3.text="("+t.p3.x+", "+(Stage.height-t.p3.y)+")";
return t;
}
var myTriangle:MovieClip = arcTriangle();
它看起来有点像这样当您完成:
alt text http://roi.webfactional.com/img/so/triangle2.jpg
如果我的答案中有一方(或两方)对你有帮助,请点击左边的大记号(tick http://roi.webfactional.com/img/so/so_tick.png),接受。谢谢。
相关问题
- 1. 带坐标的三角形?
- 2. 三角形的第三点的坐标
- 3. 从随机中断形成三角形
- 4. 三角形中的样本随机点
- 5. 随机显示拉斐尔画布内的三角形
- 6. 如何找到等边三角形的第三个坐标?
- 7. 三角形风扇的纹理坐标
- 8. 如何在变形后得到三角形内点的坐标?
- 9. 如何找到两个坐标及其对应角度的三角形的第三坐标
- 10. 三角坐标几何
- 11. Java不显示三角形
- 12. 如何计算三角形的第三坐标,知道2个坐标和1个角度?
- 13. 如何在多边形中生成随机的LatLng坐标?
- 14. Arraylist随机坐标
- 15. 带重心坐标的线框着色器显示黑色三角形
- 16. OpenGL ES 2.0中的旋转三角形
- 17. 在三维坐标系中查找矩形中的角度点
- 18. 如何渲染三角形网格坐标列表?
- 19. 如何在ActionScript 3中随机显示MovieClip?
- 20. 三角测量GPS坐标
- 21. 三角形中的三角形CSS
- 22. GPS三角坐标米
- 23. 基于MATLAB中原始坐标的随机角度生成坐标
- 24. 六角形/形状中的随机点
- 25. 在Applet中生成随机三角形(动画)
- 26. 在三角形的三角形中绘制三角形
- 27. Python:在坐标系统中显示随机点
- 28. 三角形阵列中的Java偏置随机数
- 29. 三维坐标图形
- 30. Gnuplot:对数坐标轴中的三角形
可能的重复[我如何显示一个随机三角形的坐标在范围从+10到-10的XY轴在actionscript 2.0中?](http://stackoverflow.com/questions/2572271/how- do-i-display-the-coordinates-of-a-random-triangle-in-a-graph-which-ranges-fr) – user1118321 2015-03-05 14:13:01