Sg2.9
Average color script gives a...
Recent RSS
Average color script gives a Syntax error
From:  Jord
Date:  26. August 2013, 08:16

I'm trying to get the Average Color script to work but I get this error:
syntax error
at ExamplesRastersColor Average.js:16

This is the code I'm using:

var rasters = document.getItems({
type: Raster,
selected: true
});

var paths = document.getItems({
type: Path,
selected: true
});

// if the user has selected an image and at least one path
if(rasters.length > 0 && paths.length > 0) {
var raster = rasters[0];
// loop through the paths
for(var i = 0; < paths.length; i++) {
var path = paths[i];
var color = raster .getAverageColor(path);
path.fillColor = color;
}
} else {
Dialog.alert('Please select an image and at least one path');
}

Can somebody tell me what is wrong?

Thanks in advance.

Re: Average color script gives a Syntax error
From:  pqbd
Date:  26. August 2013, 19:00

You have a typo in your for loop:

for(var i = 0; < paths.length; i++)

should be:
for (var i = 0; i < paths.length; i++)

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Triangular 25.01.11