Awe*_*Guy 2 gradient javafx circular-dependency shapes intersect
我需要向减法圆添加圆形径向渐变。我一直在尝试,但我无法获得圆形渐变。
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);
Run Code Online (Sandbox Code Playgroud)
我也尝试更改值 x 和 y 但我没有得到我想要的。
使用剪辑来切割你的圆圈:
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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
88 次 |
| 最近记录: |