我需要在一个减去的圆上加一个圆形径向梯度。我一直在尝试,但我不能得到一个圆形梯度。

1:全圆,2:全圆的径向梯度,3:减去的圆,4:减法圆中的圆径向梯度试验(不是我想要的) 5:减去圆的圆径向梯度。,这是我想要的.
一旦我得到减去圆(3),我应用径向梯度,但我得到(4)而不是(5)。
int x = 0.5;
int y = 0.5;
RadialGradient gradientCut = new RadialGradient(0, 0, x, y, 1, true, CycleMethod.NO_CYCLE, new
Stop[] {
new Stop(0, Color.ORANGE),
new Stop(0.2, Color.YELLOW),
new Stop(0.5, Color.TRANSPARENT)
});
Rectangle rect = new Rectangle(0, 0, 1000, 75);
Shape cutCircleGradient = Shape.intersect(circleGradientCut, rect);
cutCircleGradient.setFill(gradientCut);我也试着改变值x和y,但是我没有得到我想要的。
发布于 2020-01-13 10:43:48
使用剪辑来分割你的圆圈:
double x = 0.5;
double y = 0.5;
RadialGradient gradientCut = new RadialGradient(0, 0, x, y, 1, true, CycleMethod.NO_CYCLE, new
Stop[]{
new Stop(0, Color.ORANGE),
new Stop(0.2, Color.YELLOW),
new Stop(0.5, Color.TRANSPARENT)
});
double radius = 50.0;
Circle c = new Circle(radius, gradientCut);
var clip = new Rectangle(radius * 2, radius);
clip.setTranslateX(-radius);
clip.setTranslateY(-65);
//clip.setTranslateY(-50); --> half circle
c.setClip(clip);https://stackoverflow.com/questions/59712272
复制相似问题