For loop 回路内部的lineStyle()生成断开连接的角度
下面是我的代码,它被浓缩到所讨论的函数中:For loop 回路内部的lineStyle()生成断开连接的角度,for-loop,graphics,linestyle,For Loop,Graphics,Linestyle,下面是我的代码,它被浓缩到所讨论的函数中: public function redrawNewShape() { var tempAX:Number; var tempAY:Number; var tempBX:Number; var tempBY:Number; var tempLineThickness:Number; var tempLineColour:uint; var te
public function redrawNewShape() {
var tempAX:Number;
var tempAY:Number;
var tempBX:Number;
var tempBY:Number;
var tempLineThickness:Number;
var tempLineColour:uint;
var tempLineJoints:String;
var tempLineMiter:Number;
var tempSprite:Sprite;
tempSprite = new Sprite;
tempSprite = shapeArray[1];
tempSprite.graphics.clear()
if (fillTransparency == 0) {
tempSprite.graphics.beginFill(shapeArray[3],1);
}
tempSprite.graphics.moveTo(linesArray[(linesArray.length - 2)],linesArray[(linesArray.length - 1)]);
for (var d = 0; d < (linesArray.length/4); d++) {
tempAX = linesArray[(d*4)];
tempAY = linesArray[((d*4)+1)];
tempBX = linesArray[((d*4)+2)];
tempBY = linesArray[((d*4)+3)];
tempLineThickness = lineStyleArray[(d*4)];
tempLineColour = lineStyleArray[((d*4)+1)];
tempLineMiter = lineStyleArray[((d*4)+3)];
if (lineStyleArray[((d*4)+2)] == 0) {
tempLineJoints = JointStyle.MITER;
} else if (lineStyleArray[((d*4)+2)] == 1) {
tempLineJoints = JointStyle.ROUND;
} else if (lineStyleArray[((d*4)+2)] == 2) {
tempLineJoints = JointStyle.BEVEL;
}
tempSprite.graphics.lineStyle(tempLineThickness,tempLineColour,1,false,"normal","none",tempLineJoints,tempLineMiter)
tempSprite.graphics.curveTo(tempAX,tempAY,tempBX,BY)
}
if (fillTransparency == 0) {
tempSprite.graphics.endFill();
}
}
此函数用于在我的程序中重新绘制由数组ShaperRay、linesArray和lineStyleArray中的属性定义的形状。问题是,在我的程序中,无论我将形状设置为什么JointStyle,形状的角度都没有连接
我无法上传示例图片,因为我没有至少10个声誉。想象两条没有封口的粗线以90度角连接。不是圆角、倒角或斜接,而是两条线宽度一半的正方形间隙
我不明白为什么,如果我把tempsrite.graphics.lineStyle放在for循环之外,角度是相连的。在lineStyle下的Actionscript 3.0参考中指出
您可以在绘制路径中间调用LILISTILE方法,以指定路径中不同线段的不同样式。
那么为什么它不能在循环中工作呢 将线型放置在for循环外部并手动添加临时值的示例:public function redrawNewShape() {
var tempAX:Number;
var tempAY:Number;
var tempBX:Number;
var tempBY:Number;
var tempLineThickness:Number;
var tempLineColour:uint;
var tempLineJoints:String;
var tempLineMiter:Number;
var tempSprite:Sprite;
tempSprite = new Sprite;
tempSprite = shapeArray[1];
tempSprite.graphics.clear()
if (fillTransparency == 0) {
tempSprite.graphics.beginFill(shapeArray[3],1);
}
tempSprite.graphics.moveTo(linesArray[(linesArray.length - 2)],linesArray[(linesArray.length - 1)]);
tempSprite.graphics.lineStyle(10,0x000000,1,false,"normal","none","miter",3)
for (var d = 0; d < (linesArray.length/4); d++) {
tempAX = linesArray[(d*4)];
tempAY = linesArray[((d*4)+1)];
tempBX = linesArray[((d*4)+2)];
tempBY = linesArray[((d*4)+3)];
tempLineThickness = lineStyleArray[(d*4)];
tempLineColour = lineStyleArray[((d*4)+1)];
tempLineMiter = lineStyleArray[((d*4)+3)];
if (lineStyleArray[((d*4)+2)] == 0) {
tempLineJoints = JointStyle.MITER;
} else if (lineStyleArray[((d*4)+2)] == 1) {
tempLineJoints = JointStyle.ROUND;
} else if (lineStyleArray[((d*4)+2)] == 2) {
tempLineJoints = JointStyle.BEVEL;
}
tempSprite.graphics.curveTo(tempAX,tempAY,tempBX,tempBY)
}
if (fillTransparency == 0) {
tempSprite.graphics.endFill();
}
}
很可能在路径中间改变直线样式重新启动一个新的段并应用当前的CAPGRESH。< /P>
尝试找出在改变拐角处的线厚度时计算接头的难度。当我将CapStyle更改为圆形或方形时,角度没有间隙。但是我不能使用我想要的Miter JointStyle。我的回答是告诉你这太难实现了,所以不受支持。