椭圆字幕选择,然后在Photoshop中使用Javascript填充颜色

Elliptical marquee selection then fill with color in Photoshop using Javascript

本文关键字:Javascript 颜色 填充 Photoshop 字幕 选择 然后      更新时间:2023-09-26

基本上,我要做的是在特定位置创建点。点需要放在图像上部每一端的1/3上,然后放在中心。

使用笔刷工具也可以,但我似乎找不到任何关于如何设置笔刷坐标的参考。

到目前为止,我只能想出如何填写选择

function fillSelection()
{
    var doc = app.activeDocument;
    var dotColor = new SolidColor;
    dotColor.rgb.hexValue = '000000';
    var newLayer = doc.artLayers.add();
    doc.selection.fill(dotColor);
    doc.selection.deselect();
}

它应该是这样的:样品

正如你所看到的,我不是这方面的专家,所以非常感谢你的帮助。提前谢谢。

您可以使用以下选项为您的点创建一个选择:

function selectIt(top, left, right, bottom)
{
    var id1 = charIDToTypeID( "setd" );
    var desc1 = new ActionDescriptor();
    var id2 = charIDToTypeID( "null" );
    var ref1 = new ActionReference();
    var id3 = charIDToTypeID( "Chnl" );
    var id4 = charIDToTypeID( "fsel" );
    ref1.putProperty( id3, id4 );
    desc1.putReference( id2, ref1 );
    var id5 = charIDToTypeID( "T   " );
    var desc2 = new ActionDescriptor();
    var id6 = charIDToTypeID( "Top " );
    var id7 = charIDToTypeID( "#Pxl" );
    desc2.putUnitDouble( id6, id7, top ); //top
    var id8 = charIDToTypeID( "Left" );
    var id9 = charIDToTypeID( "#Pxl" );
    desc2.putUnitDouble( id8, id9, left ); //left
    var id10 = charIDToTypeID( "Btom" );
    var id11 = charIDToTypeID( "#Pxl" );
    desc2.putUnitDouble( id10, id11, bottom ); //bottom
    var id12 = charIDToTypeID( "Rght" );
    var id13 = charIDToTypeID( "#Pxl" );
    desc2.putUnitDouble( id12, id13, right ); //right
    var id14 = charIDToTypeID( "Elps" );
    desc1.putObject( id5, id14, desc2 );
    var id15 = charIDToTypeID( "AntA" );
    desc1.putBoolean( id15, true );
    executeAction( id1, desc1, DialogModes.NO );
}

你可能想修改上面的函数,只提供X,Y&函数的半径参数,而不是椭圆的极限(上、下、左、右)。

此外,可能值得在函数开始时进行额外的取消选择,以防您已经选择了某些内容。)