以下是我的代码(精简为相关函数):
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();
}
}此函数用于在我的程序中重新绘制由数组shapeArray、linesArray和lineStyleArray中的属性定义的形状。问题是,我的程序中形状的角度是不连接的,无论我将它设置为什么JointStyle。
(我不能上传示例图片,因为我没有至少10个声誉。想象两条粗线,没有大写字母以90度的角度连接在一起。而不是圆角、倒角或斜接,而是一个方形形状的间隙,宽度为两条线的一半。)
我不明白为什么,如果我把tempSprite.graphics.lineStyle放在for循环之外,这些角度是相连的。它在lineStyle下的ActionScript3.0参考中声明,
“您可以在绘制路径的过程中调用lineStyle()方法,以便为路径中的不同线段指定不同的样式。”
那么,为什么它不能在循环中工作呢?
将lineStyle放在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();
}
}发布于 2014-01-29 16:08:55
更改路径中间的lineStyle可能会重新启动新的网段并应用当前的CapStyle。
如果在角点处更改线条粗细,请尝试计算关节的难度。
https://stackoverflow.com/questions/21421747
复制相似问题