Skip to main content
Participant
July 11, 2021
Answered

Any easy way to make a random lines like this one

  • July 11, 2021
  • 3 replies
  • 2924 views

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

is that any way to do that

plz help

This topic has been closed for replies.
Correct answer 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 replies

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];
    };
}

 

c.pfaffenbichler
Community Expert
Community Expert
July 12, 2021

The example the OP posted looks like they might want curves points, so it might be necessary to additionally lock the angles of leftDirection and rightDirection at 180˚. 

renél80416020
Inspiring
July 12, 2021

Salut!

 Comme cela ?

De elleere

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?