首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Photoshop中当前位置的平铺图像

Photoshop中当前位置的平铺图像
EN

Stack Overflow用户
提问于 2021-01-19 20:08:26
回答 1查看 26关注 0票数 0

是否有一些方法(或脚本)可以在Photoshop(或其他图像编辑软件)中创建重复的图像平铺?

需要保持图像的位置和旋转。

来自图像From

目标图像平铺:To

EN

回答 1

Stack Overflow用户

发布于 2021-01-19 21:20:34

平铺背后的原则是tessellation

在您的示例中,复制并沿其局部x轴(或如我们所见,沿对角向下向右)移动一定量的瓦片,然后再次沿y轴(向下和向左)移动。

在图像中加载,它将重复瓦片12次。然后,您应该能够调整脚本以满足您对其他图像的需求。

代码语言:javascript
复制
// Switch off any dialog boxes
displayDialogs = DialogModes.ERROR; // OFF 

var originalUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;


var duplicatLayerName = "tile";
var offsetX1 = 215; // pixels
var offsetY1 = 111; // pixels
var offsetX2 = -103; // pixels
var offsetY2 = 178; // pixels
var numTilesX = 3;
var numTilesY = 4

// tile them along the x axis
for (var i = 0; i < numTilesX; i++)
{
  duplicate_layer(duplicatLayerName);
  transform(offsetX1, offsetY1, 0);
  // merge down as we go
  app.activeDocument.activeLayer.merge();
}

// now do the same for the y axis
for (var i = 0; i < numTilesY; i++)
{
  duplicate_layer(duplicatLayerName);
  transform(offsetX2, offsetY2, 0);
  // merge down as we go
  app.activeDocument.activeLayer.merge();
}



// Set measuring units back to how they were
app.preferences.rulerUnits = originalUnits;


// Set Display Dialogs back to normal
displayDialogs = DialogModes.ALL; // NORMAL


function transform(dX, dY, angle)
{
  if (angle == undefined ) angle = 0;

  //transform
  // =======================================================
  var id769 = charIDToTypeID( "Trnf" );
  var desc98 = new ActionDescriptor();
  var id770 = charIDToTypeID( "null" );
  var ref59 = new ActionReference();
  var id771 = charIDToTypeID( "Lyr " );
  var id772 = charIDToTypeID( "Ordn" );
  var id773 = charIDToTypeID( "Trgt" );
  ref59.putEnumerated( id771, id772, id773 );
  desc98.putReference( id770, ref59 );
  var id774 = charIDToTypeID( "FTcs" );
  var id775 = charIDToTypeID( "QCSt" );
  var id776 = charIDToTypeID( "Qcsa" );
  desc98.putEnumerated( id774, id775, id776 );
  var id777 = charIDToTypeID( "Ofst" );
  var desc99 = new ActionDescriptor();
  var id778 = charIDToTypeID( "Hrzn" );
  var id779 = charIDToTypeID( "#Pxl" );
  desc99.putUnitDouble( id778, id779, dX );
  var id780 = charIDToTypeID( "Vrtc" );
  var id781 = charIDToTypeID( "#Pxl" );
  desc99.putUnitDouble( id780, id781, dY );
  var id782 = charIDToTypeID( "Ofst" );
  desc98.putObject( id777, id782, desc99 );
  var id783 = charIDToTypeID( "Angl" );
  var id784 = charIDToTypeID( "#Ang" );
  desc98.putUnitDouble( id783, id784, angle );
  executeAction( id769, desc98, DialogModes.NO );
}


// function DUPLICATE LAYER (str)
// --------------------------------------------------------
function duplicate_layer(str)
{
  // duplicate layer
  // =======================================================
  var id1572 = charIDToTypeID( "Dplc" );
  var desc350 = new ActionDescriptor();
  var id1573 = charIDToTypeID( "null" );
  var ref184 = new ActionReference();
  var id1574 = charIDToTypeID( "Lyr " );
  var id1575 = charIDToTypeID( "Ordn" );
  var id1576 = charIDToTypeID( "Trgt" );
  ref184.putEnumerated( id1574, id1575, id1576 );
  desc350.putReference( id1573, ref184 );
  var id1577 = charIDToTypeID( "Nm  " );
  desc350.putString( id1577, str );         // layer name here
  var id1578 = charIDToTypeID( "Vrsn" );
  desc350.putInteger( id1578, 2 );
  executeAction( id1572, desc350, DialogModes.NO );
}

结果将是这样的东西,可以裁剪。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65791221

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档