我想要生成一個隨機的三角形座標,它顯示了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