- Mastering JavaFX 10
- Sergey Grinev
- 145字
- 2021-06-25 21:21:56
Paint
Basic paint is just a color. The Color class is derived from Paint and provides the following options:
- Predefined constants from Color.BLACK to a fancy Color.ANTIQUEWHITE
- Color-building methods and corresponding getters—rgb(), hsb(), web()
- Opacity through a parameter of the aforementioned methods
- Color-adjusting methods—saturate(), darker(), deriveColor(), and others
Here is a small example of semi-transparent color circles to show how colors can blend. I understand it's slightly harder to grasp in the black-and-white picture, so try it on your computer:
// chapter2/paint/ColorsDemo.java
Pane root = new Pane();
root.getChildren().addAll(
// RED, opacity 0.3
new Circle(150,80,70, Color.rgb(255, 0, 0, 0.3)),
// GREEN, opacity 0.3
new Circle(100,180,70, Color.hsb(120, 1.0, 1.0, 0.3)),
// BLUE, opacity 0.3
new Circle(200,180,70, Color.web("0x0000FF", 0.3))
);
The output is as follows:

If you want to get rid of color at all, you can use the special constant Color.TRANSPARENT.
推薦閱讀
- 黑客攻防實戰技術完全手冊:掃描、嗅探、入侵與防御
- 物聯網短距離無線通信技術應用與開發
- 物聯網檢驗檢測技術
- Mastering JavaFX 10
- 智慧光網絡:關鍵技術、應用實踐和未來演進
- 無線傳感器網絡定位技術
- 現代通信系統(第5版)
- 新媒體交互藝術
- NB-IoT原理和優化
- 從物聯到萬聯:Node.js與樹莓派萬維物聯網構建實戰
- Microservices Development Cookbook
- 加密與解密實戰全攻略
- Hands-On Cloud:Native Microservices with Jakarta EE
- Scala Programming Projects
- Learning IoT with Particle Photon and Electron