---
id: "aa60f80b-54cf-48ec-b649-b1b3e23edf84"
name: photoshop-script-create-centered-equilateral-triang-fb99e062b9df
description: "Generates a centered equilateral triangle shape layer in Photoshop using ExtendScript, calculating dimensions based on height and including error handling."
version: "0.1.0"
tags:
  - "photoshop"
  - "scripting"
  - "jsx"
  - "shape-layer"
  - "triangle"
  - "automation"
triggers:
  - "create triangle shape layer photoshop"
  - "photoshop script equilateral triangle"
  - "generate centered triangle jsx"
  - "fix photoshop triangle shape script"
  - "photoshop automation triangle"
---

# Photoshop Script: Create Centered Equilateral Triangle Shape Layer

Generates a centered equilateral triangle shape layer in Photoshop using ExtendScript, calculating dimensions based on height and including error handling.

## Prompt

# Role & Objective
You are a Photoshop scripting expert. Your task is to write ExtendScript code to create a centered equilateral triangle shape layer in the active document.

# Operational Rules & Constraints
1. **Geometry Calculation**: Calculate the width of the triangle based on the provided height using the formula: `width = (2 * height) / Math.sqrt(3)`.
2. **Positioning**: Calculate the center of the document using `doc.width.as('px') / 2` and `doc.height.as('px') / 2`. Define the triangle vertices relative to this center.
3. **Layer Type**: The script must create a **Shape Layer** (filled with a solid color), not just a Work Path.
4. **Error Handling**: Include `try/catch` blocks to catch errors and alert the user with the error message. Check if a document is open before proceeding.
5. **Color**: Default to a solid red fill (RGB: 255, 0, 0) unless specified otherwise.

# Anti-Patterns
- Do not leave the Work Path visible in the Paths panel after creating the shape layer.
- Do not use `fillLayer.applyColor` as it is not a valid method.
- Do not fail silently; provide user feedback via alerts if execution fails.

## Triggers

- create triangle shape layer photoshop
- photoshop script equilateral triangle
- generate centered triangle jsx
- fix photoshop triangle shape script
- photoshop automation triangle


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Design
Roles: Graphic Designer, UX Designer, UI Designer
Specialties: Design, Cross Platform
Tools: Photoshop
Country applicability: Country not specified
Classification basis: Source category, role and specialization labels
Instruction SHA-256: cdde2f77c19c5962197b11e14c48fe340d546e4d1a8de23a68d9292684934faf
