使用脚本在Photoshop中着色特定文本

时间:2015-12-19 20:30:20

标签: javascript vb.net photoshop-script

我在VB.Net中创建了一段代码来创建一个文本墙。

文本保存在.txt文件中。我想要做的是复制到photoshop中的文本层,并仅突出显示某些单词(使其具有“语法化”效果,如图中所示)。

我曾尝试编写脚本,我担心我无法得到一个很好的提示来做我想做的事:/。我希望有一个文本框用于“文本墙”,文本框用于颜色的十六进制值,另一个文本框用于选择要突出显示的短语/单词。

VB.NET代码:

Imports System.Console
Imports System.IO
Module Module1
Dim lines As Integer
Dim imported As Integer
Dim wallLines As Integer
Dim wallWords As Integer
Dim sourceName As String
Dim random As New Random
Dim randomLine As Integer
Dim randomPhrase As String

Sub Main()
    WriteLine("         Welcome to Text Wall Generator by E.Skalinski")
    WriteLine("---------------------------------------------------------------------")
    WriteLine("Please enter the name of the .txt file you have saved your text into:")
    WriteLine("---------------------------------------------------------------------")
    WriteLine("       WARNING previous generated walls will be overwritten!")
    WriteLine("    (please make sure each phrase / word is on a seperate line!)")
    sourceName = ReadLine()
    Dim sr As New System.IO.StreamReader(sourceName, FileMode.Open)
    While Not sr.EndOfStream
        sr.ReadLine()
        lines = lines + 1
    End While
    sr.Close()
    Dim sr2 As New System.IO.StreamReader(sourceName, FileMode.Open)
    Dim phrases(lines - 1) As String
    For i = 0 To lines - 1 Step 1
        phrases(i) = sr2.ReadLine()
    Next i
    sr2.Close()
    WriteLine("Imported:")
    For i = 0 To lines - 1
        imported = i
        WriteLine("Line:" & imported & " " & phrases(i))
    Next i
    WriteLine("How many lines would you like to generate?")
    wallLines = ReadLine()
    WriteLine("How many words / phrases per line?")
    wallWords = ReadLine()
    Dim sw As New System.IO.StreamWriter("wall.txt", False)
    Dim wall(wallLines - 1, wallWords - 1) As String
    For i = 0 To wallLines - 1 Step 1
        For j = 0 To wallWords - 1 Step 1
            randomLine = random.Next(0, lines)
            randomPhrase = phrases(randomLine)
            wall(i, j) = randomPhrase
            If j = wallWords - 1 Then
                sw.WriteLine(wall(i, j))
            Else
                sw.Write(wall(i, j) & " ")
            End If
        Next j
    Next i
    sw.Close()
    WriteLine("Generated (file name : wall.txt')")
    ReadLine()
End Sub

Java Script Code尝试:

doc = app.activeDocument;

var myWindow = new Window ("dialog","HighlightWord",undefined,{closeButton:true});

var group = myWindow.add ("group");
group.alignment = "right";
group.add ("statictext", undefined, "Text:");
var maxSize = group.add ("edittext",undefined, );
group.add ("statictext", undefined, "");

group = myWindow.add ("group");
group.alignment = "right";
group.add ("statictext", undefined, "Word / phrase to highlight");
var minSize = group.add ("edittext",undefined, );
group.add ("statictext", undefined, " ");


group = myWindow.add ("group");
group.alignment = "right";
group.add ("statictext", undefined, "Hex color");
var minSize = group.add ("edittext",undefined, );
group.add ("statictext", undefined, " ");

myWindow.show ()

0 个答案:

没有答案