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

Working with digital color

We have seen how to specify the window background color and the world light color. For all the 2D and 3D graphics, we can also individually specify the color information with RGB values. The coming example will show us how to specify color for the primitives.

Create an empty patch and save it with name gem004.pd in your folder. Put the gemwin object, create and destroy messages, and the toggle box for rendering. In addition, put a gemhead object with a sphere object.

Between the gemhead and the sphere objects, insert a color object. For color specification, it will be a message of three numbers: red, green, and blue. Clicking on the message will change the color of the sphere:

We can also use another object colorRGB to specify color for the graphical shapes. It requires three (RGB) to four (RGB and alpha) number boxes to specify the color. Remember that each number ranges from 0 to 1. If you press the Shift key and click-and-drag a number box upward or downward, you can alter the number in decimal point, in a step of 0.01:

Color specification is straightforward in GEM. By using color or colorRGB, you alter the default color (white) according to the number values. You can also use both the world_light color and the object color together:

Some color input requires three individual numbers. Some color input requires a message list of three numbers. We can combine them together such that the user interface is consistent, that is, three number boxes:

The new object is pack. It simply packs three numbers together. Note the parameters f f f. Each f represents a floating-point number. The number of f corresponds to the number of inlets of the pack object. In this example, three numbers are packed together to form a list for the right-hand inlet of the color object. Nevertheless, this patch is not perfect. If you play around with the number boxes, you will notice that only the red color box (hot inlet) will send out the color list message. The rest (green, blue) will just store the new values and wait until there is a change in the red number box. If you remember how we handled the synchronization of hot and cold inlets, we make use of the trigger object:

For the green and blue color number boxes, they send out the number to a trigger object, trigger b f. Each trigger box will first send out the number to the corresponding number inlet of the pack object and then send out a bang message to the hot inlet of the pack object to output the color number list to the color object. In this case, changes in the green and blue numbers will also go immediately to the sphere object without waiting.

主站蜘蛛池模板: 霍州市| 中方县| 册亨县| 原平市| 天柱县| 泰安市| 封丘县| 烟台市| 台东市| 博客| 武清区| 武胜县| 古田县| 巴彦县| 天等县| 旬阳县| 南岸区| 鲁山县| 绥棱县| 望江县| 克什克腾旗| 胶州市| 寿阳县| 宝兴县| 玉门市| 阳原县| 天等县| 峨眉山市| 漠河县| 肥城市| 西乌珠穆沁旗| 嘉峪关市| 会宁县| 道真| 定襄县| 论坛| 于田县| 玉门市| 闻喜县| 托克托县| 龙川县|