ActionScript中对齐图形线条样式中风?
-
26-09-2019 - |
题
是能够对准动作图形的笔划?例如,下面的代码创建一个黑色圆角的矩形与被自动居中对齐的灰度行程。
var t:Sprite = new Sprite();
t.graphics.lineStyle(5, 0x555555);
t.graphics.beginFill(0, 1);
t.graphics.drawRoundRect(25, 25, 200, 75, 25, 25);
t.graphics.endFill();
的线型功能似乎并没有提供任何内置用于对准的行程的功能。在Adobe Illustrator中,您可以对齐一个行程是要么中心(半/半出填充的),内部或外部(填充内接壤)。 (填充外接壤)。
解决方案
这并不在Flash支持(甚至在GUI)。你将不得不修改drawRoundRect参数来模拟这种效果。
var strokeWidth:Number = 5;
var strokeAlign:String = 'outer';
var t:Sprite = new Sprite();
t.graphics.lineStyle(strokeWidth, 0x555555);
t.graphics.beginFill(0, 1);
if (strokeAlign == 'outer') {
t.graphics.drawRoundRect(25 - strokeWidth / 2, 25 - strokeWidth / 2, 200 + strokeWidth, 75 + strokeWidth, 25 + strokeWidth / 2, 25 + strokeWidth / 2);
} else if (strokeAlign == 'inner') {
t.graphics.drawRoundRect(25 + strokeWidth / 2, 25 + strokeWidth / 2, 200 - strokeWidth, 75 - strokeWidth, 25 - strokeWidth / 2, 25 - strokeWidth / 2);
} else {
t.graphics.drawRoundRect(25, 25, 200, 75, 25, 25);
}
t.graphics.endFill();
不隶属于 StackOverflow