官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 玉溪市| 威海市| 临夏市| 温宿县| 晋江市| 耒阳市| 清远市| 榆中县| 西盟| 岳普湖县| 临海市| 灵宝市| 荣昌县| 夏邑县| 瓦房店市| 肇东市| 无锡市| 朝阳区| 红原县| 崇阳县| 陆丰市| 苗栗县| 萨嘎县| 紫阳县| 四川省| 遂川县| 桐乡市| 金乡县| 望谟县| 尼木县| 富平县| 白河县| 青阳县| 巩留县| 天门市| 若羌县| 乐昌市| 中阳县| 亳州市| 韶关市| 富源县|