gpt4 book ai didi

flash - AS3 : beginGradientFIll() doesn't make me a gradient!

转载 作者:行者123 更新时间:2023-12-02 01:19:46 26 4
gpt4 key购买 nike

我正在尝试用径向渐变渲染一个圆,但我似乎无法弄清楚。

var bkgdGrad:Shape = new Shape();
bkgdGrad.graphics.beginGradientFill(GradientType.RADIAL, [0x0000FF, 0x00FF00], [1, 1], [0, 255],null,"pad");
bkgdGrad.graphics.drawCircle(0,0,r+200);
bkgdGrad.graphics.endFill();
this.addChild(bkgdGrad);

上面的代码为我呈现了一个实心的绿色圆圈。如果我将颜色后面的数组更改为 [1,0] (alpha 数组),我会得到透明填充。我似乎无法让 flash 绘制径向渐变,上面的方法对于 GradientType.LINEAR 没有问题

最佳答案

试试这个,也许这会对你有帮助:

package  
{
import flash.display.Sprite;
import flash.display.GradientType;
import flash.geom.Matrix;

public class RadialGradient extends Sprite
{
private var gType:String;
private var matrix:Matrix;

private var bound:Sprite;

public function RadialGradient()
{
var gType:String = GradientType.RADIAL;

var matrix:Matrix = new Matrix();
matrix.createGradientBox(550,400,0,0,0);

var gColors:Array = [0x0000FF, 0x00FF00];
var gAlphas:Array = [1,1];
var gRatio:Array = [0,255];

var bound:Sprite = new Sprite();
bound.graphics.beginGradientFill(gType,gColors,gAlphas,gRatio,matrix);
bound.graphics.drawCircle(0,0,r+200);
bound.x = bound.y = 0;
addChild(bound);
}
}
}

关于flash - AS3 : beginGradientFIll() doesn't make me a gradient!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6561225/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com