查看http://yearbookmachine.github.io/esdocs/#/Javascript/$/colorPicker
colorPicker(Number color)
调用特定于平台的颜色选择对话框,并返回选定的颜色。
参数 数字 颜色 对话框中预选的颜色,如 0xRRGGBB,或 -1 为平台默认值。
var color = $.colorPicker();
alert(color);
编辑1:
AE 主要使用 4 值数组中的颜色,其值从 0 到 1 [r, g, b, a] 但实体不能具有 alpha 值。
Edit2(使其完整和可用):
// check out [http://yearbookmachine.github.io/esdocs/#/Javascript/$/colorPicker](http://yearbookmachine.github.io/esdocs/#/Javascript/$/colorPicker)
// colorPicker(Number color)
// Invokes the platform-specific color selection dialog, and returns the selected color.
// Parameters Number color The color to be preselected in the dialog, as 0xRRGGBB, or -1 for the platform default.
// convert a hexidecimal color string to 0..255 R,G,B
// found here https://gist.github.com/lrvick/2080648
var hexToRGB = function(hex) {
var r = hex >> 16;
var g = hex >> 8 & 0xFF;
var b = hex & 0xFF;
return [r, g, b];
};
var color_decimal = $.colorPicker();
$.writeln(color_decimal);
var color_hexadecimal = color_decimal.toString(16);
$.writeln(color_hexadecimal);
var color_rgb = hexToRGB(parseInt(color_hexadecimal, 16));
$.writeln(color_rgb);
var color_that_ae_add_solid_understands = [color_rgb[0] / 255, color_rgb[1] / 255, color_rgb[2] / 255];
$.writeln(color_that_ae_add_solid_understands);
// also check out the AE scripting guide on addSolid and its parameters
// https://blogs.adobe.com/aftereffects/files/2012/06/After-Effects-CS6-Scripting-Guide.pdf?file=2012/06/After-Effects-CS6-Scripting-Guide.pdf
var comp = app.project.items.addComp(name = "new comp",
width = 100,
height = 100,
pixelAspect = 1,
duration = 1,
frameRate = 25);
var solid = comp.layers.addSolid(color_that_ae_add_solid_understands,
name = "solid",
width = 10,
height = 10,
pixelAspect = 1,
duration = 1);