Page 1 of 1

Eyedropper and Fill Color (+ Solid Color)

Posted: July 21st, 2004, 6:44 am
by monter
As in JavaScript to make tool Eyedropper and Fill Color.
Thank.

Posted: July 21st, 2004, 10:52 am
by MEGABASTARD
Better yet is there a way to create a tool that would scrub over several pixels to find the average rgb values? ala Shake.

Posted: August 4th, 2004, 11:58 am
by Paul Tuersley
It isn't possible to create an Eyedropper or Fill Color swatch in the scripting UI, but you
could always use the Expression Controls > Color Control effect. You can set the value
of that effect using code such as:

curLayer.Effects.property("Color Control").property("Color").setValue([0,0,0,0]);

(the Color parameter requires a 4 dimensional array [r,g,b,a] of values between 0-1.)

Scripting isn't able to analyze pixel values either, which would be necessary for
an averaging tool. I believe this kind of thing may be possible with Useful Things.
Check out this link: http://www.4thparty.com/products/colorsampler.htm

Paul T

Posted: January 18th, 2005, 8:36 am
by miki
That's a good idea.

Another way to specify a colour (<'scuse the spelling - I'm a Brit!) would have been to create a solid layer (Layer -> New.. -> Solid...) and set the colour on that.
But I can't see a scripting way of reading the colour value of the solid! :?

Miki

Posted: January 18th, 2005, 9:52 am
by Paul Tuersley
Here are a couple of scripts that show some ways of working with a Solid's color. First, create a new comp and run this script. It creates a new solid with a specific color value, then reads that value from the solid's source:

Code: Select all

{
	var activeItem = app.project.activeItem;

	if (activeItem == null || !(activeItem instanceof CompItem)) {
		alert("Select a comp before running this script");
	} else {
		// create a red, comp-sized solid layer.
		theSolid = activeItem.layers.addSolid([1,0,0],"Solid Layer", activeItem.width, activeItem.height, 1);

		// find the solid's color array values.
		c = theSolid.source.mainSource.color;

		alert("Created a new solid with color values [" + c[0] + "," + c[1] + "," + c[2] + "]");
	}
}
Then select the new Solid and run this script. It changes the Solid source's color to white:

Code: Select all

{
	var activeItem = app.project.activeItem;

	if (activeItem == null || !(activeItem instanceof CompItem)) {
		alert("Select a comp before running this script");
	} else {
		if (activeItem.selectedLayers.length < 1) {
			alert("Select a solid layer before running this script");
		} else {
			solidLayer = activeItem.selectedLayers[0];
			solidLayer.source.mainSource.color = [1,1,1];
			alert("Changed solid's color to white.");
		}
	}
}

Posted: January 18th, 2005, 11:58 am
by miki
aha!
Thanks very much for those examples - it all makes sense now!

Miki

Posted: January 19th, 2005, 2:42 pm
by vidpat
As for pixel averaging, two effects come to mind that do this. I am not certain if this is what you had in mind or how they compare to Shake's functionality.

Image Control > Color Link colorizes a layer with several types of averages of the pixels from a layer.

Render > Eyedropper Fill similarly colorizes a layer with the average color within a specified radius of a point.