Copy link to clipboard
Copied
Hello everyone, do you know if there is a free script to vary the thickness of the strokes randomly or in a parametric way? so far not found ... Thank you very much
That should work as well if you enable the "Scale Strokes and Effects" option and disable the "Transform Objects" option at the bottom of the Transform Each dialog.
Alternatively, you could try random normal distribution. Again, select items. You can change mean and standard deviation in the first line.
var mean = 5, SD = 1;
var y2 = 0;
var array = [];
function push(items) {
for (var i = 0; i < items.length; i++) {
if (items[i].typename == "PathItem") {
array.push(items[i]);
} else if (items[i].typename == "GroupItem") {
push(items[i].pageItems);
} else if (items[i].typename == "CompoundPathItem") {
...
Maybe you will also find this script useful. https://github.com/creold/illustrator-scripts/blob/master/md/Style.md#randomstrokewidth
Copy link to clipboard
Copied
Do you mean vary the thickness of the strokes from item to item?
Copy link to clipboard
Copied
Hi, I mean that I have a series of strokes and I would like each one to have different thicknesses ... either randomly or by setting some range (min -max), thanks
Copy link to clipboard
Copied
Select items. You can change min and max in the first line.
var min = 1, max = 5;
var array = [];
function push(items) {
for (var i = 0; i < items.length; i++) {
if (items[i].typename == "PathItem") {
array.push(items[i]);
} else if (items[i].typename == "GroupItem") {
push(items[i].pageItems);
} else if (items[i].typename == "CompoundPathItem") {
push(items[i].pathItems);
}
}
}
push(app.selection);
for (var i = 0; i < array.length; i++) {
if (array[i].stroked)
var x = Math.floor(Math.random() * (max - min + 1)) + min;
array[i].strokeWidth = x;
}
Copy link to clipboard
Copied
a thousand thanks!!!
I'll try it tomorrow
Copy link to clipboard
Copied
Alternatively, you could try random normal distribution. Again, select items. You can change mean and standard deviation in the first line.
var mean = 5, SD = 1;
var y2 = 0;
var array = [];
function push(items) {
for (var i = 0; i < items.length; i++) {
if (items[i].typename == "PathItem") {
array.push(items[i]);
} else if (items[i].typename == "GroupItem") {
push(items[i].pageItems);
} else if (items[i].typename == "CompoundPathItem") {
push(items[i].pathItems);
}
}
}
push(app.selection);
for (var i = 0; i < array.length; i++) {
if (array[i].stroked)
var x = randomGaussian(mean, SD);
array[i].strokeWidth = x;
}
// randomGaussian()
function randomGaussian (tempmean, tempsd) {
var mean = tempmean || 0;
var sd = tempsd || 1;
var y1, x1, x2, w;
if (this.gaussianprevious) {
y1 = y2;
this.gaussianprevious = false;
} else {
do {
x1 = this.Math.random() * 2 - 1;
x2 = this.Math.random() * 2 - 1;
w = x1 * x1 + x2 * x2;
} while (w >= 1);
w = Math.sqrt(-2 * Math.log(w) / w);
y1 = x1 * w;
y2 = x2 * w;
this.gaussianprevious = true;
}
return y1 * sd + mean;
}
Copy link to clipboard
Copied
thank you very much femkeblanco! both work perfectly ... thank you very much again!
Copy link to clipboard
Copied
You may try Object menu > Transform > Transform Each with appropriate random settings.
Copy link to clipboard
Copied
thank you, but so I would transform and change the size and length of the strokes while I just want to change the weight / thickness of the lines
Copy link to clipboard
Copied
That should work as well if you enable the "Scale Strokes and Effects" option and disable the "Transform Objects" option at the bottom of the Transform Each dialog.
Copy link to clipboard
Copied
You're right, Kurt also works like this ... I hadn't thought about it.
In any case, the Femkeblanco scripts are very useful.
Thank you all
Copy link to clipboard
Copied
Maybe you will also find this script useful. https://github.com/creold/illustrator-scripts/blob/master/md/Style.md#randomstrokewidth
Copy link to clipboard
Copied
Thanks Sergey, your scripts are always very useful and very well explained!