Skip to main content
Participant
July 11, 2021
解決済み

Any easy way to make a random lines like this one

  • July 11, 2021
  • 返信数 3.
  • 2929 ビュー

I just create actions and I need it to start with creating random lines

is that any way to do that

plz help

このトピックへの返信は締め切られました。
解決に役立った回答 Sergey Osokin

I used your idea and the smoothing script from Hiroyuki Sato. And created another version of the random line generator

https://github.com/creold/illustrator-scripts#randomscribble

 

返信数 3

Kurt Gold
Community Expert
Community Expert
July 29, 2021

Great approach, Sergey.

 

Thank you.

 

femkeblanco
Legend
July 11, 2021

This can be very complex.  For the simplest case:

 

var points = 5;  // How many points?
var doc = activeDocument;
var w = doc.width;
var h = doc.height;

var line = new Line();
line.drawLine(points);

function Line () {
    this.path1 = doc.pathItems.add();
    this.drawLine = function (points) {
        for (var i = 0; i < points; i++) {
            this.getPoints();
        }
    };
    this.getPoints = function () {
        var p = this.path1.pathPoints.add();
        p.anchor = this.getPoint();
        p.rightDirection = this.getPoint();
        p.leftDirection = this.getPoint();
        return p;
    };
    this.getPoint = function () {
        var x = Math.floor(Math.random() * w);
        var y = - Math.floor(Math.random() * h);
        return [x, y];
    };
}

 

CarlosCanto
Community Expert
Community Expert
July 11, 2021

c.pfaffenbichler
Community Expert
Community Expert
July 11, 2021

Are you familiar with Illustrator Scripting and JavaScript? 

What are the parameters of the line and its randomness?