• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to create a brick-shaped layer that fills the entire canvas

Participant ,
Feb 22, 2025 Feb 22, 2025

Copy link to clipboard

Copied

I want to draw layered rectangular shape layers in the image, similar to a brick effect, but I don't know how to accomplish this. The image below was manually pieced together. I hope to control the number of brick columns using variables Thank you all for your help

2.jpgexpand image3.jpgexpand image4.jpgexpand image5.jpgexpand image

TOPICS
Actions and scripting

Views

83

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 22, 2025 Feb 22, 2025

Copy link to clipboard

Copied

The following code was written using GPT. I'm not sure why a part of the rectangles is missing?

 

#target photoshop

// Get the current document
var doc = app.activeDocument;

// Basic parameters
var rows = 15; // Number of rows for the brick wall
var cols = 3;  // Number of columns for the brick wall

// Get canvas dimensions
var canvasWidth = doc.width;
var canvasHeight = doc.height;

// Calculate the width and height of each brick
var brickWidth = canvasWidth / cols;
var brickHeight = canvasHeight / rows;

// Create the brick wall
for (var row = 0; row < rows; row++) {
    for (var col = 0; col < cols; col++) {
        // Staggered layout, shift odd rows by half a brick's width
        var xPos = col * brickWidth;
        if (row % 2 == 1) {
            xPos += brickWidth / 2; // Stagger odd rows
        }
        
        var yPos = row * brickHeight; // Keep vertical position consistent
        
        createBrick(xPos, yPos, brickWidth, brickHeight);
    }
}

function createBrick(x, y, width, height) {
    // Create rectangle
    var layer = doc.artLayers.add();
    layer.name = "Brick_" + x + "_" + y;
    doc.selection.select([
        [x, y],
        [x + width, y],
        [x + width, y + height],
        [x, y + height]
    ]);
    
    // Fill with color
    var color = new SolidColor();
    color.rgb.hexValue = "FF6B6B"; // Set brick color
    doc.selection.fill(color);
    doc.selection.deselect();
}

102.jpgexpand image

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2025 Feb 23, 2025

Copy link to clipboard

Copied

LATEST

Could you provide a meaningful example – a source image and (a portion of) the images you want to achieve/output ultimately? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 22, 2025 Feb 22, 2025

Copy link to clipboard

Copied

Are you looking for help with scripting specifically?

How should the brick texture interact with the background image?I am sure you'll know how to find and use texture layers via stock sites.

I expect you'll also know the trick of setting Fill Opacity to 0% which shows the layer style without the layer's content?

image.pngexpand image

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 22, 2025 Feb 22, 2025

Copy link to clipboard

Copied

Thank you for your reply. I understand that it can be done using patterns, but my requirement is not just to draw rectangles. Later, I will convert the drawn rectangles into selections, then copy each piece of the image and export them to a folder.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 22, 2025 Feb 22, 2025

Copy link to clipboard

Copied

Now that does sound like something you'd need to automate if possible.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 22, 2025 Feb 22, 2025

Copy link to clipboard

Copied

Do you mean the Variables from the Image menu or a variable number of bricks? If you want a way to manually enter the number of bricks and hit the play button, then you need a script. It can be done using actions, but it's a tedious job, and you need to know how many in advance because there are a gazillion possible combinations. For each combination, one must record a separate action.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines