Copy link to clipboard
Copied
Hi,
I'm looking for someone to write the script as I can't do it myself and would take me weeks if not months to learn by myself, not very interesting since I use PS a few times per year.
I want to have a white layer to progressively turn black vertically by drawing black pixels on it at random X coordinates. The layer being 1943 pixels wide and 194 high, thus 10 more pixels would be black compared to the previous line. The X positions will be random from 0 to 1942 included, and can't be picked twice on the same row. Black pixels can have the same X if they are on different lines, and can be next to each other on the same line (ie X=583 & X=584).
So for example on the first line I could get 10 black pixels with Y=0 and the X coordinates of 443, 622, 657, 766, 789, 886, 1259, 1376, 1555, 1643. Then second line 20 pixels with Y=1 the X coordinates would be 81, 302, 312, 322, 458, 605, 812, 856, 861, 930, 1369, 1394, 1431, 1490, 1560, 1563, 1602, 1652, 1735.
Thanks already for taking on your time to help me 🙂
Copy link to clipboard
Copied
NB I noticed I missed one value in the example, but it's just to illustrate so not to consider more than that.
Copy link to clipboard
Copied
Hi,
I am not a script writer but I tried your query in ChatGPT which has created some very basic functions for me in other apps successfully, whilst I do believe an actual script writer will get it done more accurately, here is the result.
// Photoshop Script: Progressive Black Pixel Effect
#target photoshop
// Define dimensions and pixel increment
const layerWidth = 1943;
const layerHeight = 194;
const pixelsPerRowStart = 10; // Start with 10 pixels in the first row
// Create a new document
app.documents.add(layerWidth, layerHeight, 72, "Progressive Black Pixels", NewDocumentMode.RGB);
// Fill the background with white
const doc = app.activeDocument;
doc.artLayers.add();
const whiteLayer = doc.artLayers[0];
app.activeDocument.selection.selectAll();
app.activeDocument.selection.fill(app.foregroundColor);
// Ensure the black color is selected
const black = new SolidColor();
black.rgb.red = 0;
black.rgb.green = 0;
black.rgb.blue = 0;
app.foregroundColor = black;
// Function to draw a single pixel
function drawPixel(x, y) {
doc.selection.select([[x, y], [x + 1, y], [x + 1, y + 1], [x, y + 1]]);
doc.selection.fill(app.foregroundColor);
doc.selection.deselect();
}
// Generate and draw black pixels
for (let y = 0; y < layerHeight; y++) {
const pixelsThisRow = pixelsPerRowStart + y * 10; // Incremental increase in pixels
const xPositions = new Set();
// Ensure unique X positions for this row
while (xPositions.size < pixelsThisRow) {
const randomX = Math.floor(Math.random() * layerWidth);
xPositions.add(randomX);
}
// Draw black pixels for the current row
xPositions.forEach(x => drawPixel(x, y));
}
alert("Script finished! Check the created document.");
You would need to copy the above and save as a .jsx, then go to PS, File > Scripts > Browse and open the file you save.
Copy link to clipboard
Copied
It doesn't work, I get an error 25 on line 34
for (let y = 0; y < layerHeight; y++) {
Find more inspiration, events, and resources on the new Adobe Community
Explore Now