lineStyle()内部的循环产生断开的角度



这是我的代码(与所讨论的函数凝结):

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和LinestyLaray中属性定义的形状。问题在于,我程序中形状的角度无论我设置了哪种关节型。

(我无法上传示例图片,因为我至少没有10个声誉。想象两个厚线,没有帽子的角度为90度。而不是拐角是圆形,斜角或斜切,有间隙在正方形的一半的形状中,两条线的宽度。)

我不明白的原因是,如果我将tempsprite.graphics.linestyle放在for循环外面,角度是连接的。它在linestyle下的ActionScript 3.0参考中指出,

"您可以在绘制路径中指定不同风格的路径中的Linestyle()方法中调用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();
        }
    }

很可能在路径中间更改线性会重新启动新段并应用当前的CapStyle。

尝试找出计算关节的困难,以防您更改角落的线厚度。

最新更新