Actionscript 3 as3绘制更平滑的圆角

Actionscript 3 as3绘制更平滑的圆角,actionscript-3,graphics,draw,Actionscript 3,Graphics,Draw,我使用以下脚本进行绘制: private function drawBkg():void { _bkg_shp.graphics.clear(); _bkg_shp.graphics.lineStyle(1, 0x0, 1, false, LineScaleMode.NORMAL, CapsStyle.ROUND, JointStyle.ROUND); _bkg_shp.graphics.moveTo(_round, 0); _bkg_shp.graphics.l

我使用以下脚本进行绘制:

private function drawBkg():void {
    _bkg_shp.graphics.clear();
    _bkg_shp.graphics.lineStyle(1, 0x0, 1, false, LineScaleMode.NORMAL, CapsStyle.ROUND, JointStyle.ROUND);
    _bkg_shp.graphics.moveTo(_round, 0);
    _bkg_shp.graphics.lineTo(_width - _round, 0);
    _bkg_shp.graphics.curveTo(_width, 0, _width, _round);
    _bkg_shp.graphics.lineTo(_width, _height - _round);
    _bkg_shp.graphics.curveTo(_width, _height, _width - _round, _height);

    // draw down arrow
    const startPont:int = (_width + _arrowBase) * 0.5;

    _bkg_shp.graphics.lineTo(startPont, _height);
    _bkg_shp.graphics.lineTo(int(_width * 0.5), _height + _arrowHeight);
    _bkg_shp.graphics.lineTo(int(startPont - _arrowBase), _height);

    _bkg_shp.graphics.lineTo(_round, _height);
    _bkg_shp.graphics.curveTo(0, _height, 0, _height -_round);
    _bkg_shp.graphics.lineTo(0, _round);
    _bkg_shp.graphics.curveTo(0, 0, _round, 0);
}
结果是:


有人知道如何消除子弹的模糊性吗?捕捉到像素,取决于大小,可以改善或恶化形状。

避免线条问题的常见解决方案就是不使用线条:)

只能通过填充来绘制圆形矩形: 例如,该代码绘制一个:

/**
 * Draw rectangle with rounded corners with fills (without lines) for 
 * nice scaling of corners
 */
public static function drawRoundRectAsFill (graphics:Graphics, 
                                            x:Number, y:Number, 
                                            w:Number, h:Number, 
                                            radius:Number,
                                            lineColor:uint=0x000000, fillColor:uint=0xffffff,
                                            lineThickness:Number=1,
                                            lineAlpha:Number=1, fillAlpha:Number=1):void
{
    graphics.lineStyle(0,0,0);
    graphics.beginFill(lineColor, lineAlpha);
    graphics.drawRoundRect(x, y, w, h, 2*radius, 2*radius);
    graphics.drawRoundRect(x+lineThickness, y+lineThickness, w-2*lineThickness, h-2*lineThickness, 2*radius-2*lineThickness, 2*radius-2*lineThickness);
    graphics.endFill();

    graphics.beginFill(fillColor,fillAlpha);
    graphics.drawRoundRect(x+lineThickness, y+lineThickness, w-2*lineThickness, h-2*lineThickness, 2*radius-2*lineThickness, 2*radius-2*lineThickness);
    graphics.endFill();
}                                           

一切都使用形状。不要用台词。始终。

增加线条笔划权重的厚度将有助于:

import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;

graphics.lineStyle(2,
                   0x0,
                   1.0,
                   true,
                   LineScaleMode.NORMAL,
                   CapsStyle.SQUARE,
                   JointStyle.MITER);


是的,但仅使用drawRoundRect无法完成我发布的形状,并在之后使用渐变填充。箭头的代码应与您的代码相同(或者,如果您希望在此处进行平滑缩放,则只能使用填充进行绘制)。你没说梯度。在这种情况下,我认为最好的解决方案将是在flashide中绘制它(同样只有填充,没有线条)对不起,我想我需要备份这个?台词看起来很恐怖。这是事实,不是意见。线路完全是低劣和低效的。我是一名设计师/程序员,十多年来一直从事Flash专业工作。我从来没有用过线条。而且,问题是“去除模糊…”你不能“去除模糊”线条。你只能隐藏模糊性。答案是:使用形状。