Random images along a path ?

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

szuccaro

Random images along a path ?

Post by szuccaro »

Hello All,

I was hoping someone could point me in the right direction...

I need to place random images along a path.
Was thinking to draw a path, then get the x,y's of the path (array), and placing images with some random rotation and random distance.

I have been searching for a long time and can not seem to come up with anything.

Anyone have ideas ?
lx2

Random images along a path ?

Post by lx2 »

Hmm, I've been searching for aprox. an hour, and didn't find anything.

If you have Vector objects there is a workaraoud with Illustrator:
http://vektorgarten.de/img/tut/Imkreisanordnen.pdf
(Sorry only in German)

If you don't have a curved path maybe you can use the auto-align functions within photoshop.

I don't know if you can get the coordinates of a path with scripting techniques. If so, you can set up a really hardcore script:

Devide the Path into sections(=anchor points). For each object (or layer which will be alligned) one section. Then calculate the rotation: you can get a tangent if you test the coordinates before and after a layer.

then apply the coordinates of the sections and the rotation to each object

if your finish, you can sell this as a plugin
good luck


ps.: in the scriptingreferece (something like C:/program files/adobe/photoshop cs3/script manual/scriptmanual.pdf)
I found a piece of script whith DRAWS a path. Maybe you can extract the anchor points.

Code: Select all#target photoshop

// create a document to work with
var docRef = app.documents.add(300, 300, 72, "Simple Line")
//line #1--it’s a straight line so the coordinates for anchor, left, and //right
//for each point have the same coordinates
// First create the array of PathPointInfo objects. The line has two points,
// so there are two PathPointInfo objects.
var lineArray = new Array()
lineArray[0] = new PathPointInfo
lineArray[0].kind = PointKind.CORNERPOINT
lineArray[0].anchor = Array(100, 100)
lineArray[0].leftDirection = lineArray[0].anchor
lineArray[0].rightDirection = lineArray[0].anchor
lineArray[1] = new PathPointInfo
lineArray[1].kind = PointKind.CORNERPOINT
lineArray[1].anchor = Array(150, 200)
lineArray[1].leftDirection = lineArray[1].anchor
lineArray[1].rightDirection = lineArray[1].anchor
// Next create a SubPathInfo object, which holds the line array
// in its entireSubPath property.
var lineSubPathArray = new Array()
lineSubPathArray[0] = new SubPathInfo()
lineSubPathArray[0].operation = ShapeOperation.SHAPEXOR
lineSubPathArray[0].closed = false
lineSubPathArray[0].entireSubPath = lineArray
//create the path item, using add. This method takes the SubPathInfo object
//and returns a PathItem object, which is added to the pathItems collection
// for the document.
var myPathItem = docRef.pathItems.add("A Line", lineSubPathArray);
// stroke it so we can see something
myPathItem.strokePath(ToolType.BRUSH)

save this as myscript.jsx , run, and see what happens

sorry for my bad english,
greez from munich/germany
szuccaro

Random images along a path ?

Post by szuccaro »

Thanks for the reply.
That is very helpful.

I am currently taking a different approach but your idea would work as well.

My idea now is to draw whatever needs to be drawn, then flatten, then get pixel values at random points, then draw psd/object files if and when a true value ever comes.

By "true" value I mean that, if a pixel is black.

It will be black because the path will be black and background will be white.
So at random pixels and object will be drawn.

I also have to somehow program in a way to change the perspective of the whole thing, and collision to make sure objects dont overlap.

Lots to do so I am getting to doing.

Thanks again for reply, will prob use in future.
-Steve
myranalis

Random images along a path ?

Post by myranalis »

I am trying to do almost the same thing, but I am new to photoshop scripting. Has anyone had any success with this that would be will to share some code/advise?
lukasz

Random images along a path ?

Post by lukasz »

you could also use scattering on brush. you would have to define the pattern first then you could outline the stroke with the defined brush. this would keep it all in photoshop with no need to call illustrator.