javascript - Best way to create a color picker gui in extendscript? -


i started out scripting in javascript , knowledge minimal.

i have few lines of code in create solid want gui color picker prompt user can choose color. here example below:

var mycomp = app.project.item(1); //points comp  var mysolid = mycomp.layers.addsolid([10,10,10],"shape", 10, 10, 1.0); // creates 10 pixel shape 

one of first parameters addsolid color enter array value identified in rgb values. wondering if can on ride value variable attached color picker gui? there objects or methods inside extendscript utility can create color picker? wondering.

i hope question clear. thank you

check out http://yearbookmachine.github.io/esdocs/#/javascript/$/colorpicker

colorpicker(number color)
invokes platform-specific color selection dialog, , returns selected color.
parameters number color color preselected in dialog, 0xrrggbb, or -1 platform default.

var color = $.colorpicker(); alert(color); 

edit1:

ae uses colors in 4 value array values 0 1 [r, g, b, a] solid can not have alpha value.

edit2 (to make complete , usable):

// check out [http://yearbookmachine.github.io/esdocs/#/javascript/$/colorpicker](http://yearbookmachine.github.io/esdocs/#/javascript/$/colorpicker)  // colorpicker(number color)   // invokes platform-specific color selection dialog, , returns selected color.   // parameters number color color preselected in dialog, 0xrrggbb, or -1 platform default.    // convert hexidecimal color string 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);  // check out ae scripting guide on addsolid , 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); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -